@@ -6,6 +6,7 @@ var Parse = require('parse/node').Parse;
6
6
7
7
var Schema = require ( './../Schema' ) ;
8
8
var transform = require ( './../transform' ) ;
9
+ const deepcopy = require ( 'deepcopy' ) ;
9
10
10
11
// options can contain:
11
12
// collectionPrefix: the string to put in front of every collection name.
@@ -130,6 +131,9 @@ DatabaseController.prototype.untransformObject = function(
130
131
// one of the provided strings must provide the caller with
131
132
// write permissions.
132
133
DatabaseController . prototype . update = function ( className , query , update , options ) {
134
+ // Make a copy of the object, so we don't mutate the incoming data.
135
+ update = deepcopy ( update ) ;
136
+
133
137
var acceptor = function ( schema ) {
134
138
return schema . hasKeys ( className , Object . keys ( query ) ) ;
135
139
} ;
@@ -300,6 +304,9 @@ DatabaseController.prototype.destroy = function(className, query, options = {})
300
304
// Inserts an object into the database.
301
305
// Returns a promise that resolves successfully iff the object saved.
302
306
DatabaseController . prototype . create = function ( className , object , options ) {
307
+ // Make a copy of the object, so we don't mutate the incoming data.
308
+ object = deepcopy ( object ) ;
309
+
303
310
var schema ;
304
311
var isMaster = ! ( 'acl' in options ) ;
305
312
var aclGroup = options . acl || [ ] ;
0 commit comments