ObjectID not storing hexadecimal value

谁说我不能喝 提交于 2019-12-20 03:21:16

问题


Originally, my Sails/Mongo was storing the ObjectID in the database as follows:

"_id" : ObjectId("557077fb836bdee256004232")

Not sure what changed or happened, but now new records are being stored as follows:

"_id" : {
    "_bsontype" : "ObjectID",
    "id" : "UtÓ-Åß\u0010C&5",
    "generationTime" : 1434552692
}

This is only occurring in 2 developer environments out of 6.

Things I've checked:

  • Reverted to a stable commit from last week, cleared node_modules, npm cache, etc. Re-installed and no luck.
  • Re-installed Node/npm/MongoDB completely to ensure I'm on the latest stable version of everything... my versions all match existing developer environments that are functioning without issues.

I'd be more than happy to share config/logs if there is anything specific that could help. Environment: Node 0.12.4, npm v2.11.2, MongoDB shell v3.0.4. I've debugged the code and everything to the point that I'm fairly certain it's something unique to my environment and how it interacts with Mongo/Sails/Waterline/BSON.

I'm hoping that this is more of a "Hey I've seen this before and this is how I solved it" question rather than an actual code/debugging question! Thanks!


回答1:


Answering my own question!

Seemed to be something goofy happening with the brew installation of MongoDB. Manually re-installing it from http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ and then restoring my backed up database seemed to do the trick.

I'd still love to know from a from a code/technical standpoint why my environment suddenly decided to start returning the 12-byt BSON ObjectID rather than the Hexadecimal ObjectID... but until then hopefully a simple manual re-install will help others who come across this strange issue!



来源:https://stackoverflow.com/questions/30897147/objectid-not-storing-hexadecimal-value

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