Skip to content

Commit 8d95e05

Browse files
committed
Purge & Polygon to Parse.Schema
1 parent a6315ba commit 8d95e05

File tree

6 files changed

+12
-132
lines changed

6 files changed

+12
-132
lines changed

integration/test/ParseSchemaTest.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('Schema', () => {
4747
.addDate('dateField')
4848
.addFile('fileField')
4949
.addGeoPoint('geoPointField')
50-
.addPolygon('polygonField')
5150
.addArray('arrayField')
5251
.addObject('objectField')
5352
.addPointer('pointerField', '_User')
@@ -63,7 +62,6 @@ describe('Schema', () => {
6362
assert.equal(result.fields.dateField.type, 'Date');
6463
assert.equal(result.fields.fileField.type, 'File');
6564
assert.equal(result.fields.geoPointField.type, 'GeoPoint');
66-
assert.equal(result.fields.polygonField.type, 'Polygon');
6765
assert.equal(result.fields.arrayField.type, 'Array');
6866
assert.equal(result.fields.objectField.type, 'Object');
6967
assert.equal(result.fields.pointerField.type, 'Pointer');
@@ -134,32 +132,6 @@ describe('Schema', () => {
134132
});
135133
});
136134

137-
it('purge', (done) => {
138-
const testSchema = new Parse.Schema('SchemaTest');
139-
const obj = new Parse.Object('SchemaTest');
140-
obj.save().then(() => {
141-
return testSchema.delete().then(() => {
142-
// Should never reach here
143-
assert.equal(true, false);
144-
}).catch((error) => {
145-
assert.equal(error.code, Parse.Error.INVALID_SCHEMA_OPERATION);
146-
assert.equal(error.message, 'Class SchemaTest is not empty, contains 1 objects, cannot drop schema.');
147-
return Parse.Promise.as();
148-
});
149-
}).then(() => {
150-
return testSchema.purge();
151-
}).then(() => {
152-
const query = new Parse.Query('SchemaTest');
153-
return query.count();
154-
}).then((count) => {
155-
assert.equal(count, 0);
156-
// Delete only works on empty schema, extra check
157-
return testSchema.delete();
158-
}).then(() => {
159-
done();
160-
});
161-
});
162-
163135
it('save index', (done) => {
164136
const testSchema = new Parse.Schema('SchemaTest');
165137
const index = {

src/CoreManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ type RESTController = {
7878
ajax: (method: string, url: string, data: any, headers?: any) => ParsePromise;
7979
};
8080
type SchemaController = {
81-
purge: (className: string) => ParsePromise;
8281
get: (className: string, options: RequestOptions) => ParsePromise;
8382
delete: (className: string, options: RequestOptions) => ParsePromise;
8483
create: (className: string, params: any, options: RequestOptions) => ParsePromise;
@@ -296,7 +295,7 @@ module.exports = {
296295
},
297296

298297
setSchemaController(controller: SchemaController) {
299-
requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
298+
requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send'], controller);
300299
config['SchemaController'] = controller;
301300
},
302301

src/ParseError.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ParseError {
2020
this.code = code;
2121
this.message = message;
2222
}
23-
23+
2424
toString() {
2525
return 'ParseError: ' + this.code + ' ' + this.message;
2626
}
@@ -466,14 +466,6 @@ ParseError.INVALID_LINKED_SESSION = 251;
466466
*/
467467
ParseError.UNSUPPORTED_SERVICE = 252;
468468

469-
/**
470-
* Error code indicating an invalid operation occured on schema
471-
* @property SCHEMA_ERROR
472-
* @static
473-
* @final
474-
*/
475-
ParseError.INVALID_SCHEMA_OPERATION = 255;
476-
477469
/**
478470
* Error code indicating that there were multiple errors. Aggregate errors
479471
* have an "errors" property, which is an array of error objects with more

src/ParseSchema.js

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import ParsePromise from './ParsePromise';
1414

1515
import type { RequestOptions, FullOptions } from './RESTController';
1616

17-
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
17+
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Array', 'Object', 'Pointer', 'Relation'];
1818

1919
/**
2020
* A Parse.Schema object is for handling schema data from Parse.
@@ -181,7 +181,6 @@ class ParseSchema {
181181

182182
/**
183183
* Removing a Schema from Parse
184-
* Can only be used on Schema without objects
185184
*
186185
* @param {Object} options A Backbone-style options object.
187186
* Valid options are:<ul>
@@ -208,34 +207,6 @@ class ParseSchema {
208207
})._thenRunCallbacks(options);
209208
}
210209

211-
/**
212-
* Removes all objects from a Schema (class) in Parse.
213-
* EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
214-
*
215-
* @param {Object} options A Backbone-style options object.
216-
* Valid options are:<ul>
217-
* <li>success: A Backbone-style success callback
218-
* <li>error: An Backbone-style error callback.
219-
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
220-
* be used for this request.
221-
* <li>sessionToken: A valid session token, used for making a request on
222-
* behalf of a specific user.
223-
* </ul>
224-
*
225-
* @return {Parse.Promise} A promise that is resolved with the result when
226-
* the query completes.
227-
*/
228-
purge(options: FullOptions) {
229-
this.assertClassName();
230-
231-
const controller = CoreManager.getSchemaController();
232-
233-
return controller.purge(this.className)
234-
.then((response) => {
235-
return response;
236-
})._thenRunCallbacks(options);
237-
}
238-
239210
/**
240211
* Assert if ClassName has been filled
241212
* @private
@@ -348,16 +319,6 @@ class ParseSchema {
348319
return this.addField(name, 'GeoPoint');
349320
}
350321

351-
/**
352-
* Adding Polygon Field
353-
*
354-
* @param {String} name Name of the field that will be created on Parse
355-
* @return {Parse.Schema} Returns the schema, so you can chain this call.
356-
*/
357-
addPolygon(name: string) {
358-
return this.addField(name, 'Polygon');
359-
}
360-
361322
/**
362323
* Adding Array Field
363324
*
@@ -476,16 +437,6 @@ const DefaultController = {
476437

477438
delete(className: string, options: RequestOptions): ParsePromise {
478439
return this.send(className, 'DELETE', {}, options);
479-
},
480-
481-
purge(className: string): ParsePromise {
482-
const RESTController = CoreManager.getRESTController();
483-
return RESTController.request(
484-
'DELETE',
485-
`purge/${className}`,
486-
{},
487-
{ useMasterKey: true }
488-
);
489440
}
490441
};
491442

src/__tests__/CoreManager-test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ describe('CoreManager', () => {
328328
get: function() {},
329329
create: function() {},
330330
update: function() {},
331-
delete: function() {},
332-
purge: function() {},
331+
delete: function() {}
333332
})).not.toThrow();
334333
});
335334

@@ -339,8 +338,7 @@ describe('CoreManager', () => {
339338
get: function() {},
340339
create: function() {},
341340
update: function() {},
342-
delete: function() {},
343-
purge: function() {},
341+
delete: function() {}
344342
};
345343

346344
CoreManager.setSchemaController(controller);

src/__tests__/ParseSchema-test.js

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('ParseSchema', () => {
4747
.addDate('dateField')
4848
.addFile('fileField')
4949
.addGeoPoint('geoPointField')
50-
.addPolygon('polygonField')
5150
.addArray('arrayField')
5251
.addObject('objectField')
5352
.addPointer('pointerField', '_User')
@@ -60,7 +59,6 @@ describe('ParseSchema', () => {
6059
expect(schema._fields.dateField.type, 'Date');
6160
expect(schema._fields.fileField.type, 'File');
6261
expect(schema._fields.geoPointField.type, 'GeoPoint');
63-
expect(schema._fields.polygonField.type, 'Polygon');
6462
expect(schema._fields.arrayField.type, 'Array');
6563
expect(schema._fields.objectField.type, 'Object');
6664
expect(schema._fields.pointerField.type, 'Pointer');
@@ -164,13 +162,19 @@ describe('ParseSchema', () => {
164162
done();
165163
});
166164

165+
// CoreManager.setSchemaController({
166+
// send() {},
167+
// get() {},
168+
// create() {},
169+
// update() {},
170+
// delete() {},
171+
// });
167172
it('can save schema', (done) => {
168173
CoreManager.setSchemaController({
169174
send() {},
170175
get() {},
171176
update() {},
172177
delete() {},
173-
purge() {},
174178
create(className, params, options) {
175179
expect(className).toBe('SchemaTest');
176180
expect(params).toEqual({
@@ -198,7 +202,6 @@ describe('ParseSchema', () => {
198202
get() {},
199203
create() {},
200204
delete() {},
201-
purge() {},
202205
update(className, params, options) {
203206
expect(className).toBe('SchemaTest');
204207
expect(params).toEqual({
@@ -226,7 +229,6 @@ describe('ParseSchema', () => {
226229
create() {},
227230
update() {},
228231
get() {},
229-
purge() {},
230232
delete(className, options) {
231233
expect(className).toBe('SchemaTest');
232234
expect(options).toEqual({});
@@ -241,33 +243,12 @@ describe('ParseSchema', () => {
241243
});
242244
});
243245

244-
it('can purge schema', (done) => {
245-
CoreManager.setSchemaController({
246-
send() {},
247-
create() {},
248-
update() {},
249-
get() {},
250-
delete() {},
251-
purge(className) {
252-
expect(className).toBe('SchemaTest');
253-
return ParsePromise.as([]);
254-
},
255-
});
256-
257-
var schema = new ParseSchema('SchemaTest');
258-
schema.purge().then((results) => {
259-
expect(results).toEqual([]);
260-
done();
261-
});
262-
});
263-
264246
it('can get schema', (done) => {
265247
CoreManager.setSchemaController({
266248
send() {},
267249
create() {},
268250
update() {},
269251
delete() {},
270-
purge() {},
271252
get(className, options) {
272253
expect(className).toBe('SchemaTest');
273254
expect(options).toEqual({});
@@ -288,7 +269,6 @@ describe('ParseSchema', () => {
288269
create() {},
289270
update() {},
290271
delete() {},
291-
purge() {},
292272
get(className, options) {
293273
expect(className).toBe('SchemaTest');
294274
expect(options).toEqual({ sessionToken: 1234 });
@@ -309,7 +289,6 @@ describe('ParseSchema', () => {
309289
create() {},
310290
update() {},
311291
delete() {},
312-
purge() {},
313292
get(className, options) {
314293
expect(className).toBe('SchemaTest');
315294
expect(options).toEqual({});
@@ -334,7 +313,6 @@ describe('ParseSchema', () => {
334313
create() {},
335314
update() {},
336315
delete() {},
337-
purge() {},
338316
get(className, options) {
339317
expect(className).toBe('');
340318
expect(options).toEqual({});
@@ -356,7 +334,6 @@ describe('ParseSchema', () => {
356334
create() {},
357335
update() {},
358336
delete() {},
359-
purge() {},
360337
get(className, options) {
361338
expect(className).toBe('');
362339
expect(options).toEqual({ sessionToken: 1234 });
@@ -378,7 +355,6 @@ describe('ParseSchema', () => {
378355
create() {},
379356
update() {},
380357
delete() {},
381-
purge() {},
382358
get(className, options) {
383359
expect(className).toBe('');
384360
expect(options).toEqual({});
@@ -442,12 +418,4 @@ describe('SchemaController', () => {
442418
done();
443419
});
444420
});
445-
446-
it('purge schema', (done) => {
447-
var schema = new ParseSchema('SchemaTest');
448-
schema.purge().then((results) => {
449-
expect(results).toEqual([]);
450-
done();
451-
});
452-
});
453421
});

0 commit comments

Comments
 (0)