I would like to know how to run mongoimport
to import a JSON file into Meteor app’s MongoDB, and not use ObjectId
in the _id
fields.
I have a JSON array file seed.json
that I sometimes import to my database. I run:
mongoimport --db myApp --collection myCollection --drop --file seed.json --jsonArray
The data is imported without problem. But the documents use ObjectId
in _id
fields rather than just a string. This means I can’t find the documents by _id
because Meteor expects _id
to be string. So I made a makeshift method that does the following:
...
let data = JSON.parse(Assets.getText('seed.json'));
data.forEach(elm => {
MyCollection.insert(elm);
});
...
But is there a way that I can use mongoimport or something equivalent instead?