json - MongoDB: how to select an empty-key subdocument? -


ahoy! i'm having funny issue mongodb and, possibly more in general, json. basically, accidentally created mongodb documents subdocuments contain empty key, e.g. (i stripped objectids make code nicer):

{      "_id" : objectid("..."),      "stats" :          {              "violations" : 0,              "cost" : 170,          },      "parameters" :          {              "" : "../instances/comp/comp20.ectt",              "repetition" : 29,              "time" : 600000          },      "batch" : objectid("..."),      "system" : "linux 3.5.0-27-generic",      "host" : "host3",      "date_started" : isodate("2013-05-14t16:46:46.788z"),      "date_stopped" : isodate("2013-05-14t16:56:48.483z"),      "copy" : false } 

of course problem line:

"" : "../instances/comp/comp20.ectt" 

since cannot value of field. if query using:

db.experiments.find({"batch": objectid("...")}, { "parameters.": 1 }) 

what full content of parameters subdocument. guess . ignored if followed empty selector. json specification (15.12.*) looks empty keys allowed. have ideas how solve that?

is known behavior? there use that?

update tried $rename field, won't work, same reasons. keys end . not allowed.

update filed issue on mongodb issue tracker.

thanks,
tommaso

i have same problem. can select sub-documents this:

db.foo.find({"parameters.":{$exists:true}}) 

the dot @ end of "parameters" tells mongo empty key in sub-document. works me mongo 2.4.x.

empty keys not supported mongo, don't think officially supported, can insert data them. shouldn't using them , should find place in system these keys inserted , eliminate it.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -