UNPKG

@commodo/fields-storage-dynamodb

Version:

We're working hard to get all the docs in order. New articles will be added daily.

60 lines (54 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; const or = { canProcess: ({ key }) => { return key === "$or"; }, process: ({ value, statement }) => { let output = ""; switch (true) { case _.isArray(value): value.forEach(object => { for (const [orKey, orValue] of Object.entries(object)) { if (output === "") { output = statement.process({ [orKey]: orValue }); } else { output += " OR " + statement.process({ [orKey]: orValue }); } } }); break; case _.isPlainObject(value): for (const [orKey, orValue] of Object.entries(value)) { if (output === "") { output = statement.process({ [orKey]: orValue }); } else { output += " OR " + statement.process({ [orKey]: orValue }); } } break; default: throw Error("$or operator must receive an object or an array."); } return "(" + output + ")"; } }; var _default = or; exports.default = _default; //# sourceMappingURL=or.js.map