* #6101 Let users define objectId * Add `allowCustomObjectId` to PS Option * Add checking in objectId creation * Add test * Update docs * Update definition * Change default to false * throw on empty, null, undefined * better tests * unused async * removed comment * retain comment * Linting fix according to contributing spec.
This commit is contained in:
@@ -46,17 +46,32 @@ function RestWrite(
|
||||
this.storage = {};
|
||||
this.runOptions = {};
|
||||
this.context = {};
|
||||
if (!query && data.objectId) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
'objectId is an invalid field name.'
|
||||
);
|
||||
}
|
||||
if (!query && data.id) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
'id is an invalid field name.'
|
||||
);
|
||||
|
||||
if (!query) {
|
||||
if (this.config.allowCustomObjectId) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(data, 'objectId') &&
|
||||
!data.objectId
|
||||
) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.MISSING_OBJECT_ID,
|
||||
'objectId must not be empty, null or undefined'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (data.objectId) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
'objectId is an invalid field name.'
|
||||
);
|
||||
}
|
||||
if (data.id) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
'id is an invalid field name.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the operation is complete, this.response may have several
|
||||
|
||||
Reference in New Issue
Block a user