Do not mutate parameter object in DatabaseController.
This commit is contained in:
@@ -6,6 +6,7 @@ var Parse = require('parse/node').Parse;
|
|||||||
|
|
||||||
var Schema = require('./../Schema');
|
var Schema = require('./../Schema');
|
||||||
var transform = require('./../transform');
|
var transform = require('./../transform');
|
||||||
|
const deepcopy = require('deepcopy');
|
||||||
|
|
||||||
// options can contain:
|
// options can contain:
|
||||||
// collectionPrefix: the string to put in front of every collection name.
|
// collectionPrefix: the string to put in front of every collection name.
|
||||||
@@ -130,6 +131,9 @@ DatabaseController.prototype.untransformObject = function(
|
|||||||
// one of the provided strings must provide the caller with
|
// one of the provided strings must provide the caller with
|
||||||
// write permissions.
|
// write permissions.
|
||||||
DatabaseController.prototype.update = function(className, query, update, options) {
|
DatabaseController.prototype.update = function(className, query, update, options) {
|
||||||
|
// Make a copy of the object, so we don't mutate the incoming data.
|
||||||
|
update = deepcopy(update);
|
||||||
|
|
||||||
var acceptor = function(schema) {
|
var acceptor = function(schema) {
|
||||||
return schema.hasKeys(className, Object.keys(query));
|
return schema.hasKeys(className, Object.keys(query));
|
||||||
};
|
};
|
||||||
@@ -300,6 +304,9 @@ DatabaseController.prototype.destroy = function(className, query, options = {})
|
|||||||
// Inserts an object into the database.
|
// Inserts an object into the database.
|
||||||
// Returns a promise that resolves successfully iff the object saved.
|
// Returns a promise that resolves successfully iff the object saved.
|
||||||
DatabaseController.prototype.create = function(className, object, options) {
|
DatabaseController.prototype.create = function(className, object, options) {
|
||||||
|
// Make a copy of the object, so we don't mutate the incoming data.
|
||||||
|
object = deepcopy(object);
|
||||||
|
|
||||||
var schema;
|
var schema;
|
||||||
var isMaster = !('acl' in options);
|
var isMaster = !('acl' in options);
|
||||||
var aclGroup = options.acl || [];
|
var aclGroup = options.acl || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user