dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
16 lines (15 loc) • 698 B
JavaScript
import { Finder } from '../../../../../schema/actions/finder/index.js';
import { Deduper } from '../../../../../schema/actions/utils/deduper.js';
import { joinDedupedConditions } from './utils.js';
export const transformExistsCondition = (schema, condition) => {
const conditions = new Deduper();
const schemaFinder = new 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 joinDedupedConditions(conditions, attributePath);
};