What I'm trying to do is pretty simple, but I can't find out how to give one field the value of another.
I just want to update one field with the number of characters of another.
db.collection.update({$exists:true},{$set : {field1 : field2.length}})
I tried to give it a dot notation
db.collection.update({$exits:true},{$set : {field1: "this.field2.length"}})
Also using javascript syntax
db.collection.update({$exits:true}, {$set : {field1: {$where : "this.field2.length"}})
But just copied the line and got "notOkforstorage" accordingly. Any help?
Update: I only get "notOkforStorage" when I request by ID:
db.collection.update({_id:ObjectID("38289842bbb")}, {$set : {field1: {$where :"this.field2.length"}}})
jwillis0720
source share