dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
20 lines (19 loc) • 913 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformExistsCondition = void 0;
const index_js_1 = require("../../../../../schema/actions/finder/index.js");
const deduper_js_1 = require("../../../../../schema/actions/utils/deduper.js");
const utils_js_1 = require("./utils.js");
const transformExistsCondition = (schema, condition) => {
const conditions = new deduper_js_1.Deduper();
const schemaFinder = new index_js_1.Finder(schema);
const { exists } = condition;
const attributePath = condition.attr;
const subSchemas = schemaFinder.search(attributePath);
for (const subSchema of subSchemas) {
const path = subSchema.transformedPath.strPath;
conditions.push({ attr: path, exists });
}
return (0, utils_js_1.joinDedupedConditions)(conditions, attributePath);
};
exports.transformExistsCondition = transformExistsCondition;