How to seed data into Mongo database with mongoose

145 Views Asked by At

I realize this should probably be pretty straightforward but I am hoping someone could point me in the right direction. I am building a schema with mongoose, and I want the schema to have some default values when the program runs. Is this possible to do in the mongoose schema, or do I have to have another file that seeds the database when the program runs? Thanks in advance for any pointers.

Tried to just set default values in mongoose, but it didn't work. The datatype is a string. It's just a schema with one item: A name. I want the database to be seeded with multiple instances of the schema created automatically.

0

There are 0 best solutions below