Skip to content

Instantly share code, notes, and snippets.

@lovellfelix
Forked from josephdburdick/networks.js
Created April 29, 2016 20:13
Show Gist options
  • Save lovellfelix/ff2dfb34804ced27d8876a95a98f47a7 to your computer and use it in GitHub Desktop.
Save lovellfelix/ff2dfb34804ced27d8876a95a98f47a7 to your computer and use it in GitHub Desktop.
Seeds Mongo database but is immediately removed.
Networks = new Mongo.Collection('networks');
Networks.remove({});
if (Meteor.isServer) {
Networks.allow({
insert: function (userId, doc) {
return true; //userId === doc.userId;
},
update: function (userId, doc, fieldNames, modifier) {
return true; // userId === doc.userId;
},
remove: function (userId, doc) {
return true; // userId === doc.userId;
}
});
}
if (Networks.find().count() === 0){
console.log("No networks. Seeding database...");
var network = function(){
return {
name: Fake.word() + "'s Network",
address: Fake.word() + ' ' +
Fake.fromArray(['Street', 'Road', 'Lane', 'Way', 'Avenue']),
createdAt: new Date().toDateString()
};
};
_(20).times(function(){
// Seed fake networks.
console.log('network: ', network());
// Meteor.call('insertNetwork', network());
Networks.insert(network());
});
console.log(Networks.find().count() + ' networks');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment