javascript - How to Insert records into mongo with Node where records have an $oid -
I'm new to Mongo and node and I'm trying to create a script which essentially works like a rail Does Basically I run the In this way, I can limit this code and then the next developer can run just The problem I have is that I have data from my collection dump, so some sample data from the account looks like this: Now when I run the Is there any way to complete this error or do I have all my .jso Remove all seed.js: Or is there a library which is already such a Is present for work? field names do not begin with a dollar sign ($) character Can. Part of mongodb spec because it is $ $ or $$ like unset rake db: seed work where I have a set of .json files in a specific folder, and when I run the
$ node seed then this is my seed.js file Which will take them all .json files and files based on the filename of the .json file Mixes
$ node seed and it executes the
/ seed .js which is
/seeds/account.json , /
Seed / Customer. Jason , etc.
$ node beed and its Mongo instance can work with some data Will come for you.
{_id : {'$ Oid': '534d832177da4e0d380 00001'}, id: 1, name: some, datetime: '2014-04-15T14: 06: 09-05: 00'}
$ node , I get this error:
[error: key $ OID should not start with '$']
$ oid from n files?
var requires mongoose = 'magos'); mongoose.connect ('MongoDB: // local host / testdb'); Var dir = './seeds'; Var DB = Mongoose Connection; // If any one is db.on ('error', console.error.bind (console, 'database connection error:'), then show connection error; // If we successfully set Mongo DB.ones ('Open', function Callback) {var fs = need ('fs'); // is used to get all the files in a directory // Read all the files folder fs.readdir (dir, function (err, list ) {// If the error is interrupted, then enter the error (error) {console.log ('error:' + err);} // Each file in the list list For .for Ikea (file) Set file name without collection of {// archive archive _name = file.split (".") [0]; var requires parsedJSON = (DIR + '/' + File); (Var i = 0; i & lt; parsedJSON.length; i ++) {// Calculates the number of records in the collection db.collection ('cohort'). Calculation (function (error, calculation) ) {If (err) {console (mistake) {if (err) {console.log (err)}} console.log (record [0]); console.log ("record" + record [0]) Added to the form;}}}}}}}}}}};
Comments
Post a Comment