parse 5.1.1-alpha.1 → 5.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +24 -46
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +37 -49
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +8 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +24 -46
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +37 -49
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +23 -30
package/lib/node/ParseQuery.js
CHANGED
|
@@ -17,33 +17,6 @@ function _interopRequireDefault(obj) {
|
|
|
17
17
|
default: obj
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
/*
|
|
21
|
-
* @flow
|
|
22
|
-
*/
|
|
23
|
-
/*:: import type LiveQuerySubscription from './LiveQuerySubscription';*/
|
|
24
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
25
|
-
/*:: type BatchOptions = FullOptions & { batchSize?: number };*/
|
|
26
|
-
/*:: export type WhereClause = {
|
|
27
|
-
[attr: string]: mixed,
|
|
28
|
-
};*/
|
|
29
|
-
/*:: export type QueryJSON = {
|
|
30
|
-
where: WhereClause,
|
|
31
|
-
watch?: string,
|
|
32
|
-
include?: string,
|
|
33
|
-
excludeKeys?: string,
|
|
34
|
-
keys?: string,
|
|
35
|
-
limit?: number,
|
|
36
|
-
skip?: number,
|
|
37
|
-
order?: string,
|
|
38
|
-
className?: string,
|
|
39
|
-
count?: number,
|
|
40
|
-
hint?: mixed,
|
|
41
|
-
explain?: boolean,
|
|
42
|
-
readPreference?: string,
|
|
43
|
-
includeReadPreference?: string,
|
|
44
|
-
subqueryReadPreference?: string,
|
|
45
|
-
comment?: string,
|
|
46
|
-
};*/
|
|
47
20
|
/**
|
|
48
21
|
* Converts a string into a regex that matches it.
|
|
49
22
|
* Surrounding with \Q .. \E does this, we just need to escape any \E's in
|
|
@@ -53,7 +26,7 @@ function _interopRequireDefault(obj) {
|
|
|
53
26
|
* @private
|
|
54
27
|
* @returns {string}
|
|
55
28
|
*/
|
|
56
|
-
function quote(s
|
|
29
|
+
function quote(s) {
|
|
57
30
|
return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
|
|
58
31
|
}
|
|
59
32
|
|
|
@@ -65,7 +38,7 @@ function quote(s /*: string*/) /*: string*/{
|
|
|
65
38
|
* @private
|
|
66
39
|
* @returns {string}
|
|
67
40
|
*/
|
|
68
|
-
function _getClassNameFromQueries(queries
|
|
41
|
+
function _getClassNameFromQueries(queries) {
|
|
69
42
|
let className = null;
|
|
70
43
|
queries.forEach(q => {
|
|
71
44
|
if (!className) {
|
|
@@ -83,7 +56,7 @@ function _getClassNameFromQueries(queries /*: Array<ParseQuery>*/) /*: ?string*/
|
|
|
83
56
|
* making sure that the data object contains keys for all objects that have
|
|
84
57
|
* been requested with a select, so that our cached state updates correctly.
|
|
85
58
|
*/
|
|
86
|
-
function handleSelectResult(data
|
|
59
|
+
function handleSelectResult(data, select) {
|
|
87
60
|
const serverDataMask = {};
|
|
88
61
|
select.forEach(field => {
|
|
89
62
|
const hasSubObjectSelect = field.indexOf('.') !== -1;
|
|
@@ -221,30 +194,11 @@ class ParseQuery {
|
|
|
221
194
|
/**
|
|
222
195
|
* @property {string} className
|
|
223
196
|
*/
|
|
224
|
-
|
|
225
|
-
/*:: _where: any;*/
|
|
226
|
-
/*:: _watch: Array<string>;*/
|
|
227
|
-
/*:: _include: Array<string>;*/
|
|
228
|
-
/*:: _exclude: Array<string>;*/
|
|
229
|
-
/*:: _select: Array<string>;*/
|
|
230
|
-
/*:: _limit: number;*/
|
|
231
|
-
/*:: _skip: number;*/
|
|
232
|
-
/*:: _count: boolean;*/
|
|
233
|
-
/*:: _order: Array<string>;*/
|
|
234
|
-
/*:: _readPreference: string;*/
|
|
235
|
-
/*:: _includeReadPreference: string;*/
|
|
236
|
-
/*:: _subqueryReadPreference: string;*/
|
|
237
|
-
/*:: _queriesLocalDatastore: boolean;*/
|
|
238
|
-
/*:: _localDatastorePinName: any;*/
|
|
239
|
-
/*:: _extraOptions: { [key: string]: mixed };*/
|
|
240
|
-
/*:: _hint: mixed;*/
|
|
241
|
-
/*:: _explain: boolean;*/
|
|
242
|
-
/*:: _xhrRequest: any;*/
|
|
243
|
-
/*:: _comment: string;*/
|
|
197
|
+
|
|
244
198
|
/**
|
|
245
199
|
* @param {(string | Parse.Object)} objectClass An instance of a subclass of Parse.Object, or a Parse className string.
|
|
246
200
|
*/
|
|
247
|
-
constructor(objectClass
|
|
201
|
+
constructor(objectClass) {
|
|
248
202
|
if (typeof objectClass === 'string') {
|
|
249
203
|
if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
|
|
250
204
|
this.className = '_User';
|
|
@@ -254,10 +208,11 @@ class ParseQuery {
|
|
|
254
208
|
} else if (objectClass instanceof _ParseObject.default) {
|
|
255
209
|
this.className = objectClass.className;
|
|
256
210
|
} else if (typeof objectClass === 'function') {
|
|
257
|
-
|
|
258
|
-
|
|
211
|
+
const objClass = objectClass;
|
|
212
|
+
if (typeof objClass.className === 'string') {
|
|
213
|
+
this.className = objClass.className;
|
|
259
214
|
} else {
|
|
260
|
-
const obj = new
|
|
215
|
+
const obj = new objClass();
|
|
261
216
|
this.className = obj.className;
|
|
262
217
|
}
|
|
263
218
|
} else {
|
|
@@ -289,7 +244,7 @@ class ParseQuery {
|
|
|
289
244
|
* @param {Array} queries
|
|
290
245
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
291
246
|
*/
|
|
292
|
-
_orQuery(queries
|
|
247
|
+
_orQuery(queries) {
|
|
293
248
|
const queryJSON = queries.map(q => {
|
|
294
249
|
return q.toJSON().where;
|
|
295
250
|
});
|
|
@@ -303,7 +258,7 @@ class ParseQuery {
|
|
|
303
258
|
* @param {Array} queries
|
|
304
259
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
305
260
|
*/
|
|
306
|
-
_andQuery(queries
|
|
261
|
+
_andQuery(queries) {
|
|
307
262
|
const queryJSON = queries.map(q => {
|
|
308
263
|
return q.toJSON().where;
|
|
309
264
|
});
|
|
@@ -317,7 +272,7 @@ class ParseQuery {
|
|
|
317
272
|
* @param {Array} queries
|
|
318
273
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
319
274
|
*/
|
|
320
|
-
_norQuery(queries
|
|
275
|
+
_norQuery(queries) {
|
|
321
276
|
const queryJSON = queries.map(q => {
|
|
322
277
|
return q.toJSON().where;
|
|
323
278
|
});
|
|
@@ -333,7 +288,7 @@ class ParseQuery {
|
|
|
333
288
|
* @param value
|
|
334
289
|
* @returns {Parse.Query}
|
|
335
290
|
*/
|
|
336
|
-
_addCondition(key
|
|
291
|
+
_addCondition(key, condition, value) {
|
|
337
292
|
if (!this._where[key] || typeof this._where[key] === 'string') {
|
|
338
293
|
this._where[key] = {};
|
|
339
294
|
}
|
|
@@ -347,10 +302,10 @@ class ParseQuery {
|
|
|
347
302
|
* @param string
|
|
348
303
|
* @returns {string}
|
|
349
304
|
*/
|
|
350
|
-
_regexStartWith(string
|
|
305
|
+
_regexStartWith(string) {
|
|
351
306
|
return '^' + quote(string);
|
|
352
307
|
}
|
|
353
|
-
async _handleOfflineQuery(params
|
|
308
|
+
async _handleOfflineQuery(params) {
|
|
354
309
|
_OfflineQuery.default.validateQuery(this);
|
|
355
310
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
356
311
|
const objects = await localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
|
|
@@ -387,7 +342,6 @@ class ParseQuery {
|
|
|
387
342
|
if (params.count) {
|
|
388
343
|
count = results.length; // total count from response
|
|
389
344
|
}
|
|
390
|
-
|
|
391
345
|
if (params.skip) {
|
|
392
346
|
if (params.skip >= results.length) {
|
|
393
347
|
results = [];
|
|
@@ -414,8 +368,8 @@ class ParseQuery {
|
|
|
414
368
|
*
|
|
415
369
|
* @returns {object} The JSON representation of the query.
|
|
416
370
|
*/
|
|
417
|
-
toJSON()
|
|
418
|
-
const params
|
|
371
|
+
toJSON() {
|
|
372
|
+
const params = {
|
|
419
373
|
where: this._where
|
|
420
374
|
};
|
|
421
375
|
if (this._watch.length) {
|
|
@@ -487,7 +441,7 @@ class ParseQuery {
|
|
|
487
441
|
* @param {QueryJSON} json from Parse.Query.toJSON() method
|
|
488
442
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
489
443
|
*/
|
|
490
|
-
withJSON(json
|
|
444
|
+
withJSON(json) {
|
|
491
445
|
if (json.where) {
|
|
492
446
|
this._where = json.where;
|
|
493
447
|
}
|
|
@@ -551,7 +505,7 @@ class ParseQuery {
|
|
|
551
505
|
* @param {QueryJSON} json from Parse.Query.toJSON() method
|
|
552
506
|
* @returns {Parse.Query} new created query
|
|
553
507
|
*/
|
|
554
|
-
static fromJSON(className
|
|
508
|
+
static fromJSON(className, json) {
|
|
555
509
|
const query = new ParseQuery(className);
|
|
556
510
|
return query.withJSON(json);
|
|
557
511
|
}
|
|
@@ -573,7 +527,7 @@ class ParseQuery {
|
|
|
573
527
|
* @returns {Promise} A promise that is resolved with the result when
|
|
574
528
|
* the query completes.
|
|
575
529
|
*/
|
|
576
|
-
get(objectId
|
|
530
|
+
get(objectId, options) {
|
|
577
531
|
this.equalTo('objectId', objectId);
|
|
578
532
|
const firstOptions = {};
|
|
579
533
|
if (options && options.hasOwnProperty('useMasterKey')) {
|
|
@@ -612,7 +566,7 @@ class ParseQuery {
|
|
|
612
566
|
* @returns {Promise} A promise that is resolved with the results when
|
|
613
567
|
* the query completes.
|
|
614
568
|
*/
|
|
615
|
-
find(options
|
|
569
|
+
find(options) {
|
|
616
570
|
options = options || {};
|
|
617
571
|
const findOptions = {};
|
|
618
572
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
@@ -631,11 +585,12 @@ class ParseQuery {
|
|
|
631
585
|
return this._handleOfflineQuery(this.toJSON());
|
|
632
586
|
}
|
|
633
587
|
return controller.find(this.className, this.toJSON(), findOptions).then(response => {
|
|
588
|
+
var _response$results;
|
|
634
589
|
// Return generic object when explain is used
|
|
635
590
|
if (this._explain) {
|
|
636
591
|
return response.results;
|
|
637
592
|
}
|
|
638
|
-
const results = response.results.map(data => {
|
|
593
|
+
const results = (_response$results = response.results) === null || _response$results === void 0 ? void 0 : _response$results.map(data => {
|
|
639
594
|
// In cases of relations, the server may send back a className
|
|
640
595
|
// on the top level of the payload
|
|
641
596
|
const override = response.className || this.className;
|
|
@@ -681,9 +636,9 @@ class ParseQuery {
|
|
|
681
636
|
* @returns {Promise} A promise that is resolved with the results when
|
|
682
637
|
* the query completes.
|
|
683
638
|
*/
|
|
684
|
-
async findAll(options
|
|
685
|
-
let result
|
|
686
|
-
await this.eachBatch(
|
|
639
|
+
async findAll(options) {
|
|
640
|
+
let result = [];
|
|
641
|
+
await this.eachBatch(objects => {
|
|
687
642
|
result = [...result, ...objects];
|
|
688
643
|
}, options);
|
|
689
644
|
return result;
|
|
@@ -693,6 +648,8 @@ class ParseQuery {
|
|
|
693
648
|
* Counts the number of objects that match this query.
|
|
694
649
|
*
|
|
695
650
|
* @param {object} options
|
|
651
|
+
* @param {boolean} [options.useMasterKey]
|
|
652
|
+
* @param {string} [options.sessionToken]
|
|
696
653
|
* Valid options are:<ul>
|
|
697
654
|
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
698
655
|
* be used for this request.
|
|
@@ -702,7 +659,7 @@ class ParseQuery {
|
|
|
702
659
|
* @returns {Promise} A promise that is resolved with the count when
|
|
703
660
|
* the query completes.
|
|
704
661
|
*/
|
|
705
|
-
count(options
|
|
662
|
+
count(options) {
|
|
706
663
|
options = options || {};
|
|
707
664
|
const findOptions = {};
|
|
708
665
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
@@ -726,16 +683,14 @@ class ParseQuery {
|
|
|
726
683
|
*
|
|
727
684
|
* @param {string} key A field to find distinct values
|
|
728
685
|
* @param {object} options
|
|
729
|
-
*
|
|
730
|
-
* <li>sessionToken: A valid session token, used for making a request on
|
|
731
|
-
* behalf of a specific user.
|
|
732
|
-
* </ul>
|
|
686
|
+
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
|
|
733
687
|
* @returns {Promise} A promise that is resolved with the query completes.
|
|
734
688
|
*/
|
|
735
|
-
distinct(key
|
|
689
|
+
distinct(key, options) {
|
|
736
690
|
options = options || {};
|
|
737
|
-
const distinctOptions = {
|
|
738
|
-
|
|
691
|
+
const distinctOptions = {
|
|
692
|
+
useMasterKey: true
|
|
693
|
+
};
|
|
739
694
|
if (options.hasOwnProperty('sessionToken')) {
|
|
740
695
|
distinctOptions.sessionToken = options.sessionToken;
|
|
741
696
|
}
|
|
@@ -755,16 +710,15 @@ class ParseQuery {
|
|
|
755
710
|
* Executes an aggregate query and returns aggregate results
|
|
756
711
|
*
|
|
757
712
|
* @param {(Array|object)} pipeline Array or Object of stages to process query
|
|
758
|
-
* @param {object} options
|
|
759
|
-
*
|
|
760
|
-
* behalf of a specific user.
|
|
761
|
-
* </ul>
|
|
713
|
+
* @param {object} options
|
|
714
|
+
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
|
|
762
715
|
* @returns {Promise} A promise that is resolved with the query completes.
|
|
763
716
|
*/
|
|
764
|
-
aggregate(pipeline
|
|
717
|
+
aggregate(pipeline, options) {
|
|
765
718
|
options = options || {};
|
|
766
|
-
const aggregateOptions = {
|
|
767
|
-
|
|
719
|
+
const aggregateOptions = {
|
|
720
|
+
useMasterKey: true
|
|
721
|
+
};
|
|
768
722
|
if (options.hasOwnProperty('sessionToken')) {
|
|
769
723
|
aggregateOptions.sessionToken = options.sessionToken;
|
|
770
724
|
}
|
|
@@ -808,8 +762,7 @@ class ParseQuery {
|
|
|
808
762
|
* @returns {Promise} A promise that is resolved with the object when
|
|
809
763
|
* the query completes.
|
|
810
764
|
*/
|
|
811
|
-
first(options
|
|
812
|
-
options = options || {};
|
|
765
|
+
first(options = {}) {
|
|
813
766
|
const findOptions = {};
|
|
814
767
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
815
768
|
findOptions.useMasterKey = options.useMasterKey;
|
|
@@ -877,7 +830,7 @@ class ParseQuery {
|
|
|
877
830
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
878
831
|
* iteration has completed.
|
|
879
832
|
*/
|
|
880
|
-
eachBatch(callback
|
|
833
|
+
eachBatch(callback, options) {
|
|
881
834
|
options = options || {};
|
|
882
835
|
if (this._order || this._skip || this._limit >= 0) {
|
|
883
836
|
return Promise.reject('Cannot iterate on a query with sort, skip, or limit.');
|
|
@@ -959,7 +912,7 @@ class ParseQuery {
|
|
|
959
912
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
960
913
|
* iteration has completed.
|
|
961
914
|
*/
|
|
962
|
-
each(callback
|
|
915
|
+
each(callback, options) {
|
|
963
916
|
return this.eachBatch(results => {
|
|
964
917
|
let callbacksDone = Promise.resolve();
|
|
965
918
|
results.forEach(result => {
|
|
@@ -977,7 +930,7 @@ class ParseQuery {
|
|
|
977
930
|
* @param {(string|object)} value String or Object of index that should be used when executing query
|
|
978
931
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
979
932
|
*/
|
|
980
|
-
hint(value
|
|
933
|
+
hint(value) {
|
|
981
934
|
if (typeof value === 'undefined') {
|
|
982
935
|
delete this._hint;
|
|
983
936
|
}
|
|
@@ -991,7 +944,7 @@ class ParseQuery {
|
|
|
991
944
|
* @param {boolean} explain Used to toggle the information on the query plan.
|
|
992
945
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
993
946
|
*/
|
|
994
|
-
explain(explain
|
|
947
|
+
explain(explain = true) {
|
|
995
948
|
if (typeof explain !== 'boolean') {
|
|
996
949
|
throw new Error('You can only set explain to a boolean value');
|
|
997
950
|
}
|
|
@@ -1021,7 +974,7 @@ class ParseQuery {
|
|
|
1021
974
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
1022
975
|
* iteration has completed.
|
|
1023
976
|
*/
|
|
1024
|
-
async map(callback
|
|
977
|
+
async map(callback, options) {
|
|
1025
978
|
const array = [];
|
|
1026
979
|
let index = 0;
|
|
1027
980
|
await this.each(object => {
|
|
@@ -1056,7 +1009,7 @@ class ParseQuery {
|
|
|
1056
1009
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
1057
1010
|
* iteration has completed.
|
|
1058
1011
|
*/
|
|
1059
|
-
async reduce(callback
|
|
1012
|
+
async reduce(callback, initialValue, options) {
|
|
1060
1013
|
let accumulator = initialValue;
|
|
1061
1014
|
let index = 0;
|
|
1062
1015
|
await this.each(object => {
|
|
@@ -1102,7 +1055,7 @@ class ParseQuery {
|
|
|
1102
1055
|
* @returns {Promise} A promise that will be fulfilled once the
|
|
1103
1056
|
* iteration has completed.
|
|
1104
1057
|
*/
|
|
1105
|
-
async filter(callback
|
|
1058
|
+
async filter(callback, options) {
|
|
1106
1059
|
const array = [];
|
|
1107
1060
|
let index = 0;
|
|
1108
1061
|
await this.each(object => {
|
|
@@ -1126,7 +1079,7 @@ class ParseQuery {
|
|
|
1126
1079
|
* @param value The value that the Parse.Object must contain.
|
|
1127
1080
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1128
1081
|
*/
|
|
1129
|
-
equalTo(key
|
|
1082
|
+
equalTo(key, value) {
|
|
1130
1083
|
if (key && typeof key === 'object') {
|
|
1131
1084
|
Object.entries(key).forEach(([k, val]) => this.equalTo(k, val));
|
|
1132
1085
|
return this;
|
|
@@ -1146,7 +1099,7 @@ class ParseQuery {
|
|
|
1146
1099
|
* @param value The value that must not be equalled.
|
|
1147
1100
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1148
1101
|
*/
|
|
1149
|
-
notEqualTo(key
|
|
1102
|
+
notEqualTo(key, value) {
|
|
1150
1103
|
if (key && typeof key === 'object') {
|
|
1151
1104
|
Object.entries(key).forEach(([k, val]) => this.notEqualTo(k, val));
|
|
1152
1105
|
return this;
|
|
@@ -1162,7 +1115,7 @@ class ParseQuery {
|
|
|
1162
1115
|
* @param value The value that provides an upper bound.
|
|
1163
1116
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1164
1117
|
*/
|
|
1165
|
-
lessThan(key
|
|
1118
|
+
lessThan(key, value) {
|
|
1166
1119
|
return this._addCondition(key, '$lt', value);
|
|
1167
1120
|
}
|
|
1168
1121
|
|
|
@@ -1174,7 +1127,7 @@ class ParseQuery {
|
|
|
1174
1127
|
* @param value The value that provides an lower bound.
|
|
1175
1128
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1176
1129
|
*/
|
|
1177
|
-
greaterThan(key
|
|
1130
|
+
greaterThan(key, value) {
|
|
1178
1131
|
return this._addCondition(key, '$gt', value);
|
|
1179
1132
|
}
|
|
1180
1133
|
|
|
@@ -1186,7 +1139,7 @@ class ParseQuery {
|
|
|
1186
1139
|
* @param value The value that provides an upper bound.
|
|
1187
1140
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1188
1141
|
*/
|
|
1189
|
-
lessThanOrEqualTo(key
|
|
1142
|
+
lessThanOrEqualTo(key, value) {
|
|
1190
1143
|
return this._addCondition(key, '$lte', value);
|
|
1191
1144
|
}
|
|
1192
1145
|
|
|
@@ -1198,7 +1151,7 @@ class ParseQuery {
|
|
|
1198
1151
|
* @param {*} value The value that provides an lower bound.
|
|
1199
1152
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1200
1153
|
*/
|
|
1201
|
-
greaterThanOrEqualTo(key
|
|
1154
|
+
greaterThanOrEqualTo(key, value) {
|
|
1202
1155
|
return this._addCondition(key, '$gte', value);
|
|
1203
1156
|
}
|
|
1204
1157
|
|
|
@@ -1210,7 +1163,7 @@ class ParseQuery {
|
|
|
1210
1163
|
* @param {Array<*>} value The values that will match.
|
|
1211
1164
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1212
1165
|
*/
|
|
1213
|
-
containedIn(key
|
|
1166
|
+
containedIn(key, value) {
|
|
1214
1167
|
return this._addCondition(key, '$in', value);
|
|
1215
1168
|
}
|
|
1216
1169
|
|
|
@@ -1222,7 +1175,7 @@ class ParseQuery {
|
|
|
1222
1175
|
* @param {Array<*>} value The values that will not match.
|
|
1223
1176
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1224
1177
|
*/
|
|
1225
|
-
notContainedIn(key
|
|
1178
|
+
notContainedIn(key, value) {
|
|
1226
1179
|
return this._addCondition(key, '$nin', value);
|
|
1227
1180
|
}
|
|
1228
1181
|
|
|
@@ -1234,7 +1187,7 @@ class ParseQuery {
|
|
|
1234
1187
|
* @param {Array} values The values that will match.
|
|
1235
1188
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1236
1189
|
*/
|
|
1237
|
-
containedBy(key
|
|
1190
|
+
containedBy(key, values) {
|
|
1238
1191
|
return this._addCondition(key, '$containedBy', values);
|
|
1239
1192
|
}
|
|
1240
1193
|
|
|
@@ -1246,7 +1199,7 @@ class ParseQuery {
|
|
|
1246
1199
|
* @param {Array} values The values that will match.
|
|
1247
1200
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1248
1201
|
*/
|
|
1249
|
-
containsAll(key
|
|
1202
|
+
containsAll(key, values) {
|
|
1250
1203
|
return this._addCondition(key, '$all', values);
|
|
1251
1204
|
}
|
|
1252
1205
|
|
|
@@ -1258,14 +1211,13 @@ class ParseQuery {
|
|
|
1258
1211
|
* @param {Array<string>} values The string values that will match as starting string.
|
|
1259
1212
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1260
1213
|
*/
|
|
1261
|
-
containsAllStartingWith(key
|
|
1262
|
-
const _this = this;
|
|
1214
|
+
containsAllStartingWith(key, values) {
|
|
1263
1215
|
if (!Array.isArray(values)) {
|
|
1264
1216
|
values = [values];
|
|
1265
1217
|
}
|
|
1266
1218
|
const regexObject = values.map(value => {
|
|
1267
1219
|
return {
|
|
1268
|
-
$regex:
|
|
1220
|
+
$regex: this._regexStartWith(value)
|
|
1269
1221
|
};
|
|
1270
1222
|
});
|
|
1271
1223
|
return this.containsAll(key, regexObject);
|
|
@@ -1277,7 +1229,7 @@ class ParseQuery {
|
|
|
1277
1229
|
* @param {string} key The key that should exist.
|
|
1278
1230
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1279
1231
|
*/
|
|
1280
|
-
exists(key
|
|
1232
|
+
exists(key) {
|
|
1281
1233
|
return this._addCondition(key, '$exists', true);
|
|
1282
1234
|
}
|
|
1283
1235
|
|
|
@@ -1287,7 +1239,7 @@ class ParseQuery {
|
|
|
1287
1239
|
* @param {string} key The key that should not exist
|
|
1288
1240
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1289
1241
|
*/
|
|
1290
|
-
doesNotExist(key
|
|
1242
|
+
doesNotExist(key) {
|
|
1291
1243
|
return this._addCondition(key, '$exists', false);
|
|
1292
1244
|
}
|
|
1293
1245
|
|
|
@@ -1297,20 +1249,22 @@ class ParseQuery {
|
|
|
1297
1249
|
* This may be slow for large datasets.
|
|
1298
1250
|
*
|
|
1299
1251
|
* @param {string} key The key that the string to match is stored in.
|
|
1300
|
-
* @param {RegExp} regex The regular expression pattern to match.
|
|
1252
|
+
* @param {RegExp | string} regex The regular expression pattern to match.
|
|
1301
1253
|
* @param {string} modifiers The regular expression mode.
|
|
1302
1254
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1303
1255
|
*/
|
|
1304
|
-
matches(key
|
|
1256
|
+
matches(key, regex, modifiers) {
|
|
1305
1257
|
this._addCondition(key, '$regex', regex);
|
|
1306
1258
|
if (!modifiers) {
|
|
1307
1259
|
modifiers = '';
|
|
1308
1260
|
}
|
|
1309
|
-
if (regex
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1261
|
+
if (typeof regex !== 'string') {
|
|
1262
|
+
if (regex.ignoreCase) {
|
|
1263
|
+
modifiers += 'i';
|
|
1264
|
+
}
|
|
1265
|
+
if (regex.multiline) {
|
|
1266
|
+
modifiers += 'm';
|
|
1267
|
+
}
|
|
1314
1268
|
}
|
|
1315
1269
|
if (modifiers.length) {
|
|
1316
1270
|
this._addCondition(key, '$options', modifiers);
|
|
@@ -1327,7 +1281,7 @@ class ParseQuery {
|
|
|
1327
1281
|
* @param {Parse.Query} query The query that should match.
|
|
1328
1282
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1329
1283
|
*/
|
|
1330
|
-
matchesQuery(key
|
|
1284
|
+
matchesQuery(key, query) {
|
|
1331
1285
|
const queryJSON = query.toJSON();
|
|
1332
1286
|
queryJSON.className = query.className;
|
|
1333
1287
|
return this._addCondition(key, '$inQuery', queryJSON);
|
|
@@ -1342,7 +1296,7 @@ class ParseQuery {
|
|
|
1342
1296
|
* @param {Parse.Query} query The query that should not match.
|
|
1343
1297
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1344
1298
|
*/
|
|
1345
|
-
doesNotMatchQuery(key
|
|
1299
|
+
doesNotMatchQuery(key, query) {
|
|
1346
1300
|
const queryJSON = query.toJSON();
|
|
1347
1301
|
queryJSON.className = query.className;
|
|
1348
1302
|
return this._addCondition(key, '$notInQuery', queryJSON);
|
|
@@ -1359,7 +1313,7 @@ class ParseQuery {
|
|
|
1359
1313
|
* @param {Parse.Query} query The query to run.
|
|
1360
1314
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1361
1315
|
*/
|
|
1362
|
-
matchesKeyInQuery(key
|
|
1316
|
+
matchesKeyInQuery(key, queryKey, query) {
|
|
1363
1317
|
const queryJSON = query.toJSON();
|
|
1364
1318
|
queryJSON.className = query.className;
|
|
1365
1319
|
return this._addCondition(key, '$select', {
|
|
@@ -1379,7 +1333,7 @@ class ParseQuery {
|
|
|
1379
1333
|
* @param {Parse.Query} query The query to run.
|
|
1380
1334
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1381
1335
|
*/
|
|
1382
|
-
doesNotMatchKeyInQuery(key
|
|
1336
|
+
doesNotMatchKeyInQuery(key, queryKey, query) {
|
|
1383
1337
|
const queryJSON = query.toJSON();
|
|
1384
1338
|
queryJSON.className = query.className;
|
|
1385
1339
|
return this._addCondition(key, '$dontSelect', {
|
|
@@ -1396,7 +1350,7 @@ class ParseQuery {
|
|
|
1396
1350
|
* @param {string} substring The substring that the value must contain.
|
|
1397
1351
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1398
1352
|
*/
|
|
1399
|
-
contains(key
|
|
1353
|
+
contains(key, substring) {
|
|
1400
1354
|
if (typeof substring !== 'string') {
|
|
1401
1355
|
throw new Error('The value being searched for must be a string.');
|
|
1402
1356
|
}
|
|
@@ -1432,7 +1386,7 @@ class ParseQuery {
|
|
|
1432
1386
|
* @param {boolean} options.diacriticSensitive A boolean flag to enable or disable diacritic sensitive search.
|
|
1433
1387
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1434
1388
|
*/
|
|
1435
|
-
fullText(key
|
|
1389
|
+
fullText(key, value, options = {}) {
|
|
1436
1390
|
options = options || {};
|
|
1437
1391
|
if (!key) {
|
|
1438
1392
|
throw new Error('A key is required.');
|
|
@@ -1486,7 +1440,7 @@ class ParseQuery {
|
|
|
1486
1440
|
* @param {string} modifiers The regular expression mode.
|
|
1487
1441
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1488
1442
|
*/
|
|
1489
|
-
startsWith(key
|
|
1443
|
+
startsWith(key, prefix, modifiers) {
|
|
1490
1444
|
if (typeof prefix !== 'string') {
|
|
1491
1445
|
throw new Error('The value being searched for must be a string.');
|
|
1492
1446
|
}
|
|
@@ -1502,7 +1456,7 @@ class ParseQuery {
|
|
|
1502
1456
|
* @param {string} modifiers The regular expression mode.
|
|
1503
1457
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1504
1458
|
*/
|
|
1505
|
-
endsWith(key
|
|
1459
|
+
endsWith(key, suffix, modifiers) {
|
|
1506
1460
|
if (typeof suffix !== 'string') {
|
|
1507
1461
|
throw new Error('The value being searched for must be a string.');
|
|
1508
1462
|
}
|
|
@@ -1517,7 +1471,7 @@ class ParseQuery {
|
|
|
1517
1471
|
* @param {Parse.GeoPoint} point The reference Parse.GeoPoint that is used.
|
|
1518
1472
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1519
1473
|
*/
|
|
1520
|
-
near(key
|
|
1474
|
+
near(key, point) {
|
|
1521
1475
|
if (!(point instanceof _ParseGeoPoint.default)) {
|
|
1522
1476
|
// Try to cast it as a GeoPoint
|
|
1523
1477
|
point = new _ParseGeoPoint.default(point);
|
|
@@ -1537,7 +1491,7 @@ class ParseQuery {
|
|
|
1537
1491
|
* defaults to true.
|
|
1538
1492
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1539
1493
|
*/
|
|
1540
|
-
withinRadians(key
|
|
1494
|
+
withinRadians(key, point, maxDistance, sorted) {
|
|
1541
1495
|
if (sorted || sorted === undefined) {
|
|
1542
1496
|
this.near(key, point);
|
|
1543
1497
|
return this._addCondition(key, '$maxDistance', maxDistance);
|
|
@@ -1561,7 +1515,7 @@ class ParseQuery {
|
|
|
1561
1515
|
* defaults to true.
|
|
1562
1516
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1563
1517
|
*/
|
|
1564
|
-
withinMiles(key
|
|
1518
|
+
withinMiles(key, point, maxDistance, sorted) {
|
|
1565
1519
|
return this.withinRadians(key, point, maxDistance / 3958.8, sorted);
|
|
1566
1520
|
}
|
|
1567
1521
|
|
|
@@ -1578,7 +1532,7 @@ class ParseQuery {
|
|
|
1578
1532
|
* defaults to true.
|
|
1579
1533
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1580
1534
|
*/
|
|
1581
|
-
withinKilometers(key
|
|
1535
|
+
withinKilometers(key, point, maxDistance, sorted) {
|
|
1582
1536
|
return this.withinRadians(key, point, maxDistance / 6371.0, sorted);
|
|
1583
1537
|
}
|
|
1584
1538
|
|
|
@@ -1594,7 +1548,7 @@ class ParseQuery {
|
|
|
1594
1548
|
* The upper-right inclusive corner of the box.
|
|
1595
1549
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1596
1550
|
*/
|
|
1597
|
-
withinGeoBox(key
|
|
1551
|
+
withinGeoBox(key, southwest, northeast) {
|
|
1598
1552
|
if (!(southwest instanceof _ParseGeoPoint.default)) {
|
|
1599
1553
|
southwest = new _ParseGeoPoint.default(southwest);
|
|
1600
1554
|
}
|
|
@@ -1618,7 +1572,7 @@ class ParseQuery {
|
|
|
1618
1572
|
* @param {Array} points Array of Coordinates / GeoPoints
|
|
1619
1573
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1620
1574
|
*/
|
|
1621
|
-
withinPolygon(key
|
|
1575
|
+
withinPolygon(key, points) {
|
|
1622
1576
|
return this._addCondition(key, '$geoWithin', {
|
|
1623
1577
|
$polygon: points
|
|
1624
1578
|
});
|
|
@@ -1632,7 +1586,7 @@ class ParseQuery {
|
|
|
1632
1586
|
* @param {Parse.GeoPoint} point
|
|
1633
1587
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1634
1588
|
*/
|
|
1635
|
-
polygonContains(key
|
|
1589
|
+
polygonContains(key, point) {
|
|
1636
1590
|
return this._addCondition(key, '$geoIntersects', {
|
|
1637
1591
|
$point: point
|
|
1638
1592
|
});
|
|
@@ -1647,7 +1601,7 @@ class ParseQuery {
|
|
|
1647
1601
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1648
1602
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1649
1603
|
*/
|
|
1650
|
-
ascending(...keys
|
|
1604
|
+
ascending(...keys) {
|
|
1651
1605
|
this._order = [];
|
|
1652
1606
|
return this.addAscending.apply(this, keys);
|
|
1653
1607
|
}
|
|
@@ -1660,7 +1614,7 @@ class ParseQuery {
|
|
|
1660
1614
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1661
1615
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1662
1616
|
*/
|
|
1663
|
-
addAscending(...keys
|
|
1617
|
+
addAscending(...keys) {
|
|
1664
1618
|
if (!this._order) {
|
|
1665
1619
|
this._order = [];
|
|
1666
1620
|
}
|
|
@@ -1680,7 +1634,7 @@ class ParseQuery {
|
|
|
1680
1634
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1681
1635
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1682
1636
|
*/
|
|
1683
|
-
descending(...keys
|
|
1637
|
+
descending(...keys) {
|
|
1684
1638
|
this._order = [];
|
|
1685
1639
|
return this.addDescending.apply(this, keys);
|
|
1686
1640
|
}
|
|
@@ -1693,7 +1647,7 @@ class ParseQuery {
|
|
|
1693
1647
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1694
1648
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1695
1649
|
*/
|
|
1696
|
-
addDescending(...keys
|
|
1650
|
+
addDescending(...keys) {
|
|
1697
1651
|
if (!this._order) {
|
|
1698
1652
|
this._order = [];
|
|
1699
1653
|
}
|
|
@@ -1718,7 +1672,7 @@ class ParseQuery {
|
|
|
1718
1672
|
* @param {number} n the number of results to skip.
|
|
1719
1673
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1720
1674
|
*/
|
|
1721
|
-
skip(n
|
|
1675
|
+
skip(n) {
|
|
1722
1676
|
if (typeof n !== 'number' || n < 0) {
|
|
1723
1677
|
throw new Error('You can only skip by a positive number');
|
|
1724
1678
|
}
|
|
@@ -1732,7 +1686,7 @@ class ParseQuery {
|
|
|
1732
1686
|
* @param {number} n the number of results to limit to.
|
|
1733
1687
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1734
1688
|
*/
|
|
1735
|
-
limit(n
|
|
1689
|
+
limit(n) {
|
|
1736
1690
|
if (typeof n !== 'number') {
|
|
1737
1691
|
throw new Error('You can only set the limit to a numeric value');
|
|
1738
1692
|
}
|
|
@@ -1749,7 +1703,7 @@ class ParseQuery {
|
|
|
1749
1703
|
* @param {boolean} includeCount false - disable, true - enable.
|
|
1750
1704
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1751
1705
|
*/
|
|
1752
|
-
withCount(includeCount
|
|
1706
|
+
withCount(includeCount = true) {
|
|
1753
1707
|
if (typeof includeCount !== 'boolean') {
|
|
1754
1708
|
throw new Error('You can only set withCount to a boolean value');
|
|
1755
1709
|
}
|
|
@@ -1767,7 +1721,7 @@ class ParseQuery {
|
|
|
1767
1721
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1768
1722
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1769
1723
|
*/
|
|
1770
|
-
include(...keys
|
|
1724
|
+
include(...keys) {
|
|
1771
1725
|
keys.forEach(key => {
|
|
1772
1726
|
if (Array.isArray(key)) {
|
|
1773
1727
|
this._include = this._include.concat(key);
|
|
@@ -1785,7 +1739,7 @@ class ParseQuery {
|
|
|
1785
1739
|
*
|
|
1786
1740
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1787
1741
|
*/
|
|
1788
|
-
includeAll()
|
|
1742
|
+
includeAll() {
|
|
1789
1743
|
return this.include('*');
|
|
1790
1744
|
}
|
|
1791
1745
|
|
|
@@ -1797,7 +1751,7 @@ class ParseQuery {
|
|
|
1797
1751
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1798
1752
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1799
1753
|
*/
|
|
1800
|
-
select(...keys
|
|
1754
|
+
select(...keys) {
|
|
1801
1755
|
if (!this._select) {
|
|
1802
1756
|
this._select = [];
|
|
1803
1757
|
}
|
|
@@ -1820,7 +1774,7 @@ class ParseQuery {
|
|
|
1820
1774
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
|
|
1821
1775
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1822
1776
|
*/
|
|
1823
|
-
exclude(...keys
|
|
1777
|
+
exclude(...keys) {
|
|
1824
1778
|
keys.forEach(key => {
|
|
1825
1779
|
if (Array.isArray(key)) {
|
|
1826
1780
|
this._exclude = this._exclude.concat(key);
|
|
@@ -1839,7 +1793,7 @@ class ParseQuery {
|
|
|
1839
1793
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
|
|
1840
1794
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1841
1795
|
*/
|
|
1842
|
-
watch(...keys
|
|
1796
|
+
watch(...keys) {
|
|
1843
1797
|
keys.forEach(key => {
|
|
1844
1798
|
if (Array.isArray(key)) {
|
|
1845
1799
|
this._watch = this._watch.concat(key);
|
|
@@ -1858,10 +1812,10 @@ class ParseQuery {
|
|
|
1858
1812
|
* @param {string} subqueryReadPreference The read preference for the sub queries.
|
|
1859
1813
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1860
1814
|
*/
|
|
1861
|
-
readPreference(readPreference
|
|
1815
|
+
readPreference(readPreference, includeReadPreference, subqueryReadPreference) {
|
|
1862
1816
|
this._readPreference = readPreference;
|
|
1863
|
-
this._includeReadPreference = includeReadPreference;
|
|
1864
|
-
this._subqueryReadPreference = subqueryReadPreference;
|
|
1817
|
+
this._includeReadPreference = includeReadPreference || null;
|
|
1818
|
+
this._subqueryReadPreference = subqueryReadPreference || null;
|
|
1865
1819
|
return this;
|
|
1866
1820
|
}
|
|
1867
1821
|
|
|
@@ -1872,10 +1826,10 @@ class ParseQuery {
|
|
|
1872
1826
|
* @returns {Promise<LiveQuerySubscription>} Returns the liveQuerySubscription, it's an event emitter
|
|
1873
1827
|
* which can be used to get liveQuery updates.
|
|
1874
1828
|
*/
|
|
1875
|
-
async subscribe(sessionToken
|
|
1829
|
+
async subscribe(sessionToken) {
|
|
1876
1830
|
const currentUser = await _CoreManager.default.getUserController().currentUserAsync();
|
|
1877
1831
|
if (!sessionToken) {
|
|
1878
|
-
sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
|
|
1832
|
+
sessionToken = currentUser ? currentUser.getSessionToken() || undefined : undefined;
|
|
1879
1833
|
}
|
|
1880
1834
|
const liveQueryClient = await _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
1881
1835
|
if (liveQueryClient.shouldOpen()) {
|
|
@@ -1899,7 +1853,7 @@ class ParseQuery {
|
|
|
1899
1853
|
* @static
|
|
1900
1854
|
* @returns {Parse.Query} The query that is the OR of the passed in queries.
|
|
1901
1855
|
*/
|
|
1902
|
-
static or(...queries
|
|
1856
|
+
static or(...queries) {
|
|
1903
1857
|
const className = _getClassNameFromQueries(queries);
|
|
1904
1858
|
const query = new ParseQuery(className);
|
|
1905
1859
|
query._orQuery(queries);
|
|
@@ -1918,7 +1872,7 @@ class ParseQuery {
|
|
|
1918
1872
|
* @static
|
|
1919
1873
|
* @returns {Parse.Query} The query that is the AND of the passed in queries.
|
|
1920
1874
|
*/
|
|
1921
|
-
static and(...queries
|
|
1875
|
+
static and(...queries) {
|
|
1922
1876
|
const className = _getClassNameFromQueries(queries);
|
|
1923
1877
|
const query = new ParseQuery(className);
|
|
1924
1878
|
query._andQuery(queries);
|
|
@@ -1937,7 +1891,7 @@ class ParseQuery {
|
|
|
1937
1891
|
* @static
|
|
1938
1892
|
* @returns {Parse.Query} The query that is the NOR of the passed in queries.
|
|
1939
1893
|
*/
|
|
1940
|
-
static nor(...queries
|
|
1894
|
+
static nor(...queries) {
|
|
1941
1895
|
const className = _getClassNameFromQueries(queries);
|
|
1942
1896
|
const query = new ParseQuery(className);
|
|
1943
1897
|
query._norQuery(queries);
|
|
@@ -1949,7 +1903,7 @@ class ParseQuery {
|
|
|
1949
1903
|
*
|
|
1950
1904
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1951
1905
|
*/
|
|
1952
|
-
fromNetwork()
|
|
1906
|
+
fromNetwork() {
|
|
1953
1907
|
this._queriesLocalDatastore = false;
|
|
1954
1908
|
this._localDatastorePinName = null;
|
|
1955
1909
|
return this;
|
|
@@ -1960,7 +1914,7 @@ class ParseQuery {
|
|
|
1960
1914
|
*
|
|
1961
1915
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1962
1916
|
*/
|
|
1963
|
-
fromLocalDatastore()
|
|
1917
|
+
fromLocalDatastore() {
|
|
1964
1918
|
return this.fromPinWithName(null);
|
|
1965
1919
|
}
|
|
1966
1920
|
|
|
@@ -1969,7 +1923,7 @@ class ParseQuery {
|
|
|
1969
1923
|
*
|
|
1970
1924
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1971
1925
|
*/
|
|
1972
|
-
fromPin()
|
|
1926
|
+
fromPin() {
|
|
1973
1927
|
return this.fromPinWithName(_LocalDatastoreUtils.DEFAULT_PIN);
|
|
1974
1928
|
}
|
|
1975
1929
|
|
|
@@ -1979,7 +1933,7 @@ class ParseQuery {
|
|
|
1979
1933
|
* @param {string} name The name of query source.
|
|
1980
1934
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1981
1935
|
*/
|
|
1982
|
-
fromPinWithName(name
|
|
1936
|
+
fromPinWithName(name) {
|
|
1983
1937
|
const localDatastore = _CoreManager.default.getLocalDatastore();
|
|
1984
1938
|
if (localDatastore.checkIfEnabled()) {
|
|
1985
1939
|
this._queriesLocalDatastore = true;
|
|
@@ -1993,7 +1947,7 @@ class ParseQuery {
|
|
|
1993
1947
|
*
|
|
1994
1948
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1995
1949
|
*/
|
|
1996
|
-
cancel()
|
|
1950
|
+
cancel() {
|
|
1997
1951
|
if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
|
|
1998
1952
|
this._xhrRequest.task._aborted = true;
|
|
1999
1953
|
this._xhrRequest.task.abort();
|
|
@@ -2001,7 +1955,8 @@ class ParseQuery {
|
|
|
2001
1955
|
this._xhrRequest.onchange = () => {};
|
|
2002
1956
|
return this;
|
|
2003
1957
|
}
|
|
2004
|
-
|
|
1958
|
+
this._xhrRequest.onchange = () => this.cancel();
|
|
1959
|
+
return this;
|
|
2005
1960
|
}
|
|
2006
1961
|
_setRequestTask(options) {
|
|
2007
1962
|
options.requestTask = task => {
|
|
@@ -2012,12 +1967,12 @@ class ParseQuery {
|
|
|
2012
1967
|
|
|
2013
1968
|
/**
|
|
2014
1969
|
* Sets a comment to the query so that the query
|
|
2015
|
-
*can be identified when using a the profiler for MongoDB.
|
|
1970
|
+
* can be identified when using a the profiler for MongoDB.
|
|
2016
1971
|
*
|
|
2017
1972
|
* @param {string} value a comment can make your profile data easier to interpret and trace.
|
|
2018
1973
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
2019
1974
|
*/
|
|
2020
|
-
comment(value
|
|
1975
|
+
comment(value) {
|
|
2021
1976
|
if (value == null) {
|
|
2022
1977
|
delete this._comment;
|
|
2023
1978
|
return this;
|
|
@@ -2030,16 +1985,15 @@ class ParseQuery {
|
|
|
2030
1985
|
}
|
|
2031
1986
|
}
|
|
2032
1987
|
const DefaultController = {
|
|
2033
|
-
find(className
|
|
1988
|
+
find(className, params, options) {
|
|
2034
1989
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2035
1990
|
return RESTController.request('GET', 'classes/' + className, params, options);
|
|
2036
1991
|
},
|
|
2037
|
-
aggregate(className
|
|
1992
|
+
aggregate(className, params, options) {
|
|
2038
1993
|
const RESTController = _CoreManager.default.getRESTController();
|
|
2039
1994
|
return RESTController.request('GET', 'aggregate/' + className, params, options);
|
|
2040
1995
|
}
|
|
2041
1996
|
};
|
|
2042
1997
|
_CoreManager.default.setParseQuery(ParseQuery);
|
|
2043
1998
|
_CoreManager.default.setQueryController(DefaultController);
|
|
2044
|
-
var _default = ParseQuery;
|
|
2045
|
-
exports.default = _default;
|
|
1999
|
+
var _default = exports.default = ParseQuery;
|