I am trying to fetch name and price property of a collection from MongoDB and I got output like this.
When I fetched name property then it shows correct value, but when I fetched price property then I got undefined value.
Note: i don't want to fetch all the properties which available on total. i just want to fetch price property of an object which is on first index of an array
Here is the code of service-:
async total(){
const total= await this.usersmodel.find().exec()
try{
//return total[0].name
console.log(total[0].name)
console.log(total[0].price)
}
catch(error){
return error.message
}
}
Here is the code of controller-:
@Post('total')
async total(){
return this.usersService.total();
}
}

return await this.usersService.total();?console.log(total)show you?