Now i have a libs.json file in my server directory. I want to load it up in my libs collection in order to fill it and the only code that i’ve found to do just that is this: ( I’ve put it in server/startup/loadLibs.js)
Meteor.startup(function () {
var fs = Npm.require("fs");
var Fiber = Npm.require("fibers");
fs.readFile(Assets.getText("libs.json"), 'utf8', function (err, data) {
data = JSON.parse(data);
Fiber(function () {
_.each(data, function (document) {
libs.insert(document);
});
}).run();
});
});
I guess there are a couple of things that i don’t quite get because what happens is that the collection isnt filled up with the json data AND the return of the code above is [Object, Object]…
Loading external json file into a Mongo Collection using Mongoimport following command used: mongoimport --db db_name --collection coll-name --type json --file seed.json --jsonArray
If the specified collection does’t exist, It will be automatically created otherwise appended into existing collection.
This is great that we can read JSON file on server side using JSON.parse(Assets.getText(…) method.
I realized that this is not the right topic for me to ask on this discussion thread, but I really needs to have the ability to read JSON file on client side, because my Meteor app will be running on iPhone and the App needs to be able to load data from json file without internet connection.
I had post message "I have a Meteor app and needs to read data, from a file “/public/_assets/results/mmresults.json”, within the file “/client/controllers.js” in this forum.
I am not looking for a way to browse and select file to upload using the browse button.
Is there a way I can store a local mongo db on an iOS device?
Please provide me suggestions as to what I need to do to read the data from my app’s json file.