I have a document like the following
{ prices: [ { taxes: { name: 'Tax 1' } }, { taxes: { name: 'Tax 2' } } ] }
but i want to convert the taxes
field to an array of objects, something like the following
{ prices: [ { taxes: [{ name: 'Tax 1' }] }, { taxes: [{ name: 'Tax 2' }] } ] }
Im having troubles doing so, as mongo wont let me do this
collection.updateOne({ ‘prices.0.taxes’: { $exists: true, $ne: null } }, [ { $set: { ‘prices.0.taxes’: [‘$prices.0.taxes’] } } ])