@@ -13,6 +13,7 @@ const {
1313 isObject,
1414 isString,
1515 isUndefined,
16+ plainCopy,
1617 resolve
1718} = utils
1819
@@ -387,20 +388,20 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
387388 * @method
388389 * @return {Object }
389390 */
390- getQuery ( Resource , query ) {
391- query || ( query = { } )
391+ getQuery ( mapper , query ) {
392+ query = plainCopy ( query || { } )
392393 query . where || ( query . where = { } )
393394
394- forOwn ( query , function ( v , k ) {
395- if ( reserved . indexOf ( k ) === - 1 ) {
396- if ( isObject ( v ) ) {
397- query . where [ k ] = v
395+ forOwn ( query , function ( config , keyword ) {
396+ if ( reserved . indexOf ( keyword ) === - 1 ) {
397+ if ( isObject ( config ) ) {
398+ query . where [ keyword ] = config
398399 } else {
399- query . where [ k ] = {
400- '==' : v
400+ query . where [ keyword ] = {
401+ '==' : config
401402 }
402403 }
403- delete query [ k ]
404+ delete query [ keyword ]
404405 }
405406 } )
406407
@@ -534,8 +535,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
534535 * @method
535536 * @return {Object }
536537 */
537- getQueryOptions ( Resource , query ) {
538- query = query || { }
538+ getQueryOptions ( mapper , query ) {
539+ query = plainCopy ( query || { } )
539540 query . orderBy = query . orderBy || query . sort
540541 query . skip = query . skip || query . offset
541542
@@ -578,7 +579,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
578579 */
579580 getOpt ( opt , opts ) {
580581 opts || ( opts = { } )
581- return isUndefined ( opts [ opt ] ) ? this [ opt ] : opts [ opt ]
582+ return isUndefined ( opts [ opt ] ) ? plainCopy ( this [ opt ] ) : plainCopy ( opts [ opt ] )
582583 } ,
583584
584585 /**
@@ -588,8 +589,8 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
588589 * @method
589590 * @return {* }
590591 */
591- toObjectID ( Resource , id ) {
592- if ( id !== undefined && Resource . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) && ! ( id instanceof ObjectID ) ) {
592+ toObjectID ( mapper , id ) {
593+ if ( id !== undefined && mapper . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) && ! ( id instanceof ObjectID ) ) {
593594 return new ObjectID ( id )
594595 }
595596 return id
@@ -1062,7 +1063,7 @@ addHiddenPropsToTarget(MongoDBAdapter.prototype, {
10621063 *
10631064 * @name MongoDBAdapter#destroy
10641065 * @method
1065- * @param {Object } Resource The Resource .
1066+ * @param {Object } mapper The mapper .
10661067 * @param {(string|number) } id Primary key of the record to destroy.
10671068 * @param {Object } [opts] Configuration options.
10681069 * @param {boolean } [opts.raw=false] Whether to return a more detailed
0 commit comments