0

I've seen a lot of docs and questions on how to create a field with an existing field's value, but none that I've read explain how to create a field with an existing but nested value.

Here's are two examples of the queries I've tried to run:

db.getCollection('bots').find({name:/PORTER/}).update({ $set: {'theme.css.greeterFontColor' : $theme.css.primaryColor}})
db.getCollection('bots').find({name:/PORTER/}).update({ $set: {'theme.css.greeterFontColor' : '$theme.css.primaryColor'}})

In both cases, a new field hasn't been created.

edit - I disagree that this is a duplicate because that linked question only covers values that aren't nested, and the solutions offered in the answers haven't worked for me.

mdb
  • 229
  • 5
  • 16
  • Possible duplicate of [Update MongoDB field using value of another field](https://stackoverflow.com/questions/3974985/update-mongodb-field-using-value-of-another-field) – Plancke Jun 14 '19 at 02:17
  • see my edit on why i disagree this is a dupe – mdb Jun 14 '19 at 19:05

0 Answers0