I've exported a MongodB collection to a JSON file on my local test machine and want to import it through the Meteor.js server side code on startup (after deploying to a meteor.com site). I'm not finding any examples of this yet.
Thanks
Example:
// import data only when Products collection is empty
if (Products.find().count() === 0) {
console.log("Importing private/products.json to db")
var data = JSON.parse(Assets.getText("products.json"));
data.forEach(function (item, index, array) {
Products.insert(item);
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With