UNPKG

mongoose-diff-tracking

Version:
27 lines (22 loc) 874 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateOperationToJSON = updateOperationToJSON; var _findOperationToJson = require('./find-operation-to-json.js'); var _normalizeQueryCondition = require('./normalize-query-condition.js'); function updateOperationToJSON(_operation) { var operation = _operation; if (operation.$restore != null) { var $restore = {}; Object.keys(operation.$restore).forEach(function (docPath) { return $restore[docPath] = ''; }); operation = Object.assign({}, operation, { $restore: $restore }); } if (operation.$pull != null) { var queryCondition = (0, _findOperationToJson.queryConditionToJSON)((0, _normalizeQueryCondition.normalizeQueryCondition)(operation.$pull)); operation = Object.assign({}, operation, { $pull: queryCondition }); } return operation; }