mingo
Version:
MongoDB query language for in-memory objects
24 lines (23 loc) • 467 B
JavaScript
import {
applyUpdate,
UPDATE_OPTIONS,
walkExpression
} from "./_internal";
const $currentDate = (obj, expr, arrayFilters = [], options = UPDATE_OPTIONS) => {
const now = Date.now();
return walkExpression(expr, arrayFilters, options, (_, node, queries) => {
return applyUpdate(
obj,
node,
queries,
(o, k) => {
o[k] = now;
return true;
},
{ buildGraph: true }
);
});
};
export {
$currentDate
};