I would like to populate my mongo with some test data.
I have defined mongoose models and I was wandering if it was possible to pragmatically create mongo documents using pre defined models.
For example, model Items
var Schema = mongoose.Schema;
var Items = new Schema({
title: { type: String, required: true },
desc: { type: String}
});
Sure, do it in a single-purpose node app. Create a new app that doesn’t use express or whatever web framework, but instead just has your model definition and a connection to your database.
You’ll need a data source of course for the test data, which you could just use a random word generator, like this one: http://james.padolsey.com/javascript/random-word-generator/
Then you’d need to populate the database like this:
Then just run that node app.