Skip to content

Instantly share code, notes, and snippets.

@tgoyer
Last active January 26, 2016 05:12
Show Gist options
  • Save tgoyer/26ccc9f1d00a2e7a7b95 to your computer and use it in GitHub Desktop.
Save tgoyer/26ccc9f1d00a2e7a7b95 to your computer and use it in GitHub Desktop.
Load Data into Mongo / Mongoose using Groceries as an example.
var GroceryItem = require('./model.groceryitem.js');
module.exports = {
load: function() {
[{
name: 'Chips',
purchased: false
}, {
name: "Ice Cream",
purchased: false
}, {
name: "Corn",
purchased: true
}, {
name: "Diapers",
purchased: false
}].forEach(function(item) {
new GroceryItem(item).save();
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment