@drip_sync/drip
Version:
Scalable incremental sync for MongoDB aggregation pipelines
21 lines (20 loc) • 747 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isOperator = isOperator;
const atoms_1 = require("./atoms");
const invalid_expression_1 = require("./invalid_expression");
function isOperator(e) {
if (!(0, atoms_1.isComposite)(e) ||
Array.isArray(e) ||
e === null ||
!Object.keys(e).some((e) => e.startsWith("$"))) {
return false;
}
const keys = Object.keys(e);
if (keys.length !== 1) {
throw new invalid_expression_1.InvalidExpression("an expression specification must contain exactly one field, the name of the expression.");
}
// Note that scopeOperator will reject this if the
// operator is not recognized / is banned.
return true;
}