UNPKG

@webiny/api-headless-cms-ddb-es

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

35 lines (34 loc) 875 B
import DataLoader from "dataloader"; import { createPartitionKey } from "../keys.js"; import { createBatchScheduleFn } from "./createBatchScheduleFn.js"; export const createGetAllEntryRevisions = params => { const { entity, tenant, modelId } = params; return new DataLoader(async ids => { const results = {}; for (const id of ids) { results[id] = (await entity.queryAllClean({ partitionKey: createPartitionKey({ tenant, id }), options: { beginsWith: "REV#" } })).map(item => { return item.data; }); } return ids.map(entryId => { return (results[entryId] || []).filter(item => { return item.modelId === modelId; }); }); }, { batchScheduleFn: createBatchScheduleFn() }); }; //# sourceMappingURL=getAllEntryRevisions.js.map