1

Could someone explain me why do I have the following result with the following data in my db :

Data in the DB :

{
  "_id": { "$oid" : "4E4BDA5A068E2C5B0E450100" },
  "name" : "john",
  "object" : {
    "A":"1",
    "B":"2"
  },
  "array" : [
    {"A":"1"},
    {"B":"2"}
  ]
}

Query :

db.collection.find( { name : "john" } );

Result :

{ "_id" : ObjectId("4e4bda5a068e2c5b0e450100"), "name" : "john", "object" : { "A" : "1", "B" : "2" }, "array" : [ { "B" : "2" } ] }

Where is my array A:1 ??? Thx for your help.

Mongo 2.0.1

1 Answer 1

2

Something in your syntax must be wrong.

Inserting your doc:

db.free4297.insert({
  "_id": { _id: ObjectId("4E4BDA5A068E2C5B0E450100") },
  "name" : "john",
  "object" : {
    "A":"1",
    "B":"2"
  },
  "array" : [
    {"A":"1"},
    {"B":"2"}
  ]
})

Then:

db.free4297.findOne( { name: "john" } )

{
    "_id" : {
        "_id" : ObjectId("4e4bda5a068e2c5b0e450100")
    },
    "name" : "john",
    "object" : {
        "A" : "1",
        "B" : "2"
    },
    "array" : [
        {
            "A" : "1"
        },
        {
            "B" : "2"
        }
    ]
}
1
  • Well, I still don't understand why, but it seems ok now :/ Nov 26, 2011 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.