I want to import data into MongoDB, including reference ID's to set up our tests. I'm using the node-mongo-seeds module.
Some of our data has reference dependencies and I'm stuck in a chicken and egg situation where some of the data needs to have a reference ID in order for things to work.
I've exported the data I need and converted it all to Extended JSON, e.g.
each ObjectID("<id>") becomes { "$oid", "<id>" }
I have tried out the mongodb-extended-json package.
I wish to do something like:
db.collection(collection_name).insert(EJSON.parse(contents), /* callback */)
However its coming back with the error
SyntaxError: Unexpected token o
Which seems to be same error as if the contents had the text BSON representation ObjectId"<id>".
Is there a way to insert data into Mongo in this way?
I've created a fork if anyone wants to have a look with just a minor change: https://github.com/adamski/node-mongo-seeds/commit/266e4aac32032beb75782ece03e163504223e522