investorSchema.pre("findOneAndUpdate", async function(done){
if(this._update.money){
try{
const getAllMoney = this.populate('money');
console.log("getAllMoney", getAllMoney)
// const getTotalMoney = await getAllMoney?.map(item => item?.value);
this._update.totalMoney = await getTotalMoney
}catch(e){
console.log(e)
}
}
done()
})
The result i got i have search in that alot but not getting any this field.
getAllMoney Query {
_mongooseOptions: { populate: { money: [PopulateOptions] } },
_transforms: [],
_hooks: Kareem { _pres: Map(0) {}, _posts: Map(0) {} },
_executionStack: null,
mongooseCollection: Collection {
collection: Collection { s: [Object] },
Promise: [Function: Promise],
modelName: 'Investor',
_closed: false,
opts: {
autoIndex: true,
autoCreate: true,
schemaUserProvidedOptions: [Object],
capped: false,
Promise: [Function: Promise],
'$wasForceClosed': undefined
},
name: 'investors',
collectionName: 'investors',
conn: NativeConnection {
base: [Mongoose], ..................