DEV Community

Discussion on: Database seeding in Node.js

Collapse
 
ausmurp profile image
Austin Murphy

I think you should take this article a step further. The most popular use case for seeding is so you know the ID of lookup table values, and can then use enums to account for those value checks in code, like this:

if (someObject.statusId === SomeObjectStatus.Active) {
...
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ausmurp profile image
Austin Murphy

Also, how do you account for when another record needs added to this lookup table, another status. How can the seed script run and only insert the new values? This is built into some ORMs like Entity Framework, but it would be nice to see this in node as a lot of those ORMs do not have that capability.