Hi Guys
what would a correct query look like to perform this:
db.employees.updateMany({}, {$set : {“new_field”:"$privileges"}},
{upsert:false,
multi:true})
All attempts places the “stringvalue” and not the field equivalent in the new_field.
on a simple schema like this :
{ _id: ObjectId("604fbebd435c984410df951c"),
name: 'Martin',
age: 43,
phone: { personal: '555-123-123', work: '555-456-456', ext: '5623' },
privileges: 'user',
favorites: { food: 'pizza', artist: 'Picasso' },
finished: [ 18, 12 ],
badges: [ 'black', 'blue' ],
points: [ { points: 78, bonus: 8 }, { points: 57, bonus: 7 } ],
SecurityLog:
[ { Date: 2021-03-15T20:26:56.041Z,
levelgranted: '$ROOT.privileges' } ],
SecurityLog2: [ { date: '$NOW', level: 'user' } ],
Headoffice: { CompanyName: 'MangoHQ', city: 'Cork' },
adress: [ 'Military hill', 'Cork', 'Ireland' ],
new_field: '$privileges' } ]