I'm while using MongoDB spend and I have to find some nested elements. My structure appears like this:

 car : { "$ref" : "cars" , "$id" : { "$oid" : "4e8478ace4b0dea06288ad63"}}

I have to arrive at the oid = 4e8478ace4b0dea06288ad63

thx ahead of time

This is actually the structure :

, "driver" : "Test Driver" , "category" : "BUSINESS" , "distanceM" : 216.857 , "mileageKmStart" : 121813.943 , "mileageKmEnd" : 122030.8 , "timestampStart" : , "timestampEnd" : , "vehicle" :

Following a small search around...

mongoexport will represent object ids as "$oid". Are you currently reading through a json file produced by mongoexport? If to ensure that is not the dwelling of the documents when imported (Or it's, however when you make use of a client to speak to mongo it doesn't want you to employ this syntax).

Probably, you would like:

db.x.find({'car.$id': ObjectId('4e8478ace4b0dea06288ad63')})

In the event that is not the situation - take a look within the mongo cli - e.g. run:



db.x.findOne({'car' : {$exists: true}}) // make sure the one I find has a car

If you have handled to produceOrend up with data with illegal secrets - you'll most likely wish to migrate their structure to ensure that you'll be able to query your computer data.

DBRefs really are a convention based on how to produce references to various collections - Note particularly "convention". They are not special (except they're allowed the secrets $ref, $id and $db) by any means - they're yet another resist mongo.