parse 4.0.1 → 4.1.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 +17995 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8739 -17728
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +2 -20
- package/lib/browser/AnonymousUtils.js +6 -35
- package/lib/browser/Cloud.js +12 -70
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -184
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -1
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -35
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -13
- package/lib/browser/LiveQueryClient.js +87 -204
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -12
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +42 -222
- package/lib/browser/Parse.js +12 -106
- package/lib/browser/ParseACL.js +33 -141
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -88
- package/lib/browser/ParseError.js +63 -90
- package/lib/browser/ParseFile.js +129 -685
- package/lib/browser/ParseGeoPoint.js +23 -82
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +628 -1840
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -63
- package/lib/browser/ParseQuery.js +404 -1505
- package/lib/browser/ParseRelation.js +12 -61
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -201
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -43
- package/lib/browser/RESTController.js +18 -140
- package/lib/browser/SingleInstanceStateController.js +19 -137
- package/lib/browser/Socket.weapp.js +2 -12
- package/lib/browser/Storage.js +10 -73
- package/lib/browser/StorageController.browser.js +4 -17
- package/lib/browser/StorageController.default.js +4 -17
- package/lib/browser/StorageController.react-native.js +6 -33
- package/lib/browser/StorageController.weapp.js +5 -16
- package/lib/browser/TaskQueue.js +1 -22
- package/lib/browser/UniqueInstanceStateController.js +19 -142
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -16
- package/lib/browser/canBeSerialized.js +3 -33
- package/lib/browser/decode.js +3 -33
- package/lib/browser/encode.js +9 -70
- package/lib/browser/equals.js +2 -25
- package/lib/browser/escape.js +1 -8
- package/lib/browser/isRevocableSession.js +2 -11
- package/lib/browser/parseDate.js +2 -13
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -17
- package/lib/browser/unsavedChildren.js +6 -50
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -18
- package/lib/node/AnonymousUtils.js +5 -37
- package/lib/node/Cloud.js +10 -66
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -220
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -1
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -37
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -15
- package/lib/node/LiveQueryClient.js +56 -136
- package/lib/node/LiveQuerySubscription.js +7 -16
- package/lib/node/LocalDatastore.js +19 -175
- package/lib/node/LocalDatastoreController.js +6 -38
- package/lib/node/LocalDatastoreController.react-native.js +6 -45
- package/lib/node/LocalDatastoreUtils.js +1 -6
- package/lib/node/ObjectStateMutations.js +13 -93
- package/lib/node/OfflineQuery.js +20 -152
- package/lib/node/Parse.js +11 -99
- package/lib/node/ParseACL.js +32 -150
- package/lib/node/ParseCLP.js +69 -262
- package/lib/node/ParseConfig.js +16 -84
- package/lib/node/ParseError.js +61 -65
- package/lib/node/ParseFile.js +50 -205
- package/lib/node/ParseGeoPoint.js +21 -82
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -10
- package/lib/node/ParseLiveQuery.js +10 -36
- package/lib/node/ParseObject.js +193 -939
- package/lib/node/ParseOp.js +31 -255
- package/lib/node/ParsePolygon.js +12 -62
- package/lib/node/ParseQuery.js +170 -882
- package/lib/node/ParseRelation.js +11 -61
- package/lib/node/ParseRole.js +10 -57
- package/lib/node/ParseSchema.js +46 -222
- package/lib/node/ParseSession.js +8 -50
- package/lib/node/ParseUser.js +107 -576
- package/lib/node/Push.js +4 -37
- package/lib/node/RESTController.js +8 -110
- package/lib/node/SingleInstanceStateController.js +17 -130
- package/lib/node/Socket.weapp.js +2 -9
- package/lib/node/Storage.js +10 -83
- package/lib/node/StorageController.browser.js +4 -23
- package/lib/node/StorageController.default.js +5 -21
- package/lib/node/StorageController.react-native.js +6 -40
- package/lib/node/StorageController.weapp.js +6 -21
- package/lib/node/TaskQueue.js +1 -17
- package/lib/node/UniqueInstanceStateController.js +16 -133
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -12
- package/lib/node/canBeSerialized.js +2 -28
- package/lib/node/decode.js +1 -26
- package/lib/node/encode.js +3 -54
- package/lib/node/equals.js +0 -18
- package/lib/node/escape.js +1 -6
- package/lib/node/isRevocableSession.js +1 -5
- package/lib/node/parseDate.js +1 -7
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -11
- package/lib/node/unsavedChildren.js +2 -38
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +1 -5
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +4 -52
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +24 -101
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +6 -113
- package/lib/react-native/LocalDatastoreController.js +0 -21
- package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +0 -34
- package/lib/react-native/OfflineQuery.js +2 -137
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +32 -96
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +4 -72
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +3 -25
- package/lib/react-native/ParseObject.js +4 -371
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +6 -262
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +0 -51
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +1 -224
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +1 -70
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +2 -12
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -20
- package/lib/weapp/AnonymousUtils.js +6 -35
- package/lib/weapp/Cloud.js +12 -70
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -184
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -1
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -35
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -13
- package/lib/weapp/LiveQueryClient.js +87 -204
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -12
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +42 -222
- package/lib/weapp/Parse.js +12 -106
- package/lib/weapp/ParseACL.js +33 -141
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -88
- package/lib/weapp/ParseError.js +63 -90
- package/lib/weapp/ParseFile.js +130 -686
- package/lib/weapp/ParseGeoPoint.js +23 -82
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +628 -1840
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -63
- package/lib/weapp/ParseQuery.js +404 -1505
- package/lib/weapp/ParseRelation.js +12 -61
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -201
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -43
- package/lib/weapp/RESTController.js +18 -140
- package/lib/weapp/SingleInstanceStateController.js +19 -137
- package/lib/weapp/Socket.weapp.js +2 -12
- package/lib/weapp/Storage.js +10 -73
- package/lib/weapp/StorageController.browser.js +4 -17
- package/lib/weapp/StorageController.default.js +4 -17
- package/lib/weapp/StorageController.react-native.js +6 -33
- package/lib/weapp/StorageController.weapp.js +5 -16
- package/lib/weapp/TaskQueue.js +1 -22
- package/lib/weapp/UniqueInstanceStateController.js +19 -142
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -16
- package/lib/weapp/canBeSerialized.js +3 -33
- package/lib/weapp/decode.js +3 -33
- package/lib/weapp/encode.js +9 -70
- package/lib/weapp/equals.js +2 -25
- package/lib/weapp/escape.js +1 -8
- package/lib/weapp/isRevocableSession.js +2 -11
- package/lib/weapp/parseDate.js +2 -13
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -17
- package/lib/weapp/unsavedChildren.js +6 -50
- package/lib/weapp/uuid.js +1 -6
- package/package.json +45 -43
|
@@ -1,59 +1,40 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = void 0;
|
|
7
|
-
|
|
8
6
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
|
|
10
7
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
19
|
-
|
|
20
12
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
21
|
-
|
|
22
13
|
var _promiseUtils = require("./promiseUtils");
|
|
23
|
-
|
|
24
14
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
25
|
-
|
|
26
15
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
27
|
-
|
|
28
16
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
29
|
-
|
|
30
17
|
var _OfflineQuery = _interopRequireDefault(require("./OfflineQuery"));
|
|
31
|
-
|
|
32
18
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
33
|
-
|
|
34
19
|
function quote(s) {
|
|
35
20
|
return '\\Q' + s.replace('\\E', '\\E\\\\E\\Q') + '\\E';
|
|
36
21
|
}
|
|
37
|
-
|
|
38
22
|
function _getClassNameFromQueries(queries) {
|
|
39
23
|
var className = null;
|
|
40
24
|
queries.forEach(function (q) {
|
|
41
25
|
if (!className) {
|
|
42
26
|
className = q.className;
|
|
43
27
|
}
|
|
44
|
-
|
|
45
28
|
if (className !== q.className) {
|
|
46
29
|
throw new Error('All queries must be for the same class.');
|
|
47
30
|
}
|
|
48
31
|
});
|
|
49
32
|
return className;
|
|
50
33
|
}
|
|
51
|
-
|
|
52
34
|
function handleSelectResult(data, select) {
|
|
53
35
|
var serverDataMask = {};
|
|
54
36
|
select.forEach(function (field) {
|
|
55
37
|
var hasSubObjectSelect = field.indexOf('.') !== -1;
|
|
56
|
-
|
|
57
38
|
if (!hasSubObjectSelect && !data.hasOwnProperty(field)) {
|
|
58
39
|
data[field] = undefined;
|
|
59
40
|
} else if (hasSubObjectSelect) {
|
|
@@ -64,32 +45,26 @@ function handleSelectResult(data, select) {
|
|
|
64
45
|
if (_obj && !_obj.hasOwnProperty(component)) {
|
|
65
46
|
_obj[component] = undefined;
|
|
66
47
|
}
|
|
67
|
-
|
|
68
48
|
if (_obj && typeof _obj === 'object') {
|
|
69
49
|
_obj = _obj[component];
|
|
70
50
|
}
|
|
71
|
-
|
|
72
51
|
if (index < arr.length - 1) {
|
|
73
52
|
if (!serverMask[component]) {
|
|
74
53
|
serverMask[component] = {};
|
|
75
54
|
}
|
|
76
|
-
|
|
77
55
|
serverMask = serverMask[component];
|
|
78
56
|
}
|
|
79
57
|
});
|
|
80
58
|
}
|
|
81
59
|
});
|
|
82
|
-
|
|
83
60
|
if (Object.keys(serverDataMask).length > 0) {
|
|
84
61
|
var serverData = _CoreManager.default.getObjectStateController().getServerData({
|
|
85
62
|
id: data.objectId,
|
|
86
63
|
className: data.className
|
|
87
64
|
});
|
|
88
|
-
|
|
89
65
|
copyMissingDataWithMask(serverData, data, serverDataMask, false);
|
|
90
66
|
}
|
|
91
67
|
}
|
|
92
|
-
|
|
93
68
|
function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
|
|
94
69
|
if (copyThisLevel) {
|
|
95
70
|
for (var _key in src) {
|
|
@@ -98,58 +73,45 @@ function copyMissingDataWithMask(src, dest, mask, copyThisLevel) {
|
|
|
98
73
|
}
|
|
99
74
|
}
|
|
100
75
|
}
|
|
101
|
-
|
|
102
76
|
for (var _key2 in mask) {
|
|
103
77
|
if (dest[_key2] !== undefined && dest[_key2] !== null && src !== undefined && src !== null) {
|
|
104
78
|
copyMissingDataWithMask(src[_key2], dest[_key2], mask[_key2], true);
|
|
105
79
|
}
|
|
106
80
|
}
|
|
107
81
|
}
|
|
108
|
-
|
|
109
82
|
function handleOfflineSort(a, b, sorts) {
|
|
110
83
|
var order = sorts[0];
|
|
111
84
|
var operator = order.slice(0, 1);
|
|
112
85
|
var isDescending = operator === '-';
|
|
113
|
-
|
|
114
86
|
if (isDescending) {
|
|
115
87
|
order = order.substring(1);
|
|
116
88
|
}
|
|
117
|
-
|
|
118
89
|
if (order === '_created_at') {
|
|
119
90
|
order = 'createdAt';
|
|
120
91
|
}
|
|
121
|
-
|
|
122
92
|
if (order === '_updated_at') {
|
|
123
93
|
order = 'updatedAt';
|
|
124
94
|
}
|
|
125
|
-
|
|
126
95
|
if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
|
|
127
96
|
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${order}`);
|
|
128
97
|
}
|
|
129
|
-
|
|
130
98
|
var field1 = a.get(order);
|
|
131
99
|
var field2 = b.get(order);
|
|
132
|
-
|
|
133
100
|
if (field1 < field2) {
|
|
134
101
|
return isDescending ? 1 : -1;
|
|
135
102
|
}
|
|
136
|
-
|
|
137
103
|
if (field1 > field2) {
|
|
138
104
|
return isDescending ? -1 : 1;
|
|
139
105
|
}
|
|
140
|
-
|
|
141
106
|
if (sorts.length > 1) {
|
|
142
107
|
var remainingSorts = sorts.slice(1);
|
|
143
108
|
return handleOfflineSort(a, b, remainingSorts);
|
|
144
109
|
}
|
|
145
|
-
|
|
146
110
|
return 0;
|
|
147
111
|
}
|
|
148
|
-
|
|
149
112
|
var ParseQuery = function () {
|
|
150
113
|
function ParseQuery(objectClass) {
|
|
151
114
|
(0, _classCallCheck2.default)(this, ParseQuery);
|
|
152
|
-
|
|
153
115
|
if (typeof objectClass === 'string') {
|
|
154
116
|
if (objectClass === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
|
|
155
117
|
this.className = '_User';
|
|
@@ -163,13 +125,11 @@ var ParseQuery = function () {
|
|
|
163
125
|
this.className = objectClass.className;
|
|
164
126
|
} else {
|
|
165
127
|
var _obj2 = new objectClass();
|
|
166
|
-
|
|
167
128
|
this.className = _obj2.className;
|
|
168
129
|
}
|
|
169
130
|
} else {
|
|
170
131
|
throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
|
|
171
132
|
}
|
|
172
|
-
|
|
173
133
|
this._where = {};
|
|
174
134
|
this._include = [];
|
|
175
135
|
this._exclude = [];
|
|
@@ -187,7 +147,6 @@ var ParseQuery = function () {
|
|
|
187
147
|
onchange: function () {}
|
|
188
148
|
};
|
|
189
149
|
}
|
|
190
|
-
|
|
191
150
|
(0, _createClass2.default)(ParseQuery, [{
|
|
192
151
|
key: "_orQuery",
|
|
193
152
|
value: function (queries) {
|
|
@@ -221,7 +180,6 @@ var ParseQuery = function () {
|
|
|
221
180
|
if (!this._where[key] || typeof this._where[key] === 'string') {
|
|
222
181
|
this._where[key] = {};
|
|
223
182
|
}
|
|
224
|
-
|
|
225
183
|
this._where[key][condition] = (0, _encode.default)(value, false, true);
|
|
226
184
|
return this;
|
|
227
185
|
}
|
|
@@ -235,34 +193,26 @@ var ParseQuery = function () {
|
|
|
235
193
|
value: function () {
|
|
236
194
|
var _handleOfflineQuery2 = (0, _asyncToGenerator2.default)(function* (params) {
|
|
237
195
|
var _this2 = this;
|
|
238
|
-
|
|
239
196
|
_OfflineQuery.default.validateQuery(this);
|
|
240
|
-
|
|
241
197
|
var localDatastore = _CoreManager.default.getLocalDatastore();
|
|
242
|
-
|
|
243
198
|
var objects = yield localDatastore._serializeObjectsFromPinName(this._localDatastorePinName);
|
|
244
199
|
var results = objects.map(function (json, index, arr) {
|
|
245
200
|
var object = _ParseObject.default.fromJSON(json, false);
|
|
246
|
-
|
|
247
201
|
if (json._localId && !json.objectId) {
|
|
248
202
|
object._localId = json._localId;
|
|
249
203
|
}
|
|
250
|
-
|
|
251
204
|
if (!_OfflineQuery.default.matchesQuery(_this2.className, object, arr, _this2)) {
|
|
252
205
|
return null;
|
|
253
206
|
}
|
|
254
|
-
|
|
255
207
|
return object;
|
|
256
208
|
}).filter(function (object) {
|
|
257
209
|
return object !== null;
|
|
258
210
|
});
|
|
259
|
-
|
|
260
211
|
if (params.keys) {
|
|
261
212
|
var keys = params.keys.split(',');
|
|
262
213
|
keys = keys.concat(['className', 'objectId', 'createdAt', 'updatedAt', 'ACL']);
|
|
263
214
|
results = results.map(function (object) {
|
|
264
215
|
var json = object._toFullJSON();
|
|
265
|
-
|
|
266
216
|
Object.keys(json).forEach(function (key) {
|
|
267
217
|
if (!keys.includes(key)) {
|
|
268
218
|
delete json[key];
|
|
@@ -271,20 +221,16 @@ var ParseQuery = function () {
|
|
|
271
221
|
return _ParseObject.default.fromJSON(json, false);
|
|
272
222
|
});
|
|
273
223
|
}
|
|
274
|
-
|
|
275
224
|
if (params.order) {
|
|
276
225
|
var sorts = params.order.split(',');
|
|
277
226
|
results.sort(function (a, b) {
|
|
278
227
|
return handleOfflineSort(a, b, sorts);
|
|
279
228
|
});
|
|
280
229
|
}
|
|
281
|
-
|
|
282
230
|
var count;
|
|
283
|
-
|
|
284
231
|
if (params.count) {
|
|
285
232
|
count = results.length;
|
|
286
233
|
}
|
|
287
|
-
|
|
288
234
|
if (params.skip) {
|
|
289
235
|
if (params.skip >= results.length) {
|
|
290
236
|
results = [];
|
|
@@ -292,29 +238,22 @@ var ParseQuery = function () {
|
|
|
292
238
|
results = results.splice(params.skip, results.length);
|
|
293
239
|
}
|
|
294
240
|
}
|
|
295
|
-
|
|
296
241
|
var limit = results.length;
|
|
297
|
-
|
|
298
242
|
if (params.limit !== 0 && params.limit < results.length) {
|
|
299
243
|
limit = params.limit;
|
|
300
244
|
}
|
|
301
|
-
|
|
302
245
|
results = results.splice(0, limit);
|
|
303
|
-
|
|
304
246
|
if (typeof count === 'number') {
|
|
305
247
|
return {
|
|
306
248
|
results: results,
|
|
307
249
|
count: count
|
|
308
250
|
};
|
|
309
251
|
}
|
|
310
|
-
|
|
311
252
|
return results;
|
|
312
253
|
});
|
|
313
|
-
|
|
314
254
|
function _handleOfflineQuery() {
|
|
315
255
|
return _handleOfflineQuery2.apply(this, arguments);
|
|
316
256
|
}
|
|
317
|
-
|
|
318
257
|
return _handleOfflineQuery;
|
|
319
258
|
}()
|
|
320
259
|
}, {
|
|
@@ -323,59 +262,45 @@ var ParseQuery = function () {
|
|
|
323
262
|
var params = {
|
|
324
263
|
where: this._where
|
|
325
264
|
};
|
|
326
|
-
|
|
327
265
|
if (this._include.length) {
|
|
328
266
|
params.include = this._include.join(',');
|
|
329
267
|
}
|
|
330
|
-
|
|
331
268
|
if (this._exclude.length) {
|
|
332
269
|
params.excludeKeys = this._exclude.join(',');
|
|
333
270
|
}
|
|
334
|
-
|
|
335
271
|
if (this._select) {
|
|
336
272
|
params.keys = this._select.join(',');
|
|
337
273
|
}
|
|
338
|
-
|
|
339
274
|
if (this._count) {
|
|
340
275
|
params.count = 1;
|
|
341
276
|
}
|
|
342
|
-
|
|
343
277
|
if (this._limit >= 0) {
|
|
344
278
|
params.limit = this._limit;
|
|
345
279
|
}
|
|
346
|
-
|
|
347
280
|
if (this._skip > 0) {
|
|
348
281
|
params.skip = this._skip;
|
|
349
282
|
}
|
|
350
|
-
|
|
351
283
|
if (this._order) {
|
|
352
284
|
params.order = this._order.join(',');
|
|
353
285
|
}
|
|
354
|
-
|
|
355
286
|
if (this._readPreference) {
|
|
356
287
|
params.readPreference = this._readPreference;
|
|
357
288
|
}
|
|
358
|
-
|
|
359
289
|
if (this._includeReadPreference) {
|
|
360
290
|
params.includeReadPreference = this._includeReadPreference;
|
|
361
291
|
}
|
|
362
|
-
|
|
363
292
|
if (this._subqueryReadPreference) {
|
|
364
293
|
params.subqueryReadPreference = this._subqueryReadPreference;
|
|
365
294
|
}
|
|
366
|
-
|
|
367
295
|
if (this._hint) {
|
|
368
296
|
params.hint = this._hint;
|
|
369
297
|
}
|
|
370
|
-
|
|
371
298
|
if (this._explain) {
|
|
372
299
|
params.explain = true;
|
|
373
300
|
}
|
|
374
|
-
|
|
375
301
|
for (var _key3 in this._extraOptions) {
|
|
376
302
|
params[_key3] = this._extraOptions[_key3];
|
|
377
303
|
}
|
|
378
|
-
|
|
379
304
|
return params;
|
|
380
305
|
}
|
|
381
306
|
}, {
|
|
@@ -384,55 +309,42 @@ var ParseQuery = function () {
|
|
|
384
309
|
if (json.where) {
|
|
385
310
|
this._where = json.where;
|
|
386
311
|
}
|
|
387
|
-
|
|
388
312
|
if (json.include) {
|
|
389
313
|
this._include = json.include.split(',');
|
|
390
314
|
}
|
|
391
|
-
|
|
392
315
|
if (json.keys) {
|
|
393
316
|
this._select = json.keys.split(',');
|
|
394
317
|
}
|
|
395
|
-
|
|
396
318
|
if (json.excludeKeys) {
|
|
397
319
|
this._exclude = json.excludeKeys.split(',');
|
|
398
320
|
}
|
|
399
|
-
|
|
400
321
|
if (json.count) {
|
|
401
322
|
this._count = json.count === 1;
|
|
402
323
|
}
|
|
403
|
-
|
|
404
324
|
if (json.limit) {
|
|
405
325
|
this._limit = json.limit;
|
|
406
326
|
}
|
|
407
|
-
|
|
408
327
|
if (json.skip) {
|
|
409
328
|
this._skip = json.skip;
|
|
410
329
|
}
|
|
411
|
-
|
|
412
330
|
if (json.order) {
|
|
413
331
|
this._order = json.order.split(',');
|
|
414
332
|
}
|
|
415
|
-
|
|
416
333
|
if (json.readPreference) {
|
|
417
334
|
this._readPreference = json.readPreference;
|
|
418
335
|
}
|
|
419
|
-
|
|
420
336
|
if (json.includeReadPreference) {
|
|
421
337
|
this._includeReadPreference = json.includeReadPreference;
|
|
422
338
|
}
|
|
423
|
-
|
|
424
339
|
if (json.subqueryReadPreference) {
|
|
425
340
|
this._subqueryReadPreference = json.subqueryReadPreference;
|
|
426
341
|
}
|
|
427
|
-
|
|
428
342
|
if (json.hint) {
|
|
429
343
|
this._hint = json.hint;
|
|
430
344
|
}
|
|
431
|
-
|
|
432
345
|
if (json.explain) {
|
|
433
346
|
this._explain = !!json.explain;
|
|
434
347
|
}
|
|
435
|
-
|
|
436
348
|
for (var _key4 in json) {
|
|
437
349
|
if (json.hasOwnProperty(_key4)) {
|
|
438
350
|
if (['where', 'include', 'keys', 'count', 'limit', 'skip', 'order', 'readPreference', 'includeReadPreference', 'subqueryReadPreference', 'hint', 'explain'].indexOf(_key4) === -1) {
|
|
@@ -440,7 +352,6 @@ var ParseQuery = function () {
|
|
|
440
352
|
}
|
|
441
353
|
}
|
|
442
354
|
}
|
|
443
|
-
|
|
444
355
|
return this;
|
|
445
356
|
}
|
|
446
357
|
}, {
|
|
@@ -448,28 +359,22 @@ var ParseQuery = function () {
|
|
|
448
359
|
value: function (objectId, options) {
|
|
449
360
|
this.equalTo('objectId', objectId);
|
|
450
361
|
var firstOptions = {};
|
|
451
|
-
|
|
452
362
|
if (options && options.hasOwnProperty('useMasterKey')) {
|
|
453
363
|
firstOptions.useMasterKey = options.useMasterKey;
|
|
454
364
|
}
|
|
455
|
-
|
|
456
365
|
if (options && options.hasOwnProperty('sessionToken')) {
|
|
457
366
|
firstOptions.sessionToken = options.sessionToken;
|
|
458
367
|
}
|
|
459
|
-
|
|
460
368
|
if (options && options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
461
369
|
firstOptions.context = options.context;
|
|
462
370
|
}
|
|
463
|
-
|
|
464
371
|
if (options && options.hasOwnProperty('json')) {
|
|
465
372
|
firstOptions.json = options.json;
|
|
466
373
|
}
|
|
467
|
-
|
|
468
374
|
return this.first(firstOptions).then(function (response) {
|
|
469
375
|
if (response) {
|
|
470
376
|
return response;
|
|
471
377
|
}
|
|
472
|
-
|
|
473
378
|
var errorObject = new _ParseError.default(_ParseError.default.OBJECT_NOT_FOUND, 'Object not found.');
|
|
474
379
|
return Promise.reject(errorObject);
|
|
475
380
|
});
|
|
@@ -478,48 +383,35 @@ var ParseQuery = function () {
|
|
|
478
383
|
key: "find",
|
|
479
384
|
value: function (options) {
|
|
480
385
|
var _this3 = this;
|
|
481
|
-
|
|
482
386
|
options = options || {};
|
|
483
387
|
var findOptions = {};
|
|
484
|
-
|
|
485
388
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
486
389
|
findOptions.useMasterKey = options.useMasterKey;
|
|
487
390
|
}
|
|
488
|
-
|
|
489
391
|
if (options.hasOwnProperty('sessionToken')) {
|
|
490
392
|
findOptions.sessionToken = options.sessionToken;
|
|
491
393
|
}
|
|
492
|
-
|
|
493
394
|
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
494
395
|
findOptions.context = options.context;
|
|
495
396
|
}
|
|
496
|
-
|
|
497
397
|
this._setRequestTask(findOptions);
|
|
498
|
-
|
|
499
398
|
var controller = _CoreManager.default.getQueryController();
|
|
500
|
-
|
|
501
399
|
var select = this._select;
|
|
502
|
-
|
|
503
400
|
if (this._queriesLocalDatastore) {
|
|
504
401
|
return this._handleOfflineQuery(this.toJSON());
|
|
505
402
|
}
|
|
506
|
-
|
|
507
403
|
return controller.find(this.className, this.toJSON(), findOptions).then(function (response) {
|
|
508
404
|
if (_this3._explain) {
|
|
509
405
|
return response.results;
|
|
510
406
|
}
|
|
511
|
-
|
|
512
407
|
var results = response.results.map(function (data) {
|
|
513
408
|
var override = response.className || _this3.className;
|
|
514
|
-
|
|
515
409
|
if (!data.className) {
|
|
516
410
|
data.className = override;
|
|
517
411
|
}
|
|
518
|
-
|
|
519
412
|
if (select) {
|
|
520
413
|
handleSelectResult(data, select);
|
|
521
414
|
}
|
|
522
|
-
|
|
523
415
|
if (options.json) {
|
|
524
416
|
return data;
|
|
525
417
|
} else {
|
|
@@ -527,7 +419,6 @@ var ParseQuery = function () {
|
|
|
527
419
|
}
|
|
528
420
|
});
|
|
529
421
|
var count = response.count;
|
|
530
|
-
|
|
531
422
|
if (typeof count === 'number') {
|
|
532
423
|
return {
|
|
533
424
|
results: results,
|
|
@@ -548,11 +439,9 @@ var ParseQuery = function () {
|
|
|
548
439
|
}, options);
|
|
549
440
|
return result;
|
|
550
441
|
});
|
|
551
|
-
|
|
552
442
|
function findAll() {
|
|
553
443
|
return _findAll.apply(this, arguments);
|
|
554
444
|
}
|
|
555
|
-
|
|
556
445
|
return findAll;
|
|
557
446
|
}()
|
|
558
447
|
}, {
|
|
@@ -560,19 +449,14 @@ var ParseQuery = function () {
|
|
|
560
449
|
value: function (options) {
|
|
561
450
|
options = options || {};
|
|
562
451
|
var findOptions = {};
|
|
563
|
-
|
|
564
452
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
565
453
|
findOptions.useMasterKey = options.useMasterKey;
|
|
566
454
|
}
|
|
567
|
-
|
|
568
455
|
if (options.hasOwnProperty('sessionToken')) {
|
|
569
456
|
findOptions.sessionToken = options.sessionToken;
|
|
570
457
|
}
|
|
571
|
-
|
|
572
458
|
this._setRequestTask(findOptions);
|
|
573
|
-
|
|
574
459
|
var controller = _CoreManager.default.getQueryController();
|
|
575
|
-
|
|
576
460
|
var params = this.toJSON();
|
|
577
461
|
params.limit = 0;
|
|
578
462
|
params.count = 1;
|
|
@@ -586,15 +470,11 @@ var ParseQuery = function () {
|
|
|
586
470
|
options = options || {};
|
|
587
471
|
var distinctOptions = {};
|
|
588
472
|
distinctOptions.useMasterKey = true;
|
|
589
|
-
|
|
590
473
|
if (options.hasOwnProperty('sessionToken')) {
|
|
591
474
|
distinctOptions.sessionToken = options.sessionToken;
|
|
592
475
|
}
|
|
593
|
-
|
|
594
476
|
this._setRequestTask(distinctOptions);
|
|
595
|
-
|
|
596
477
|
var controller = _CoreManager.default.getQueryController();
|
|
597
|
-
|
|
598
478
|
var params = {
|
|
599
479
|
distinct: key,
|
|
600
480
|
where: this._where,
|
|
@@ -610,29 +490,22 @@ var ParseQuery = function () {
|
|
|
610
490
|
options = options || {};
|
|
611
491
|
var aggregateOptions = {};
|
|
612
492
|
aggregateOptions.useMasterKey = true;
|
|
613
|
-
|
|
614
493
|
if (options.hasOwnProperty('sessionToken')) {
|
|
615
494
|
aggregateOptions.sessionToken = options.sessionToken;
|
|
616
495
|
}
|
|
617
|
-
|
|
618
496
|
this._setRequestTask(aggregateOptions);
|
|
619
|
-
|
|
620
497
|
var controller = _CoreManager.default.getQueryController();
|
|
621
|
-
|
|
622
498
|
if (!Array.isArray(pipeline) && typeof pipeline !== 'object') {
|
|
623
499
|
throw new Error('Invalid pipeline must be Array or Object');
|
|
624
500
|
}
|
|
625
|
-
|
|
626
501
|
if (Object.keys(this._where || {}).length) {
|
|
627
502
|
if (!Array.isArray(pipeline)) {
|
|
628
503
|
pipeline = [pipeline];
|
|
629
504
|
}
|
|
630
|
-
|
|
631
505
|
pipeline.unshift({
|
|
632
506
|
$match: this._where
|
|
633
507
|
});
|
|
634
508
|
}
|
|
635
|
-
|
|
636
509
|
var params = {
|
|
637
510
|
pipeline: pipeline,
|
|
638
511
|
hint: this._hint,
|
|
@@ -647,55 +520,41 @@ var ParseQuery = function () {
|
|
|
647
520
|
key: "first",
|
|
648
521
|
value: function (options) {
|
|
649
522
|
var _this4 = this;
|
|
650
|
-
|
|
651
523
|
options = options || {};
|
|
652
524
|
var findOptions = {};
|
|
653
|
-
|
|
654
525
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
655
526
|
findOptions.useMasterKey = options.useMasterKey;
|
|
656
527
|
}
|
|
657
|
-
|
|
658
528
|
if (options.hasOwnProperty('sessionToken')) {
|
|
659
529
|
findOptions.sessionToken = options.sessionToken;
|
|
660
530
|
}
|
|
661
|
-
|
|
662
531
|
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
663
532
|
findOptions.context = options.context;
|
|
664
533
|
}
|
|
665
|
-
|
|
666
534
|
this._setRequestTask(findOptions);
|
|
667
|
-
|
|
668
535
|
var controller = _CoreManager.default.getQueryController();
|
|
669
|
-
|
|
670
536
|
var params = this.toJSON();
|
|
671
537
|
params.limit = 1;
|
|
672
538
|
var select = this._select;
|
|
673
|
-
|
|
674
539
|
if (this._queriesLocalDatastore) {
|
|
675
540
|
return this._handleOfflineQuery(params).then(function (objects) {
|
|
676
541
|
if (!objects[0]) {
|
|
677
542
|
return undefined;
|
|
678
543
|
}
|
|
679
|
-
|
|
680
544
|
return objects[0];
|
|
681
545
|
});
|
|
682
546
|
}
|
|
683
|
-
|
|
684
547
|
return controller.find(this.className, params, findOptions).then(function (response) {
|
|
685
548
|
var objects = response.results;
|
|
686
|
-
|
|
687
549
|
if (!objects[0]) {
|
|
688
550
|
return undefined;
|
|
689
551
|
}
|
|
690
|
-
|
|
691
552
|
if (!objects[0].className) {
|
|
692
553
|
objects[0].className = _this4.className;
|
|
693
554
|
}
|
|
694
|
-
|
|
695
555
|
if (select) {
|
|
696
556
|
handleSelectResult(objects[0], select);
|
|
697
557
|
}
|
|
698
|
-
|
|
699
558
|
if (options.json) {
|
|
700
559
|
return objects[0];
|
|
701
560
|
} else {
|
|
@@ -707,29 +566,23 @@ var ParseQuery = function () {
|
|
|
707
566
|
key: "eachBatch",
|
|
708
567
|
value: function (callback, options) {
|
|
709
568
|
options = options || {};
|
|
710
|
-
|
|
711
569
|
if (this._order || this._skip || this._limit >= 0) {
|
|
712
570
|
return Promise.reject('Cannot iterate on a query with sort, skip, or limit.');
|
|
713
571
|
}
|
|
714
|
-
|
|
715
572
|
var query = new ParseQuery(this.className);
|
|
716
573
|
query._limit = options.batchSize || 100;
|
|
717
574
|
query._include = this._include.map(function (i) {
|
|
718
575
|
return i;
|
|
719
576
|
});
|
|
720
|
-
|
|
721
577
|
if (this._select) {
|
|
722
578
|
query._select = this._select.map(function (s) {
|
|
723
579
|
return s;
|
|
724
580
|
});
|
|
725
581
|
}
|
|
726
|
-
|
|
727
582
|
query._hint = this._hint;
|
|
728
583
|
query._where = {};
|
|
729
|
-
|
|
730
584
|
for (var _attr in this._where) {
|
|
731
585
|
var val = this._where[_attr];
|
|
732
|
-
|
|
733
586
|
if (Array.isArray(val)) {
|
|
734
587
|
query._where[_attr] = val.map(function (v) {
|
|
735
588
|
return v;
|
|
@@ -737,7 +590,6 @@ var ParseQuery = function () {
|
|
|
737
590
|
} else if (val && typeof val === 'object') {
|
|
738
591
|
var conditionMap = {};
|
|
739
592
|
query._where[_attr] = conditionMap;
|
|
740
|
-
|
|
741
593
|
for (var cond in val) {
|
|
742
594
|
conditionMap[cond] = val[cond];
|
|
743
595
|
}
|
|
@@ -745,35 +597,28 @@ var ParseQuery = function () {
|
|
|
745
597
|
query._where[_attr] = val;
|
|
746
598
|
}
|
|
747
599
|
}
|
|
748
|
-
|
|
749
600
|
query.ascending('objectId');
|
|
750
601
|
var findOptions = {};
|
|
751
|
-
|
|
752
602
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
753
603
|
findOptions.useMasterKey = options.useMasterKey;
|
|
754
604
|
}
|
|
755
|
-
|
|
756
605
|
if (options.hasOwnProperty('sessionToken')) {
|
|
757
606
|
findOptions.sessionToken = options.sessionToken;
|
|
758
607
|
}
|
|
759
|
-
|
|
760
608
|
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
|
|
761
609
|
findOptions.context = options.context;
|
|
762
610
|
}
|
|
763
|
-
|
|
764
611
|
if (options.hasOwnProperty('json')) {
|
|
765
612
|
findOptions.json = options.json;
|
|
766
613
|
}
|
|
767
|
-
|
|
768
614
|
var finished = false;
|
|
769
615
|
var previousResults = [];
|
|
770
616
|
return (0, _promiseUtils.continueWhile)(function () {
|
|
771
617
|
return !finished;
|
|
772
618
|
}, (0, _asyncToGenerator2.default)(function* () {
|
|
773
619
|
var _yield$Promise$all = yield Promise.all([query.find(findOptions), Promise.resolve(previousResults.length > 0 && callback(previousResults))]),
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
620
|
+
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 1),
|
|
621
|
+
results = _yield$Promise$all2[0];
|
|
777
622
|
if (results.length >= query._limit) {
|
|
778
623
|
query.greaterThan('objectId', results[results.length - 1].id);
|
|
779
624
|
previousResults = results;
|
|
@@ -804,7 +649,6 @@ var ParseQuery = function () {
|
|
|
804
649
|
if (typeof value === 'undefined') {
|
|
805
650
|
delete this._hint;
|
|
806
651
|
}
|
|
807
|
-
|
|
808
652
|
this._hint = value;
|
|
809
653
|
return this;
|
|
810
654
|
}
|
|
@@ -812,11 +656,9 @@ var ParseQuery = function () {
|
|
|
812
656
|
key: "explain",
|
|
813
657
|
value: function () {
|
|
814
658
|
var _explain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
815
|
-
|
|
816
659
|
if (typeof _explain !== 'boolean') {
|
|
817
660
|
throw new Error('You can only set explain to a boolean value');
|
|
818
661
|
}
|
|
819
|
-
|
|
820
662
|
this._explain = _explain;
|
|
821
663
|
return this;
|
|
822
664
|
}
|
|
@@ -825,7 +667,6 @@ var ParseQuery = function () {
|
|
|
825
667
|
value: function () {
|
|
826
668
|
var _map = (0, _asyncToGenerator2.default)(function* (callback, options) {
|
|
827
669
|
var _this5 = this;
|
|
828
|
-
|
|
829
670
|
var array = [];
|
|
830
671
|
var index = 0;
|
|
831
672
|
yield this.each(function (object) {
|
|
@@ -836,11 +677,9 @@ var ParseQuery = function () {
|
|
|
836
677
|
}, options);
|
|
837
678
|
return array;
|
|
838
679
|
});
|
|
839
|
-
|
|
840
680
|
function map() {
|
|
841
681
|
return _map.apply(this, arguments);
|
|
842
682
|
}
|
|
843
|
-
|
|
844
683
|
return map;
|
|
845
684
|
}()
|
|
846
685
|
}, {
|
|
@@ -855,24 +694,19 @@ var ParseQuery = function () {
|
|
|
855
694
|
index += 1;
|
|
856
695
|
return;
|
|
857
696
|
}
|
|
858
|
-
|
|
859
697
|
return Promise.resolve(callback(accumulator, object, index)).then(function (result) {
|
|
860
698
|
accumulator = result;
|
|
861
699
|
index += 1;
|
|
862
700
|
});
|
|
863
701
|
}, options);
|
|
864
|
-
|
|
865
702
|
if (index === 0 && initialValue === undefined) {
|
|
866
703
|
throw new TypeError('Reducing empty query result set with no initial value');
|
|
867
704
|
}
|
|
868
|
-
|
|
869
705
|
return accumulator;
|
|
870
706
|
});
|
|
871
|
-
|
|
872
707
|
function reduce() {
|
|
873
708
|
return _reduce.apply(this, arguments);
|
|
874
709
|
}
|
|
875
|
-
|
|
876
710
|
return reduce;
|
|
877
711
|
}()
|
|
878
712
|
}, {
|
|
@@ -880,7 +714,6 @@ var ParseQuery = function () {
|
|
|
880
714
|
value: function () {
|
|
881
715
|
var _filter = (0, _asyncToGenerator2.default)(function* (callback, options) {
|
|
882
716
|
var _this6 = this;
|
|
883
|
-
|
|
884
717
|
var array = [];
|
|
885
718
|
var index = 0;
|
|
886
719
|
yield this.each(function (object) {
|
|
@@ -888,39 +721,32 @@ var ParseQuery = function () {
|
|
|
888
721
|
if (flag) {
|
|
889
722
|
array.push(object);
|
|
890
723
|
}
|
|
891
|
-
|
|
892
724
|
index += 1;
|
|
893
725
|
});
|
|
894
726
|
}, options);
|
|
895
727
|
return array;
|
|
896
728
|
});
|
|
897
|
-
|
|
898
729
|
function filter() {
|
|
899
730
|
return _filter.apply(this, arguments);
|
|
900
731
|
}
|
|
901
|
-
|
|
902
732
|
return filter;
|
|
903
733
|
}()
|
|
904
734
|
}, {
|
|
905
735
|
key: "equalTo",
|
|
906
736
|
value: function (key, value) {
|
|
907
737
|
var _this7 = this;
|
|
908
|
-
|
|
909
738
|
if (key && typeof key === 'object') {
|
|
910
739
|
Object.entries(key).forEach(function (_ref2) {
|
|
911
740
|
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
741
|
+
k = _ref3[0],
|
|
742
|
+
val = _ref3[1];
|
|
915
743
|
return _this7.equalTo(k, val);
|
|
916
744
|
});
|
|
917
745
|
return this;
|
|
918
746
|
}
|
|
919
|
-
|
|
920
747
|
if (typeof value === 'undefined') {
|
|
921
748
|
return this.doesNotExist(key);
|
|
922
749
|
}
|
|
923
|
-
|
|
924
750
|
this._where[key] = (0, _encode.default)(value, false, true);
|
|
925
751
|
return this;
|
|
926
752
|
}
|
|
@@ -928,18 +754,15 @@ var ParseQuery = function () {
|
|
|
928
754
|
key: "notEqualTo",
|
|
929
755
|
value: function (key, value) {
|
|
930
756
|
var _this8 = this;
|
|
931
|
-
|
|
932
757
|
if (key && typeof key === 'object') {
|
|
933
758
|
Object.entries(key).forEach(function (_ref4) {
|
|
934
759
|
var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
760
|
+
k = _ref5[0],
|
|
761
|
+
val = _ref5[1];
|
|
938
762
|
return _this8.notEqualTo(k, val);
|
|
939
763
|
});
|
|
940
764
|
return this;
|
|
941
765
|
}
|
|
942
|
-
|
|
943
766
|
return this._addCondition(key, '$ne', value);
|
|
944
767
|
}
|
|
945
768
|
}, {
|
|
@@ -986,11 +809,9 @@ var ParseQuery = function () {
|
|
|
986
809
|
key: "containsAllStartingWith",
|
|
987
810
|
value: function (key, values) {
|
|
988
811
|
var _this = this;
|
|
989
|
-
|
|
990
812
|
if (!Array.isArray(values)) {
|
|
991
813
|
values = [values];
|
|
992
814
|
}
|
|
993
|
-
|
|
994
815
|
var regexObject = values.map(function (value) {
|
|
995
816
|
return {
|
|
996
817
|
$regex: _this._regexStartWith(value)
|
|
@@ -1012,23 +833,18 @@ var ParseQuery = function () {
|
|
|
1012
833
|
key: "matches",
|
|
1013
834
|
value: function (key, regex, modifiers) {
|
|
1014
835
|
this._addCondition(key, '$regex', regex);
|
|
1015
|
-
|
|
1016
836
|
if (!modifiers) {
|
|
1017
837
|
modifiers = '';
|
|
1018
838
|
}
|
|
1019
|
-
|
|
1020
839
|
if (regex.ignoreCase) {
|
|
1021
840
|
modifiers += 'i';
|
|
1022
841
|
}
|
|
1023
|
-
|
|
1024
842
|
if (regex.multiline) {
|
|
1025
843
|
modifiers += 'm';
|
|
1026
844
|
}
|
|
1027
|
-
|
|
1028
845
|
if (modifiers.length) {
|
|
1029
846
|
this._addCondition(key, '$options', modifiers);
|
|
1030
847
|
}
|
|
1031
|
-
|
|
1032
848
|
return this;
|
|
1033
849
|
}
|
|
1034
850
|
}, {
|
|
@@ -1071,48 +887,38 @@ var ParseQuery = function () {
|
|
|
1071
887
|
if (typeof substring !== 'string') {
|
|
1072
888
|
throw new Error('The value being searched for must be a string.');
|
|
1073
889
|
}
|
|
1074
|
-
|
|
1075
890
|
return this._addCondition(key, '$regex', quote(substring));
|
|
1076
891
|
}
|
|
1077
892
|
}, {
|
|
1078
893
|
key: "fullText",
|
|
1079
894
|
value: function (key, value, options) {
|
|
1080
895
|
options = options || {};
|
|
1081
|
-
|
|
1082
896
|
if (!key) {
|
|
1083
897
|
throw new Error('A key is required.');
|
|
1084
898
|
}
|
|
1085
|
-
|
|
1086
899
|
if (!value) {
|
|
1087
900
|
throw new Error('A search term is required');
|
|
1088
901
|
}
|
|
1089
|
-
|
|
1090
902
|
if (typeof value !== 'string') {
|
|
1091
903
|
throw new Error('The value being searched for must be a string.');
|
|
1092
904
|
}
|
|
1093
|
-
|
|
1094
905
|
var fullOptions = {};
|
|
1095
906
|
fullOptions.$term = value;
|
|
1096
|
-
|
|
1097
907
|
for (var option in options) {
|
|
1098
908
|
switch (option) {
|
|
1099
909
|
case 'language':
|
|
1100
910
|
fullOptions.$language = options[option];
|
|
1101
911
|
break;
|
|
1102
|
-
|
|
1103
912
|
case 'caseSensitive':
|
|
1104
913
|
fullOptions.$caseSensitive = options[option];
|
|
1105
914
|
break;
|
|
1106
|
-
|
|
1107
915
|
case 'diacriticSensitive':
|
|
1108
916
|
fullOptions.$diacriticSensitive = options[option];
|
|
1109
917
|
break;
|
|
1110
|
-
|
|
1111
918
|
default:
|
|
1112
919
|
throw new Error(`Unknown option: ${option}`);
|
|
1113
920
|
}
|
|
1114
921
|
}
|
|
1115
|
-
|
|
1116
922
|
return this._addCondition(key, '$text', {
|
|
1117
923
|
$search: fullOptions
|
|
1118
924
|
});
|
|
@@ -1130,7 +936,6 @@ var ParseQuery = function () {
|
|
|
1130
936
|
if (typeof prefix !== 'string') {
|
|
1131
937
|
throw new Error('The value being searched for must be a string.');
|
|
1132
938
|
}
|
|
1133
|
-
|
|
1134
939
|
return this.matches(key, this._regexStartWith(prefix), modifiers);
|
|
1135
940
|
}
|
|
1136
941
|
}, {
|
|
@@ -1139,7 +944,6 @@ var ParseQuery = function () {
|
|
|
1139
944
|
if (typeof suffix !== 'string') {
|
|
1140
945
|
throw new Error('The value being searched for must be a string.');
|
|
1141
946
|
}
|
|
1142
|
-
|
|
1143
947
|
return this.matches(key, quote(suffix) + '$', modifiers);
|
|
1144
948
|
}
|
|
1145
949
|
}, {
|
|
@@ -1148,7 +952,6 @@ var ParseQuery = function () {
|
|
|
1148
952
|
if (!(point instanceof _ParseGeoPoint.default)) {
|
|
1149
953
|
point = new _ParseGeoPoint.default(point);
|
|
1150
954
|
}
|
|
1151
|
-
|
|
1152
955
|
return this._addCondition(key, '$nearSphere', point);
|
|
1153
956
|
}
|
|
1154
957
|
}, {
|
|
@@ -1179,15 +982,12 @@ var ParseQuery = function () {
|
|
|
1179
982
|
if (!(southwest instanceof _ParseGeoPoint.default)) {
|
|
1180
983
|
southwest = new _ParseGeoPoint.default(southwest);
|
|
1181
984
|
}
|
|
1182
|
-
|
|
1183
985
|
if (!(northeast instanceof _ParseGeoPoint.default)) {
|
|
1184
986
|
northeast = new _ParseGeoPoint.default(northeast);
|
|
1185
987
|
}
|
|
1186
|
-
|
|
1187
988
|
this._addCondition(key, '$within', {
|
|
1188
989
|
$box: [southwest, northeast]
|
|
1189
990
|
});
|
|
1190
|
-
|
|
1191
991
|
return this;
|
|
1192
992
|
}
|
|
1193
993
|
}, {
|
|
@@ -1208,31 +1008,25 @@ var ParseQuery = function () {
|
|
|
1208
1008
|
key: "ascending",
|
|
1209
1009
|
value: function () {
|
|
1210
1010
|
this._order = [];
|
|
1211
|
-
|
|
1212
1011
|
for (var _len = arguments.length, keys = new Array(_len), _key5 = 0; _key5 < _len; _key5++) {
|
|
1213
1012
|
keys[_key5] = arguments[_key5];
|
|
1214
1013
|
}
|
|
1215
|
-
|
|
1216
1014
|
return this.addAscending.apply(this, keys);
|
|
1217
1015
|
}
|
|
1218
1016
|
}, {
|
|
1219
1017
|
key: "addAscending",
|
|
1220
1018
|
value: function () {
|
|
1221
1019
|
var _this9 = this;
|
|
1222
|
-
|
|
1223
1020
|
if (!this._order) {
|
|
1224
1021
|
this._order = [];
|
|
1225
1022
|
}
|
|
1226
|
-
|
|
1227
1023
|
for (var _len2 = arguments.length, keys = new Array(_len2), _key6 = 0; _key6 < _len2; _key6++) {
|
|
1228
1024
|
keys[_key6] = arguments[_key6];
|
|
1229
1025
|
}
|
|
1230
|
-
|
|
1231
1026
|
keys.forEach(function (key) {
|
|
1232
1027
|
if (Array.isArray(key)) {
|
|
1233
1028
|
key = key.join();
|
|
1234
1029
|
}
|
|
1235
|
-
|
|
1236
1030
|
_this9._order = _this9._order.concat(key.replace(/\s/g, '').split(','));
|
|
1237
1031
|
});
|
|
1238
1032
|
return this;
|
|
@@ -1241,31 +1035,25 @@ var ParseQuery = function () {
|
|
|
1241
1035
|
key: "descending",
|
|
1242
1036
|
value: function () {
|
|
1243
1037
|
this._order = [];
|
|
1244
|
-
|
|
1245
1038
|
for (var _len3 = arguments.length, keys = new Array(_len3), _key7 = 0; _key7 < _len3; _key7++) {
|
|
1246
1039
|
keys[_key7] = arguments[_key7];
|
|
1247
1040
|
}
|
|
1248
|
-
|
|
1249
1041
|
return this.addDescending.apply(this, keys);
|
|
1250
1042
|
}
|
|
1251
1043
|
}, {
|
|
1252
1044
|
key: "addDescending",
|
|
1253
1045
|
value: function () {
|
|
1254
1046
|
var _this10 = this;
|
|
1255
|
-
|
|
1256
1047
|
if (!this._order) {
|
|
1257
1048
|
this._order = [];
|
|
1258
1049
|
}
|
|
1259
|
-
|
|
1260
1050
|
for (var _len4 = arguments.length, keys = new Array(_len4), _key8 = 0; _key8 < _len4; _key8++) {
|
|
1261
1051
|
keys[_key8] = arguments[_key8];
|
|
1262
1052
|
}
|
|
1263
|
-
|
|
1264
1053
|
keys.forEach(function (key) {
|
|
1265
1054
|
if (Array.isArray(key)) {
|
|
1266
1055
|
key = key.join();
|
|
1267
1056
|
}
|
|
1268
|
-
|
|
1269
1057
|
_this10._order = _this10._order.concat(key.replace(/\s/g, '').split(',').map(function (k) {
|
|
1270
1058
|
return '-' + k;
|
|
1271
1059
|
}));
|
|
@@ -1278,7 +1066,6 @@ var ParseQuery = function () {
|
|
|
1278
1066
|
if (typeof n !== 'number' || n < 0) {
|
|
1279
1067
|
throw new Error('You can only skip by a positive number');
|
|
1280
1068
|
}
|
|
1281
|
-
|
|
1282
1069
|
this._skip = n;
|
|
1283
1070
|
return this;
|
|
1284
1071
|
}
|
|
@@ -1288,7 +1075,6 @@ var ParseQuery = function () {
|
|
|
1288
1075
|
if (typeof n !== 'number') {
|
|
1289
1076
|
throw new Error('You can only set the limit to a numeric value');
|
|
1290
1077
|
}
|
|
1291
|
-
|
|
1292
1078
|
this._limit = n;
|
|
1293
1079
|
return this;
|
|
1294
1080
|
}
|
|
@@ -1296,11 +1082,9 @@ var ParseQuery = function () {
|
|
|
1296
1082
|
key: "withCount",
|
|
1297
1083
|
value: function () {
|
|
1298
1084
|
var includeCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1299
|
-
|
|
1300
1085
|
if (typeof includeCount !== 'boolean') {
|
|
1301
1086
|
throw new Error('You can only set withCount to a boolean value');
|
|
1302
1087
|
}
|
|
1303
|
-
|
|
1304
1088
|
this._count = includeCount;
|
|
1305
1089
|
return this;
|
|
1306
1090
|
}
|
|
@@ -1308,11 +1092,9 @@ var ParseQuery = function () {
|
|
|
1308
1092
|
key: "include",
|
|
1309
1093
|
value: function () {
|
|
1310
1094
|
var _this11 = this;
|
|
1311
|
-
|
|
1312
1095
|
for (var _len5 = arguments.length, keys = new Array(_len5), _key9 = 0; _key9 < _len5; _key9++) {
|
|
1313
1096
|
keys[_key9] = arguments[_key9];
|
|
1314
1097
|
}
|
|
1315
|
-
|
|
1316
1098
|
keys.forEach(function (key) {
|
|
1317
1099
|
if (Array.isArray(key)) {
|
|
1318
1100
|
_this11._include = _this11._include.concat(key);
|
|
@@ -1331,15 +1113,12 @@ var ParseQuery = function () {
|
|
|
1331
1113
|
key: "select",
|
|
1332
1114
|
value: function () {
|
|
1333
1115
|
var _this12 = this;
|
|
1334
|
-
|
|
1335
1116
|
if (!this._select) {
|
|
1336
1117
|
this._select = [];
|
|
1337
1118
|
}
|
|
1338
|
-
|
|
1339
1119
|
for (var _len6 = arguments.length, keys = new Array(_len6), _key10 = 0; _key10 < _len6; _key10++) {
|
|
1340
1120
|
keys[_key10] = arguments[_key10];
|
|
1341
1121
|
}
|
|
1342
|
-
|
|
1343
1122
|
keys.forEach(function (key) {
|
|
1344
1123
|
if (Array.isArray(key)) {
|
|
1345
1124
|
_this12._select = _this12._select.concat(key);
|
|
@@ -1353,11 +1132,9 @@ var ParseQuery = function () {
|
|
|
1353
1132
|
key: "exclude",
|
|
1354
1133
|
value: function () {
|
|
1355
1134
|
var _this13 = this;
|
|
1356
|
-
|
|
1357
1135
|
for (var _len7 = arguments.length, keys = new Array(_len7), _key11 = 0; _key11 < _len7; _key11++) {
|
|
1358
1136
|
keys[_key11] = arguments[_key11];
|
|
1359
1137
|
}
|
|
1360
|
-
|
|
1361
1138
|
keys.forEach(function (key) {
|
|
1362
1139
|
if (Array.isArray(key)) {
|
|
1363
1140
|
_this13._exclude = _this13._exclude.concat(key);
|
|
@@ -1380,27 +1157,21 @@ var ParseQuery = function () {
|
|
|
1380
1157
|
value: function () {
|
|
1381
1158
|
var _subscribe = (0, _asyncToGenerator2.default)(function* (sessionToken) {
|
|
1382
1159
|
var currentUser = yield _CoreManager.default.getUserController().currentUserAsync();
|
|
1383
|
-
|
|
1384
1160
|
if (!sessionToken) {
|
|
1385
1161
|
sessionToken = currentUser ? currentUser.getSessionToken() : undefined;
|
|
1386
1162
|
}
|
|
1387
|
-
|
|
1388
1163
|
var liveQueryClient = yield _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
1389
|
-
|
|
1390
1164
|
if (liveQueryClient.shouldOpen()) {
|
|
1391
1165
|
liveQueryClient.open();
|
|
1392
1166
|
}
|
|
1393
|
-
|
|
1394
1167
|
var subscription = liveQueryClient.subscribe(this, sessionToken);
|
|
1395
1168
|
return subscription.subscribePromise.then(function () {
|
|
1396
1169
|
return subscription;
|
|
1397
1170
|
});
|
|
1398
1171
|
});
|
|
1399
|
-
|
|
1400
1172
|
function subscribe() {
|
|
1401
1173
|
return _subscribe.apply(this, arguments);
|
|
1402
1174
|
}
|
|
1403
|
-
|
|
1404
1175
|
return subscribe;
|
|
1405
1176
|
}()
|
|
1406
1177
|
}, {
|
|
@@ -1424,31 +1195,23 @@ var ParseQuery = function () {
|
|
|
1424
1195
|
key: "fromPinWithName",
|
|
1425
1196
|
value: function (name) {
|
|
1426
1197
|
var localDatastore = _CoreManager.default.getLocalDatastore();
|
|
1427
|
-
|
|
1428
1198
|
if (localDatastore.checkIfEnabled()) {
|
|
1429
1199
|
this._queriesLocalDatastore = true;
|
|
1430
1200
|
this._localDatastorePinName = name;
|
|
1431
1201
|
}
|
|
1432
|
-
|
|
1433
1202
|
return this;
|
|
1434
1203
|
}
|
|
1435
1204
|
}, {
|
|
1436
1205
|
key: "cancel",
|
|
1437
1206
|
value: function () {
|
|
1438
1207
|
var _this14 = this;
|
|
1439
|
-
|
|
1440
1208
|
if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
|
|
1441
1209
|
this._xhrRequest.task._aborted = true;
|
|
1442
|
-
|
|
1443
1210
|
this._xhrRequest.task.abort();
|
|
1444
|
-
|
|
1445
1211
|
this._xhrRequest.task = null;
|
|
1446
|
-
|
|
1447
1212
|
this._xhrRequest.onchange = function () {};
|
|
1448
|
-
|
|
1449
1213
|
return this;
|
|
1450
1214
|
}
|
|
1451
|
-
|
|
1452
1215
|
return this._xhrRequest.onchange = function () {
|
|
1453
1216
|
return _this14.cancel();
|
|
1454
1217
|
};
|
|
@@ -1457,10 +1220,8 @@ var ParseQuery = function () {
|
|
|
1457
1220
|
key: "_setRequestTask",
|
|
1458
1221
|
value: function (options) {
|
|
1459
1222
|
var _this15 = this;
|
|
1460
|
-
|
|
1461
1223
|
options.requestTask = function (task) {
|
|
1462
1224
|
_this15._xhrRequest.task = task;
|
|
1463
|
-
|
|
1464
1225
|
_this15._xhrRequest.onchange();
|
|
1465
1226
|
};
|
|
1466
1227
|
}
|
|
@@ -1476,13 +1237,9 @@ var ParseQuery = function () {
|
|
|
1476
1237
|
for (var _len8 = arguments.length, queries = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
|
|
1477
1238
|
queries[_key12] = arguments[_key12];
|
|
1478
1239
|
}
|
|
1479
|
-
|
|
1480
1240
|
var className = _getClassNameFromQueries(queries);
|
|
1481
|
-
|
|
1482
1241
|
var query = new ParseQuery(className);
|
|
1483
|
-
|
|
1484
1242
|
query._orQuery(queries);
|
|
1485
|
-
|
|
1486
1243
|
return query;
|
|
1487
1244
|
}
|
|
1488
1245
|
}, {
|
|
@@ -1491,13 +1248,9 @@ var ParseQuery = function () {
|
|
|
1491
1248
|
for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
|
|
1492
1249
|
queries[_key13] = arguments[_key13];
|
|
1493
1250
|
}
|
|
1494
|
-
|
|
1495
1251
|
var className = _getClassNameFromQueries(queries);
|
|
1496
|
-
|
|
1497
1252
|
var query = new ParseQuery(className);
|
|
1498
|
-
|
|
1499
1253
|
query._andQuery(queries);
|
|
1500
|
-
|
|
1501
1254
|
return query;
|
|
1502
1255
|
}
|
|
1503
1256
|
}, {
|
|
@@ -1506,33 +1259,24 @@ var ParseQuery = function () {
|
|
|
1506
1259
|
for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
|
|
1507
1260
|
queries[_key14] = arguments[_key14];
|
|
1508
1261
|
}
|
|
1509
|
-
|
|
1510
1262
|
var className = _getClassNameFromQueries(queries);
|
|
1511
|
-
|
|
1512
1263
|
var query = new ParseQuery(className);
|
|
1513
|
-
|
|
1514
1264
|
query._norQuery(queries);
|
|
1515
|
-
|
|
1516
1265
|
return query;
|
|
1517
1266
|
}
|
|
1518
1267
|
}]);
|
|
1519
1268
|
return ParseQuery;
|
|
1520
1269
|
}();
|
|
1521
|
-
|
|
1522
1270
|
var DefaultController = {
|
|
1523
1271
|
find: function (className, params, options) {
|
|
1524
1272
|
var RESTController = _CoreManager.default.getRESTController();
|
|
1525
|
-
|
|
1526
1273
|
return RESTController.request('GET', 'classes/' + className, params, options);
|
|
1527
1274
|
},
|
|
1528
1275
|
aggregate: function (className, params, options) {
|
|
1529
1276
|
var RESTController = _CoreManager.default.getRESTController();
|
|
1530
|
-
|
|
1531
1277
|
return RESTController.request('GET', 'aggregate/' + className, params, options);
|
|
1532
1278
|
}
|
|
1533
1279
|
};
|
|
1534
|
-
|
|
1535
1280
|
_CoreManager.default.setQueryController(DefaultController);
|
|
1536
|
-
|
|
1537
1281
|
var _default = ParseQuery;
|
|
1538
1282
|
exports.default = _default;
|