Skip to content
Snippets Groups Projects
Commit 70ab510c authored by Prathviraj Suryakant Thokal's avatar Prathviraj Suryakant Thokal
Browse files

did changes in multiple seed function

parent 8f7de0be
No related branches found
No related tags found
1 merge request!6did changes in multiple seed function
......@@ -116,6 +116,7 @@ export const seedWithRelation = async <
export type ForeignKeyConfig<ChildType> = {
parentModel: keyof PrismaClient;
parentLookupKey: string;
parentPrimaryKey?: string;
childReferenceKey: keyof ChildType;
childForeignKeyField: keyof ChildType;
};
......@@ -141,7 +142,8 @@ export const seedWithMultipleParents = async <
const map = new Map<any, any>();
for (const parent of parents) {
map.set(parent[fk.parentLookupKey], parent.id);
const id = fk.parentPrimaryKey ?? "id";
map.set(parent[fk.parentLookupKey], parent[id]);
}
lookupMaps[String(fk.parentModel)] = map;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment