seanemmer / mongoose-seed

Seed data population for Mongoose
MIT License
52 stars 33 forks source link

"TypeError: cb is not a function" when executing the seeds script #9

Closed teckays closed 7 years ago

teckays commented 8 years ago

Executing the seed script it successfully inserts the seeded entry, however, it throws this error

TypeError: cb is not a function

stack:

TypeError: cb is not a function
at /path/node_modules/mongoose-seed/index.js:147:13
at /path/node_modules/mongoose-seed/node_modules/async/lib/async.js:49:16
at done (/path/node_modules/mongoose-seed/node_modules/async/lib/async.js:239:19)
at /path/node_modules/mongoose-seed/node_modules/async/lib/async.js:40:16
at /path/node_modules/mongoose-seed/index.js:144:17
at /path/node_modules/mongoose-seed/node_modules/async/lib/async.js:49:16
at done (/path/node_modules/mongoose-seed/node_modules/async/lib/async.js:239:19)
at /path/node_modules/mongoose-seed/node_modules/async/lib/async.js:40:16
at /path/node_modules/mongoose-seed/index.js:141:21
at Function.<anonymous> (/path/node_modules/mongoose/lib/model.js:3340:16)
at /path/node_modules/mongoose/lib/model.js:1882:14
at /path/node_modules/async/internal/parallel.js:35:9
at /path/node_modules/lodash/before.js:31:21
at iteratorCallback (/path/node_modules/async/eachOf.js:52:13)
at /path/node_modules/async/internal/onlyOnce.js:12:16
at /path/node_modules/async/internal/parallel.js:32:13
AntonKL commented 7 years ago

+1

gtatyous commented 7 years ago

that is because you're calling "seeder.populateModels(data);" without a [callback] function. The example code is doing that as well. To fix it, change the previous line of code to

seeder.populateModels(data, function(){
    //disconnect seeder from mongodb
});

note that seeder does not have a proper function for disconnecting!