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
|
@@ -7,21 +7,11 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
13
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
14
12
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
15
13
|
var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
|
|
16
|
-
|
|
17
|
-
* @flow
|
|
18
|
-
*/
|
|
19
|
-
/*:: import type { PermissionsMap } from './ParseCLP';*/
|
|
20
|
-
var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
21
|
-
/*:: type FieldOptions = {
|
|
22
|
-
required: boolean,
|
|
23
|
-
defaultValue: mixed,
|
|
24
|
-
};*/
|
|
14
|
+
const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
25
15
|
/**
|
|
26
16
|
* A Parse.Schema object is for handling schema data from Parse.
|
|
27
17
|
* <p>All the schemas methods require MasterKey.
|
|
@@ -39,12 +29,11 @@ var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoP
|
|
|
39
29
|
*
|
|
40
30
|
* @alias Parse.Schema
|
|
41
31
|
*/
|
|
42
|
-
|
|
32
|
+
class ParseSchema {
|
|
43
33
|
/**
|
|
44
34
|
* @param {string} className Parse Class string.
|
|
45
35
|
*/
|
|
46
|
-
|
|
47
|
-
(0, _classCallCheck2.default)(this, ParseSchema);
|
|
36
|
+
constructor(className) {
|
|
48
37
|
(0, _defineProperty2.default)(this, "className", void 0);
|
|
49
38
|
(0, _defineProperty2.default)(this, "_fields", void 0);
|
|
50
39
|
(0, _defineProperty2.default)(this, "_indexes", void 0);
|
|
@@ -66,470 +55,419 @@ var ParseSchema = /*#__PURE__*/function () {
|
|
|
66
55
|
* @returns {Promise} A promise that is resolved with the result when
|
|
67
56
|
* the query completes.
|
|
68
57
|
*/
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
function () {
|
|
79
|
-
this.assertClassName();
|
|
80
|
-
var controller = _CoreManager.default.getSchemaController();
|
|
81
|
-
return controller.get(this.className).then(function (response) {
|
|
82
|
-
if (!response) {
|
|
83
|
-
throw new Error('Schema not found.');
|
|
84
|
-
}
|
|
85
|
-
return response;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
58
|
+
static all() {
|
|
59
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
60
|
+
return controller.get('').then(response => {
|
|
61
|
+
if (response.results.length === 0) {
|
|
62
|
+
throw new Error('Schema not found.');
|
|
63
|
+
}
|
|
64
|
+
return response.results;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
88
67
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
return controller.create(this.className, params);
|
|
107
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the Schema from Parse
|
|
70
|
+
*
|
|
71
|
+
* @returns {Promise} A promise that is resolved with the result when
|
|
72
|
+
* the query completes.
|
|
73
|
+
*/
|
|
74
|
+
get() {
|
|
75
|
+
this.assertClassName();
|
|
76
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
77
|
+
return controller.get(this.className).then(response => {
|
|
78
|
+
if (!response) {
|
|
79
|
+
throw new Error('Schema not found.');
|
|
80
|
+
}
|
|
81
|
+
return response;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
108
84
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this._fields = {};
|
|
127
|
-
this._indexes = {};
|
|
128
|
-
return controller.update(this.className, params);
|
|
129
|
-
}
|
|
85
|
+
/**
|
|
86
|
+
* Create a new Schema on Parse
|
|
87
|
+
*
|
|
88
|
+
* @returns {Promise} A promise that is resolved with the result when
|
|
89
|
+
* the query completes.
|
|
90
|
+
*/
|
|
91
|
+
save() {
|
|
92
|
+
this.assertClassName();
|
|
93
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
94
|
+
const params = {
|
|
95
|
+
className: this.className,
|
|
96
|
+
fields: this._fields,
|
|
97
|
+
indexes: this._indexes,
|
|
98
|
+
classLevelPermissions: this._clp
|
|
99
|
+
};
|
|
100
|
+
return controller.create(this.className, params);
|
|
101
|
+
}
|
|
130
102
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Update a Schema on Parse
|
|
105
|
+
*
|
|
106
|
+
* @returns {Promise} A promise that is resolved with the result when
|
|
107
|
+
* the query completes.
|
|
108
|
+
*/
|
|
109
|
+
update() {
|
|
110
|
+
this.assertClassName();
|
|
111
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
112
|
+
const params = {
|
|
113
|
+
className: this.className,
|
|
114
|
+
fields: this._fields,
|
|
115
|
+
indexes: this._indexes,
|
|
116
|
+
classLevelPermissions: this._clp
|
|
117
|
+
};
|
|
118
|
+
this._fields = {};
|
|
119
|
+
this._indexes = {};
|
|
120
|
+
return controller.update(this.className, params);
|
|
121
|
+
}
|
|
145
122
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return controller.purge(this.className);
|
|
159
|
-
}
|
|
123
|
+
/**
|
|
124
|
+
* Removing a Schema from Parse
|
|
125
|
+
* Can only be used on Schema without objects
|
|
126
|
+
*
|
|
127
|
+
* @returns {Promise} A promise that is resolved with the result when
|
|
128
|
+
* the query completes.
|
|
129
|
+
*/
|
|
130
|
+
delete() {
|
|
131
|
+
this.assertClassName();
|
|
132
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
133
|
+
return controller.delete(this.className);
|
|
134
|
+
}
|
|
160
135
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Removes all objects from a Schema (class) in Parse.
|
|
138
|
+
* EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
|
|
139
|
+
*
|
|
140
|
+
* @returns {Promise} A promise that is resolved with the result when
|
|
141
|
+
* the query completes.
|
|
142
|
+
*/
|
|
143
|
+
purge() {
|
|
144
|
+
this.assertClassName();
|
|
145
|
+
const controller = _CoreManager.default.getSchemaController();
|
|
146
|
+
return controller.purge(this.className);
|
|
147
|
+
}
|
|
173
148
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
key: "setCLP",
|
|
183
|
-
value: function (clp /*: PermissionsMap | ParseCLP*/) {
|
|
184
|
-
if (clp instanceof _ParseCLP.default) {
|
|
185
|
-
this._clp = clp.toJSON();
|
|
186
|
-
} else {
|
|
187
|
-
this._clp = clp;
|
|
188
|
-
}
|
|
189
|
-
return this;
|
|
149
|
+
/**
|
|
150
|
+
* Assert if ClassName has been filled
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
assertClassName() {
|
|
155
|
+
if (!this.className) {
|
|
156
|
+
throw new Error('You must set a Class Name before making any request.');
|
|
190
157
|
}
|
|
158
|
+
}
|
|
191
159
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
*/
|
|
205
|
-
}, {
|
|
206
|
-
key: "addField",
|
|
207
|
-
value: function (name /*: string*/, type /*: string*/) {
|
|
208
|
-
var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
209
|
-
type = type || 'String';
|
|
210
|
-
if (!name) {
|
|
211
|
-
throw new Error('field name may not be null.');
|
|
212
|
-
}
|
|
213
|
-
if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
|
|
214
|
-
throw new Error("".concat(type, " is not a valid type."));
|
|
215
|
-
}
|
|
216
|
-
if (type === 'Pointer') {
|
|
217
|
-
return this.addPointer(name, options.targetClass, options);
|
|
218
|
-
}
|
|
219
|
-
if (type === 'Relation') {
|
|
220
|
-
return this.addRelation(name, options.targetClass, options);
|
|
221
|
-
}
|
|
222
|
-
var fieldOptions = {
|
|
223
|
-
type: type
|
|
224
|
-
};
|
|
225
|
-
if (typeof options.required === 'boolean') {
|
|
226
|
-
fieldOptions.required = options.required;
|
|
227
|
-
}
|
|
228
|
-
if (options.defaultValue !== undefined) {
|
|
229
|
-
fieldOptions.defaultValue = options.defaultValue;
|
|
230
|
-
}
|
|
231
|
-
if (type === 'Date') {
|
|
232
|
-
if (options && options.defaultValue) {
|
|
233
|
-
fieldOptions.defaultValue = {
|
|
234
|
-
__type: 'Date',
|
|
235
|
-
iso: new Date(options.defaultValue)
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (type === 'Bytes') {
|
|
240
|
-
if (options && options.defaultValue) {
|
|
241
|
-
fieldOptions.defaultValue = {
|
|
242
|
-
__type: 'Bytes',
|
|
243
|
-
base64: options.defaultValue
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
this._fields[name] = fieldOptions;
|
|
248
|
-
return this;
|
|
160
|
+
/**
|
|
161
|
+
* Sets Class Level Permissions when creating / updating a Schema.
|
|
162
|
+
* EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
|
|
163
|
+
*
|
|
164
|
+
* @param {object | Parse.CLP} clp Class Level Permissions
|
|
165
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
166
|
+
*/
|
|
167
|
+
setCLP(clp) {
|
|
168
|
+
if (clp instanceof _ParseCLP.default) {
|
|
169
|
+
this._clp = clp.toJSON();
|
|
170
|
+
} else {
|
|
171
|
+
this._clp = clp;
|
|
249
172
|
}
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
250
175
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Adding a Field to Create / Update a Schema
|
|
178
|
+
*
|
|
179
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
180
|
+
* @param {string} type Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)
|
|
181
|
+
* @param {object} options
|
|
182
|
+
* Valid options are:<ul>
|
|
183
|
+
* <li>required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
|
|
184
|
+
* <li>defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
|
|
185
|
+
* <li>targetClass: Required if type is Pointer or Parse.Relation
|
|
186
|
+
* </ul>
|
|
187
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
188
|
+
*/
|
|
189
|
+
addField(name, type) {
|
|
190
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
191
|
+
type = type || 'String';
|
|
192
|
+
if (!name) {
|
|
193
|
+
throw new Error('field name may not be null.');
|
|
194
|
+
}
|
|
195
|
+
if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
|
|
196
|
+
throw new Error(`${type} is not a valid type.`);
|
|
197
|
+
}
|
|
198
|
+
if (type === 'Pointer') {
|
|
199
|
+
return this.addPointer(name, options.targetClass, options);
|
|
200
|
+
}
|
|
201
|
+
if (type === 'Relation') {
|
|
202
|
+
return this.addRelation(name, options.targetClass);
|
|
203
|
+
}
|
|
204
|
+
const fieldOptions = {
|
|
205
|
+
type
|
|
206
|
+
};
|
|
207
|
+
if (typeof options.required === 'boolean') {
|
|
208
|
+
fieldOptions.required = options.required;
|
|
209
|
+
}
|
|
210
|
+
if (options.defaultValue !== undefined) {
|
|
211
|
+
fieldOptions.defaultValue = options.defaultValue;
|
|
212
|
+
}
|
|
213
|
+
if (type === 'Date') {
|
|
214
|
+
if (options && options.defaultValue) {
|
|
215
|
+
fieldOptions.defaultValue = {
|
|
216
|
+
__type: 'Date',
|
|
217
|
+
iso: new Date(options.defaultValue)
|
|
218
|
+
};
|
|
267
219
|
}
|
|
268
|
-
|
|
269
|
-
|
|
220
|
+
}
|
|
221
|
+
if (type === 'Bytes') {
|
|
222
|
+
if (options && options.defaultValue) {
|
|
223
|
+
fieldOptions.defaultValue = {
|
|
224
|
+
__type: 'Bytes',
|
|
225
|
+
base64: options.defaultValue
|
|
226
|
+
};
|
|
270
227
|
}
|
|
271
|
-
this._indexes[name] = index;
|
|
272
|
-
return this;
|
|
273
228
|
}
|
|
229
|
+
this._fields[name] = fieldOptions;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
274
232
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Adding an Index to Create / Update a Schema
|
|
235
|
+
*
|
|
236
|
+
* @param {string} name Name of the index
|
|
237
|
+
* @param {object} index { field: value }
|
|
238
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
239
|
+
*
|
|
240
|
+
* <pre>
|
|
241
|
+
* schema.addIndex('index_name', { 'field': 1 });
|
|
242
|
+
* </pre>
|
|
243
|
+
*/
|
|
244
|
+
addIndex(name, index) {
|
|
245
|
+
if (!name) {
|
|
246
|
+
throw new Error('index name may not be null.');
|
|
286
247
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* Adding Number Field
|
|
290
|
-
*
|
|
291
|
-
* @param {string} name Name of the field that will be created on Parse
|
|
292
|
-
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
293
|
-
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
294
|
-
*/
|
|
295
|
-
}, {
|
|
296
|
-
key: "addNumber",
|
|
297
|
-
value: function (name /*: string*/, options /*: FieldOptions*/) {
|
|
298
|
-
return this.addField(name, 'Number', options);
|
|
248
|
+
if (!index) {
|
|
249
|
+
throw new Error('index may not be null.');
|
|
299
250
|
}
|
|
251
|
+
this._indexes[name] = index;
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
300
254
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return this.addField(name, 'Boolean', options);
|
|
312
|
-
}
|
|
255
|
+
/**
|
|
256
|
+
* Adding String Field
|
|
257
|
+
*
|
|
258
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
259
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
260
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
261
|
+
*/
|
|
262
|
+
addString(name, options) {
|
|
263
|
+
return this.addField(name, 'String', options);
|
|
264
|
+
}
|
|
313
265
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return this.addField(name, 'Bytes', options);
|
|
325
|
-
}
|
|
266
|
+
/**
|
|
267
|
+
* Adding Number Field
|
|
268
|
+
*
|
|
269
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
270
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
271
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
272
|
+
*/
|
|
273
|
+
addNumber(name, options) {
|
|
274
|
+
return this.addField(name, 'Number', options);
|
|
275
|
+
}
|
|
326
276
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return this.addField(name, 'Date', options);
|
|
338
|
-
}
|
|
277
|
+
/**
|
|
278
|
+
* Adding Boolean Field
|
|
279
|
+
*
|
|
280
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
281
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
282
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
283
|
+
*/
|
|
284
|
+
addBoolean(name, options) {
|
|
285
|
+
return this.addField(name, 'Boolean', options);
|
|
286
|
+
}
|
|
339
287
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return this.addField(name, 'File', options);
|
|
351
|
-
}
|
|
288
|
+
/**
|
|
289
|
+
* Adding Bytes Field
|
|
290
|
+
*
|
|
291
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
292
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
293
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
294
|
+
*/
|
|
295
|
+
addBytes(name, options) {
|
|
296
|
+
return this.addField(name, 'Bytes', options);
|
|
297
|
+
}
|
|
352
298
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
return this.addField(name, 'GeoPoint', options);
|
|
364
|
-
}
|
|
299
|
+
/**
|
|
300
|
+
* Adding Date Field
|
|
301
|
+
*
|
|
302
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
303
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
304
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
305
|
+
*/
|
|
306
|
+
addDate(name, options) {
|
|
307
|
+
return this.addField(name, 'Date', options);
|
|
308
|
+
}
|
|
365
309
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return this.addField(name, 'Polygon', options);
|
|
377
|
-
}
|
|
310
|
+
/**
|
|
311
|
+
* Adding File Field
|
|
312
|
+
*
|
|
313
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
314
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
315
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
316
|
+
*/
|
|
317
|
+
addFile(name, options) {
|
|
318
|
+
return this.addField(name, 'File', options);
|
|
319
|
+
}
|
|
378
320
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return this.addField(name, 'Array', options);
|
|
390
|
-
}
|
|
321
|
+
/**
|
|
322
|
+
* Adding GeoPoint Field
|
|
323
|
+
*
|
|
324
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
325
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
326
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
327
|
+
*/
|
|
328
|
+
addGeoPoint(name, options) {
|
|
329
|
+
return this.addField(name, 'GeoPoint', options);
|
|
330
|
+
}
|
|
391
331
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return this.addField(name, 'Object', options);
|
|
403
|
-
}
|
|
332
|
+
/**
|
|
333
|
+
* Adding Polygon Field
|
|
334
|
+
*
|
|
335
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
336
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
337
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
338
|
+
*/
|
|
339
|
+
addPolygon(name, options) {
|
|
340
|
+
return this.addField(name, 'Polygon', options);
|
|
341
|
+
}
|
|
404
342
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
value: function (name /*: string*/, targetClass /*: string*/) {
|
|
416
|
-
var options /*: FieldOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
417
|
-
if (!name) {
|
|
418
|
-
throw new Error('field name may not be null.');
|
|
419
|
-
}
|
|
420
|
-
if (!targetClass) {
|
|
421
|
-
throw new Error('You need to set the targetClass of the Pointer.');
|
|
422
|
-
}
|
|
423
|
-
var fieldOptions = {
|
|
424
|
-
type: 'Pointer',
|
|
425
|
-
targetClass: targetClass
|
|
426
|
-
};
|
|
427
|
-
if (typeof options.required === 'boolean') {
|
|
428
|
-
fieldOptions.required = options.required;
|
|
429
|
-
}
|
|
430
|
-
if (options.defaultValue !== undefined) {
|
|
431
|
-
fieldOptions.defaultValue = options.defaultValue;
|
|
432
|
-
if (options.defaultValue instanceof _ParseObject.default) {
|
|
433
|
-
fieldOptions.defaultValue = options.defaultValue.toPointer();
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
this._fields[name] = fieldOptions;
|
|
437
|
-
return this;
|
|
438
|
-
}
|
|
343
|
+
/**
|
|
344
|
+
* Adding Array Field
|
|
345
|
+
*
|
|
346
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
347
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
348
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
349
|
+
*/
|
|
350
|
+
addArray(name, options) {
|
|
351
|
+
return this.addField(name, 'Array', options);
|
|
352
|
+
}
|
|
439
353
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (!name) {
|
|
451
|
-
throw new Error('field name may not be null.');
|
|
452
|
-
}
|
|
453
|
-
if (!targetClass) {
|
|
454
|
-
throw new Error('You need to set the targetClass of the Relation.');
|
|
455
|
-
}
|
|
456
|
-
this._fields[name] = {
|
|
457
|
-
type: 'Relation',
|
|
458
|
-
targetClass: targetClass
|
|
459
|
-
};
|
|
460
|
-
return this;
|
|
461
|
-
}
|
|
354
|
+
/**
|
|
355
|
+
* Adding Object Field
|
|
356
|
+
*
|
|
357
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
358
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
359
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
360
|
+
*/
|
|
361
|
+
addObject(name, options) {
|
|
362
|
+
return this.addField(name, 'Object', options);
|
|
363
|
+
}
|
|
462
364
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return this;
|
|
365
|
+
/**
|
|
366
|
+
* Adding Pointer Field
|
|
367
|
+
*
|
|
368
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
369
|
+
* @param {string} targetClass Name of the target Pointer Class
|
|
370
|
+
* @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
|
|
371
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
372
|
+
*/
|
|
373
|
+
addPointer(name, targetClass) {
|
|
374
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
375
|
+
if (!name) {
|
|
376
|
+
throw new Error('field name may not be null.');
|
|
476
377
|
}
|
|
378
|
+
if (!targetClass) {
|
|
379
|
+
throw new Error('You need to set the targetClass of the Pointer.');
|
|
380
|
+
}
|
|
381
|
+
const fieldOptions = {
|
|
382
|
+
type: 'Pointer',
|
|
383
|
+
targetClass
|
|
384
|
+
};
|
|
385
|
+
if (typeof options.required === 'boolean') {
|
|
386
|
+
fieldOptions.required = options.required;
|
|
387
|
+
}
|
|
388
|
+
if (options.defaultValue !== undefined) {
|
|
389
|
+
fieldOptions.defaultValue = options.defaultValue;
|
|
390
|
+
if (options.defaultValue instanceof _ParseObject.default) {
|
|
391
|
+
fieldOptions.defaultValue = options.defaultValue.toPointer();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
this._fields[name] = fieldOptions;
|
|
395
|
+
return this;
|
|
396
|
+
}
|
|
477
397
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
__op: 'Delete'
|
|
489
|
-
};
|
|
490
|
-
return this;
|
|
398
|
+
/**
|
|
399
|
+
* Adding Relation Field
|
|
400
|
+
*
|
|
401
|
+
* @param {string} name Name of the field that will be created on Parse
|
|
402
|
+
* @param {string} targetClass Name of the target Pointer Class
|
|
403
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
404
|
+
*/
|
|
405
|
+
addRelation(name, targetClass) {
|
|
406
|
+
if (!name) {
|
|
407
|
+
throw new Error('field name may not be null.');
|
|
491
408
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
value: function () {
|
|
495
|
-
var controller = _CoreManager.default.getSchemaController();
|
|
496
|
-
return controller.get('').then(function (response) {
|
|
497
|
-
if (response.results.length === 0) {
|
|
498
|
-
throw new Error('Schema not found.');
|
|
499
|
-
}
|
|
500
|
-
return response.results;
|
|
501
|
-
});
|
|
409
|
+
if (!targetClass) {
|
|
410
|
+
throw new Error('You need to set the targetClass of the Relation.');
|
|
502
411
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
412
|
+
this._fields[name] = {
|
|
413
|
+
type: 'Relation',
|
|
414
|
+
targetClass
|
|
415
|
+
};
|
|
416
|
+
return this;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Deleting a Field to Update on a Schema
|
|
421
|
+
*
|
|
422
|
+
* @param {string} name Name of the field
|
|
423
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
424
|
+
*/
|
|
425
|
+
deleteField(name) {
|
|
426
|
+
this._fields[name] = {
|
|
427
|
+
__op: 'Delete'
|
|
428
|
+
};
|
|
429
|
+
return this;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Deleting an Index to Update on a Schema
|
|
434
|
+
*
|
|
435
|
+
* @param {string} name Name of the field
|
|
436
|
+
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
|
|
437
|
+
*/
|
|
438
|
+
deleteIndex(name) {
|
|
439
|
+
this._indexes[name] = {
|
|
440
|
+
__op: 'Delete'
|
|
441
|
+
};
|
|
442
|
+
return this;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const DefaultController = {
|
|
446
|
+
send(className, method) {
|
|
447
|
+
let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
448
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
449
|
+
return RESTController.request(method, `schemas/${className}`, params, {
|
|
511
450
|
useMasterKey: true
|
|
512
451
|
});
|
|
513
452
|
},
|
|
514
|
-
get
|
|
453
|
+
get(className) {
|
|
515
454
|
return this.send(className, 'GET');
|
|
516
455
|
},
|
|
517
|
-
create
|
|
456
|
+
create(className, params) {
|
|
518
457
|
return this.send(className, 'POST', params);
|
|
519
458
|
},
|
|
520
|
-
update
|
|
459
|
+
update(className, params) {
|
|
521
460
|
return this.send(className, 'PUT', params);
|
|
522
461
|
},
|
|
523
|
-
delete
|
|
462
|
+
delete(className) {
|
|
524
463
|
return this.send(className, 'DELETE');
|
|
525
464
|
},
|
|
526
|
-
purge
|
|
527
|
-
|
|
528
|
-
return RESTController.request('DELETE',
|
|
465
|
+
purge(className) {
|
|
466
|
+
const RESTController = _CoreManager.default.getRESTController();
|
|
467
|
+
return RESTController.request('DELETE', `purge/${className}`, {}, {
|
|
529
468
|
useMasterKey: true
|
|
530
469
|
});
|
|
531
470
|
}
|
|
532
471
|
};
|
|
533
472
|
_CoreManager.default.setSchemaController(DefaultController);
|
|
534
|
-
var _default = ParseSchema;
|
|
535
|
-
exports.default = _default;
|
|
473
|
+
var _default = exports.default = ParseSchema;
|