amark / mongous

Simple MongoDB driver for Node.js with jQuery like syntax.
MIT License
246 stars 30 forks source link

Support for Object IDs ? #5

Closed joaojeronimo closed 13 years ago

joaojeronimo commented 13 years ago

Hi, great plugin, only one thing missing (i think): support for MongoDB's ObjectIDs(http://www.mongodb.org/display/DOCS/Object+IDs).

Will you be adding it anytime soon ?

Thanks in advance, A lot of people

amark commented 13 years ago

as far as I know MongoDB automatically generates the ObjectID, which can be retrieved from a find() by grabbing the "_id" property. Does this not work?

joaojeronimo commented 13 years ago

It works great if you want to grab the "_id" property, but if you later want to find({'_id' : thatidyougrabbed}) it wont work, I red somewhere you must generate an ObjectID from the hex that comes from grabbing the "_id" property and then use it to match results.

amark commented 13 years ago

from http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol it says that OP_GET_BY_OID code 2003 is no longer in use.

A lot of the BSON decoding/encoding and Object ID stuff is code from node-mongodb-native, which I believe had support for ObjectID and thus should work with Mongous.

If it doesn't though, this probably isn't something I'll fix anytime soon (since my other projects are a higher priority) and cause I suck at BSON stuff. If you could join in and fix this yourself, I'll pull it.

(? this is marked as being closed ? I didn't do this... how do you "unclose" something?)

joaojeronimo commented 13 years ago

Yes, I saw the "hex to ObjectID" function in the node-mongodb-native project earlier today. I wish I could but I suck a lot more than you at BSON :(

amark commented 13 years ago

I thought this function was built in, and thus would work (like pretty much everything else) with mongous. But I guess not, sorry about that. :/