Assigning a value to another field in MongoDB Atlas using Terminal

  Kiến thức lập trình

C:UsersAsus>mongosh –version
1.6.1

date example: {
dispatch: { dispatchAdditionalRate: [], isDispatched: false },
invoiceStatus: true,
generatedInvoice: {
invoiceNumber: 440852,
invoiceDate: ISODate(“2024-03-10T21:37:13.452Z”),
invoiceAmount: 1296,
invoiceTotal: 1296,
invoiceRemarks: ‘Invoice Generated’
},
itemsList: [],
paymentHistory: [],
reasonToCancel: ”,
partyBhara:530.22,
totalBillingAmount: 0
}

what i want is to set the value of totalBillingAmout as the value of partyBhara

Help me to fix it !

i have used update method as

Atlas atlas-zs9ix5-shard-0 [primary] freelance> db.bookings.updateMany( {}, { $set: { totalBillingAmount: $”partyBhara” } })

also used aggregate

db.bookings.aggregate([ { $addFields: { totalBillingAmount: “$partyBhara” } }])

not this not even this

db.bookings.aggregate([ { $set: { totalBillingAmount: { $eq: [“$partyBhara”, “$totalBillingAmount”] } } }])

but nothing worked out.

LEAVE A COMMENT