[mongodb-user] left-hand side error

331 views
Skip to first unread message

mongoDB newbie

unread,
Apr 28, 2010, 12:26:46 AM4/28/10
to mongodb-user
Im trying to update a certain part in my database and used this
commands

> var t = db.licpoll.findOne({},{"children.OpeniT.children.license-file.type":true})
> t
{
"_id" : ObjectId("4bd68a6a1205000000000514"),
"children" : {
"OpeniT" : {
"children" : {
"license-file" : {
"type" : "FileName"
}
}
}
}
}
>
>
>
> t.children.OpeniT.children.license-file.type = "sssss";
Wed Apr 28 12:20:49 JS Error: SyntaxError: invalid assignment left-
hand side (shell):0 ---> and i get this error

Im just wondering if there's anything wrong with my syntax. coz as far
as i know its correct
Hope someone help me here..thanks

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Dwight Merriman

unread,
Apr 28, 2010, 12:46:25 AM4/28/10
to mongod...@googlegroups.com
probably the dash which is an operator in javascript, which is what
you are doing here. try:

t.children.OpeniT.children["license-file"].type = "sssss";

or an update() server-side operation with

{ $set : "t.children.OpeniT.children["license-file"].type" : "sssss" }

as a parm

mongoDB newbie

unread,
Apr 28, 2010, 1:29:12 AM4/28/10
to mongodb-user
It worked..however the other entries in the object has been removed.

> db.mydb.findOne()
{
"_id" : ObjectId("4bd68a6a1205000000000514"),
"children" : {
"OpeniT" : {
"children" : {
"license-file" : {
"type" : "sssss",
"name" : "license-file",
"value" : "None"
}
}
}
}
}

it did the update and renamed the "type" : "FileName" to "sssss"
But it deleted the other entries in the object.
FYI:
I am using a tree structure
> > For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/mongodb-user?hl=en.
Reply all
Reply to author
Forward
0 new messages