Skip to content

Commit

Permalink
add includeDependencies in listDiagrams (chartdb#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyb1 authored Oct 11, 2024
1 parent c393b28 commit 492c90f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/context/storage-context/storage-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
options: {
includeTables?: boolean;
includeRelationships?: boolean;
} = { includeRelationships: false, includeTables: false }
includeDependencies?: boolean;
} = {
includeRelationships: false,
includeTables: false,
includeDependencies: false,
}
): Promise<Diagram[]> => {
let diagrams = await db.diagrams.toArray();

Expand All @@ -212,6 +217,15 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
);
}

if (options.includeDependencies) {
diagrams = await Promise.all(
diagrams.map(async (diagram) => {
diagram.dependencies = await listDependencies(diagram.id);
return diagram;
})
);
}

return diagrams;
};

Expand Down

0 comments on commit 492c90f

Please sign in to comment.