Reputation: 5040
I am very new to mongodb. Due to lack of time to study mongodb in depth, I'm asking this question.
Is it possible to create a collection in key-value pattern without using _id.
"1", "2", "3" will act as a key instead of _id.
{
"1": {
"name": "X",
"address": {
"street": "abc",
"zip": 12345
}
},
"2": {
"name": "Y",
"address": {
"street": "efg",
"zip": 12346
}
},
"3": {
"name": "Z",
"address": {
"street": "lmn",
"zip": 12347
}
}
}
EDIT 1: Can I say Mongodb's collection is a array?
Upvotes: 1
Views: 73
Reputation: 5040
After my finding, It seems that Mongodb's collection is a array of documents. So, this is not possible as what I've mentioned in my question.
But I can do something like
{ "_id" : "12345", "3" : { "name" : "krishna" } }
{ "_id" : "123" }
Upvotes: 1