seanemmer / mongoose-seed

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

seeder.disconnect() is not a function #23

Closed joetidee closed 6 years ago

joetidee commented 6 years ago

If I follow your example:

var seeder = require('mongoose-seed');

// Connect to MongoDB via Mongoose
seeder.connect('mongodb://localhost/sample-dev', function() {

  // Load Mongoose models
  seeder.loadModels([
    'app/model1File.js',
    'app/model2File.js'
  ]);

  // Clear specified collections
  seeder.clearModels(['Model1', 'Model2'], function() {

    // Callback to populate DB once collections have been cleared
    seeder.populateModels(data, function() {
      seeder.disconnect();
    });

  });
});

I get

TypeError: seeder.disconnect is not a function

joetidee commented 6 years ago

Did u forget to bump to v0.3.3 or to re-publish to npm after you added the disconnect function, as I have v0.3.2 and the disconnect function does not exist in the installed module?

joetidee commented 6 years ago

Also, should

Seeder.prototype.disconnect = function disconnect() {
  mongoose.disconnect();
};

be

Seeder.prototype.disconnect = function () {
  mongoose.disconnect();
};

?

seanemmer commented 6 years ago

I just merged your PR and republished as 0.4.1