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"
        }
    ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

Well, I still don't understand why, but it seems ok now :/

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.