I have a mongo collection which has been filled with documents by a program using the Mongo DB C# driver.
If I run a find
client.connect('mongodb://127.0.0.1:27017/foo', function(err, db) {
var things = db.collection('things');
things.find({}, ['ThingId']).limit(1).toArray(function(err, docs) {
console.log(docs[0]);
}
}
and look at what is stored then I see something like
{ _id: 1234235341234, ThingID: { _bsontype: 'Binary', sub_type: 3, position: 16, buffer: <Buffer a2 96 8d 7f fa e4 a4 48 b4 80 4a 19 f3 32 df 8e> }}
I've read the documentation and tried things like:
console.log(mongojs.Binary(docs[i].SessionId.buffer, 3).value());
but I can't print the ThingId as a UUID string to the console
and I definitely can't query on it!
My goal is to query by passing in the GUID strings to find so I can select documents using Ids I know the C# generated (and can see using RoboMongo)
Any help appreciated hugely!
Update: As pointed out by @wes-widner the mongo c# driver team have a UUID helper js file that helps convert between different UUIDs and we use that in RoboMongo to query directly. But the BinData which it uses is only available at the mongo shell and I'm not aware of how to access it using node.
The linked answer shows how to query using uuidHelper and BinData when using the mongo shell essentially what Im asking is how to do that within node