Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

fix(custom_types): fix custom types on storage provider (#721)

Guy Ben-Aharonbeb015194f91
diff --git a/src/context/storage-context/storage-provider.tsx b/src/context/storage-context/storage-provider.tsx
index f0273662..0b6543bf 100644
--- a/src/context/storage-context/storage-provider.tsx
+++ b/src/context/storage-context/storage-provider.tsx
@@ -267,11 +267,13 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
includeRelationships?: boolean;
includeDependencies?: boolean;
includeAreas?: boolean;
+ includeCustomTypes?: boolean;
} = {
includeRelationships: false,
includeTables: false,
includeDependencies: false,
includeAreas: false,
+ includeCustomTypes: false,
}
): Promise<Diagram[]> => {
let diagrams = await db.diagrams.toArray();
@@ -312,6 +314,15 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
);
}
+ if (options.includeCustomTypes) {
+ diagrams = await Promise.all(
+ diagrams.map(async (diagram) => {
+ diagram.customTypes = await listCustomTypes(diagram.id);
+ return diagram;
+ })
+ );
+ }
+
return diagrams;
};
@@ -383,6 +394,13 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
.where('diagramId')
.equals(id)
.modify({ diagramId: attributes.id }),
+ db.areas.where('diagramId').equals(id).modify({
+ diagramId: attributes.id,
+ }),
+ db.db_custom_types
+ .where('diagramId')
+ .equals(id)
+ .modify({ diagramId: attributes.id }),
]);
}
};