UNPKG

@signaldb/core

Version:

SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in

43 lines (42 loc) 815 B
"use strict"; const expressionKeys = /* @__PURE__ */ new Set([ "$eq", "$gt", "$gte", "$lt", "$lte", "$in", "$nin", "$ne", "$exists", "$not", "$expr", "$jsonSchema", "$mod", "$regex", "$options", "$text", "$where", "$all", "$elemMatch", "$size", "$bitsAllClear", "$bitsAllSet", "$bitsAnyClear", "$bitsAnySet" ]); function isFieldExpression(expression) { if (typeof expression !== "object" || expression == null) { return false; } const keys = Object.keys(expression); if (keys.length === 0) { return false; } const hasInvalidKeys = keys.some((key) => !expressionKeys.has(key)); if (hasInvalidKeys) return false; const hasValidKeys = keys.every((key) => expressionKeys.has(key)); return hasValidKeys; } module.exports = isFieldExpression;