Skip to content

Commit

Permalink
fix: read id from data object
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Oct 3, 2023
1 parent f1bd2df commit acd3e6b
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { PrerenderingServiceTenantStorageOperations } from "@webiny/api-prerendering-service/types";
import { Entity } from "dynamodb-toolbox";
import { queryAll } from "@webiny/db-dynamodb/utils/query";
import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup";

export interface CreateTenantStorageOperationsParams {
entity: Entity<any>;
}

interface Tenant {
data: { id: string };
}

export const createTenantStorageOperations = (
params: CreateTenantStorageOperationsParams
): PrerenderingServiceTenantStorageOperations => {
const { entity } = params;

const getTenantIds = async (): Promise<string[]> => {
const tenants = await queryAll<{ id: string }>({
const tenants = await queryAll<Tenant>({
entity,
partitionKey: "TENANTS",
options: {
Expand All @@ -22,10 +25,8 @@ export const createTenantStorageOperations = (
}
});

return cleanupItems(entity, tenants).map(tenant => tenant.id);
return tenants.map(tenant => tenant.data.id);
};

return {
getTenantIds
};
return { getTenantIds };
};

0 comments on commit acd3e6b

Please sign in to comment.