-
-
Save lovellfelix/ff2dfb34804ced27d8876a95a98f47a7 to your computer and use it in GitHub Desktop.
Seeds Mongo database but is immediately removed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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