Argument must be a string in nodejs

孤者浪人 提交于 2019-11-30 13:51:33

For posterity's sake, this is usually due to compatibility issues between versions of mongo. MongoDB driver 2.2 uses mongodb-core 2.0 (and bson 0.5) whereas MongoDB driver 2.1 uses mongodb-core 1.3 and bson 0.4. If you try to use a MongoDB driver 2.1 ObjectId with MongoDB driver 2.2 you'll get this error.

I have no idea why this is even an answer, but I'll post it.

Previously I had this:

var ObjectId = require('mongodb').ObjectID;

I changed to this:

var ObjectId = require('sails-mongo/node_modules/mongodb').ObjectID;

And somehow that made all the difference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!