UNPKG

mingo

Version:

MongoDB query language for in-memory objects

27 lines (26 loc) 627 B
import { applyUpdate, DEFAULT_OPTIONS, walkExpression } from "./_internal"; const $currentDate = (expr, arrayFilters = [], options = DEFAULT_OPTIONS) => { const copts = options; return (obj) => { return walkExpression( expr, arrayFilters, options, (val, node, queries) => { return applyUpdate( obj, node, queries, (o, k) => { o[k] = val === true || val.$type === "date" ? copts.now : copts.now.getTime(); return true; }, { buildGraph: true } ); } ); }; }; export { $currentDate };