I hope this helps.
After executing `node seed.js``
I checked MongoDB Compass and the Users table was missing.
Found this solution on Github and I am so thankful to Ondrovic for posting the solution there([seed.js does not populate users · Issue #10 · mosh-hamedani/vidly-api-node · GitHub])
I am pasting the same solution here
Solution:
I managed to get this working directly from the seed.js . You will need to make the following changes
Top near the other const’s
const { User } = require("./models/user");
Before the seed()
const dataUsers = [ { name: "Seed User", email: "[email protected]", password: "password", }, ];
Inside seed() before 1st for
await User.deleteMany({});
Inside seed() before mongoose.disconnect()
for (let user of dataUsers) { await new User({ name: user.name, email: user.email, password: user.password, }).save(); }
No more manual creating from the 1st step