-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I have this object that has an array of hashes representing addresses.
See below:
> db.customers.find(
{"_id":"c098443ae4243643b189fc43e071a0a3"})
{ "_id" : "c098443ae4243643b189fc43e071a0a3", "addresses" : [
,
{ "address1" : "101 Main Street", "city" : "Middle America", "country" : "us", "firstName" : "Matthew", "lastName" : "Fitzgerald", "phone" : "201-406-1869", "phoneExtension" : "111", "postalCode" : "55555", "slug" : "fm8x", "state" : "KS", "type" : "customer" }] }
When I attempt to remove an address using "$pullAll" and unordered hash it does not remove it.
Ex: This fails
> db.customers.update(
,
{ "$pullAll":
{ "addresses":
[
]
}
}
)
Ex: This succeeds
> db.customers.update(
,
{ "$pullAll":
{ "addresses":
[
]
}
}
)
Question: Does the order of keys in javascript hash objects matter or is it a MongoDB specific limitation? And what are the rules for ordering of keys in hashes in MongoDB (is it alphabetical by key). Is it ordered at all?
Regards,
Matt