(config, auth, className, query, data, originalData, clientSDK, context, action)
| 30 | // everything. It also knows to use triggers and special modifications |
| 31 | // for the _User class. |
| 32 | function RestWrite(config, auth, className, query, data, originalData, clientSDK, context, action) { |
| 33 | if (auth.isReadOnly) { |
| 34 | throw createSanitizedError( |
| 35 | Parse.Error.OPERATION_FORBIDDEN, |
| 36 | 'Cannot perform a write operation when using readOnlyMasterKey', |
| 37 | config |
| 38 | ); |
| 39 | } |
| 40 | this.config = config; |
| 41 | this.auth = auth; |
| 42 | this.className = className; |
| 43 | this.clientSDK = clientSDK; |
| 44 | this.storage = {}; |
| 45 | this.runOptions = {}; |
| 46 | this.context = context || {}; |
| 47 | |
| 48 | if (action) { |
| 49 | this.runOptions.action = action; |
| 50 | } |
| 51 | |
| 52 | if (!query) { |
| 53 | if (this.config.allowCustomObjectId) { |
| 54 | if (Object.prototype.hasOwnProperty.call(data, 'objectId') && !data.objectId) { |
| 55 | throw new Parse.Error( |
| 56 | Parse.Error.MISSING_OBJECT_ID, |
| 57 | 'objectId must not be empty, null or undefined' |
| 58 | ); |
| 59 | } |
| 60 | } else { |
| 61 | if (data.objectId) { |
| 62 | throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, 'objectId is an invalid field name.'); |
| 63 | } |
| 64 | if (data.id) { |
| 65 | throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, 'id is an invalid field name.'); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // When the operation is complete, this.response may have several |
| 71 | // fields. |
| 72 | // response: the actual data to be returned |
| 73 | // status: the http status code. if not present, treated like a 200 |
| 74 | // location: the location header. if not present, no location header |
| 75 | this.response = null; |
| 76 | |
| 77 | // Processing this operation may mutate our data, so we operate on a |
| 78 | // copy |
| 79 | this.query = structuredClone(query); |
| 80 | this.data = structuredClone(data); |
| 81 | // We never change originalData, so we do not need a deep copy |
| 82 | this.originalData = originalData; |
| 83 | |
| 84 | // The timestamp we'll use for this whole operation |
| 85 | this.updatedAt = Parse._encode(new Date()).iso; |
| 86 | |
| 87 | // Shared SchemaController to be reused to reduce the number of loadSchema() calls per request |
| 88 | // Once set the schemaData should be immutable |
| 89 | this.validSchemaController = null; |
nothing calls this directly
no test coverage detected