splix
unread,Jul 2, 2010, 6:24:04 AM7/2/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-user
I'm trying to add some values using $set function, but found some
behavior that i don't understand.
What i'm doing:
--------------
> db.contacts.insert({"profile-id" : "test", "actual": {"key1": "val1"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "profile-id" : "test",
"actual" : { "key1" : "val1" } }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.key2": "val2"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2" }, "profile-id" : "test" }
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.001": "val3"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3" }, "profile-id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.002": "val4"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4" }, "profile-
id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.0020000000000000000000": "val5"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4",
"0020000000000000000000" : "val5" }, "profile-id" : "test" }
>
>
> db.contacts.update({"profile-id" : "test"}, {$set: {"actual.0030000000000000000000": "val6"}})
> db.contacts.find({ "profile-id": "test"})
{ "_id" : ObjectId("4c2db755f6ec25d0c44c466a"), "actual" : { "key1" :
"val1", "key2" : "val2", "001" : "val3", "002" : "val4",
"0030000000000000000000" : "val6" }, "profile-id" : "test" }
--------------
All working right, except last operation. As you see at last step key
"0020000000000000000000" was removed, and was replaced by
"0030000000000000000000".
Is it ok? What i'm doing wrong? Maybe it's a bug?
I'm using:
$ mongod --version
db version v1.4.4, pdfile version 4.5
Fri Jul 2 14:02:42 git version:
9dcac11bd72c7cb34ca278313f033efcdd4908eb