node.js - Using a value of an document as _id when importing this document to MongoDB using NodeJS -
i'm trying import object mongo. when try use value of object _id fails. error i.e: "[casterror: cast objectid failed value "11563195" @ path "_id"]" , later "[error: document must have _id before saving]" what doing wrong ? // read , import csv file. csv.frompath(filepath, { objectmode: true, headers: keys }) .on('data', function (data) { settimeout(function(){ var obj = new models[filename](data); obj._id = obj.some_id; obj.save(function (err, importedobj) { if (err) { console.log(err); } else { console.log('import: ok'); } }); }, 500); }) here used schema: var mongoose = require('mongoose'); var schema = mongoose.schema; var someschema = new schema( { some_id: string, fie...