@webiny/api-headless-cms-ddb
Version:
DynamoDB storage operations plugin for Headless CMS API.
35 lines (33 loc) • 864 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractWhereParams = void 0;
const extractWhereParams = key => {
const isWbyAco = key.match("wbyAco_") !== null;
const result = key.replace("wbyAco_", "").split("_");
const fieldId = result.shift();
if (!fieldId) {
return null;
}
const rawOp = result.length === 0 ? "eq" : result.join("_");
/**
* When rawOp is not, it means it is equal negated so just return that.
*/
if (rawOp === "not") {
return {
fieldId,
operation: "eq",
negate: true
};
}
const negate = rawOp.match("not_") !== null;
const operation = rawOp.replace("not_", "");
return {
fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
operation,
negate
};
};
exports.extractWhereParams = extractWhereParams;
//# sourceMappingURL=where.js.map