So I have a collection called dummyCollection where I’ve defined two string properties called username and passoword. Username is declared as string and password as binData. I want to use these two to create a new property called user which would serve as a key value map. I want to update the exisiting collections in the data base so that the current value for username and password would be used to construct this new users object. This doesn’t seem to work. Instead, the values from username and password are copied as string literal. Unfortunately, I can only do update via runCommand. Anything I’m doing wrong here?
{
"update": "dummyCollection",
"updates":
[
{
"q":
{
"username":
{
"$exists": true
},
"password":
{
"$exists": true
}
},
"u":
{
"$set":
{
"users.dummyUser":
{
"username": "$username",
"password": "$password"
}
}
},
"multi": true
}
]
}