In the 2.0.2/2.1.0 shell this is what I get:
> db.bin.insert({_id: new BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv") })
> db.bin.find({_id: new BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv") })
{ "_id" : BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv") }
All looks fine, no?
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
In 2.1.0 you can omit the "new" but that is kind of weird in general
(from a javascript/programming point of view) and mostly not a good
practice but something which is supported all the same for the
user-experience.
https://jira.mongodb.org/browse/SERVER-4093
Hi,
Could you elaborate on what you’re trying to do? ObjectId and BinData are two different things.
Specifically, ObjectId is a method to allow the creation of a unique document ID, since every MongoDB document requires an _id field as its “primary key”. See ObjectId for the details. Note that ObjectId value by itself is not strictly required by MongoDB. You can create a document containing your own _id field, with the restriction that the value of the field must be unique in a collection. See Field Names for more information.
In contrast, BinData is a specific BSON type, along with strings, numbers, arrays, etc. See BSON Specification Version 1.1. The closest SQL equivalent is a BLOB, although it must observe MongoDB’s BSON 16MB document size limit.
Please note that you are replying to a very old thread. If you have a specific issue, could you create a new post with:
Best regards,
Kevin