3

I'm currently bound to using Mockgoose/Mongoose for a small NodeJS demo and have some questions about it's purpose and functionalities.

I'm aware that Mockgoose is a non persistent database deployed to memory in order to avoid an actual DB, but does it still provide basic Database abilities with regards to the ability to store and retrieve Models/Documents? Or is it solely used to gain access to Schemas and Models without basic Database functionalities?

For instance does this code have any effect as far as Saving the Model to the Database in Mockgoose?

var Tank = mongoose.model('Tank', yourSchema);

var small = new Tank({ size: 'small' });
small.save(function (err) {
  if (err) return handleError(err);
  // saved!
})

And then would I be able to retrieve it with?

Tank.find({ size: 'small' })

Or as I stated earlier is the sole purpose of Mockgoose to gain access to Schemas and Models without ANY basic database storing functionalities?

Tony Tyrrell
  • 131
  • 1
  • 7

1 Answers1

1

Mockgoose brings up actual mongod in the background with storage engine set to memory. If you invoke any save function, as long as you didn't start new test run, data will be persisted, and you will be able to run "find" to get it back.

winfinit
  • 11
  • 2