mongodb - Import json file into collection in server code on startup -
i've exported mongodb collection json file on local test machine , want import through meteor.js server side code on startup (after deploying meteor.com site). i'm not finding examples of yet.
thanks
example:
// import data when products collection empty if (products.find().count() === 0) { console.log("importing private/products.json db") var data = json.parse(assets.gettext("products.json")); data.foreach(function (item, index, array) { products.insert(item); }) }
Comments
Post a Comment