I have pet data stored on as a mongodb object as shown below:
{
"_id" : ObjectId("0000439359317900131f111"),
"name" : "Travis",
"description" : "Travis is a support animal",
"petId" : "225123",
"petDetails" : {
"color" : "brown"
}
}
When I try to console.log petDetails (petDetails is a map) object using the following:
const pet = await context.AnimalService.findOne({where:{_id : userSubscription.planId}})
const petDetails = pet.petDetails
console.log('Logging Pet Details', petDetails)
The result is returned as:
Logging Pet Details {
'$__parent': '{\n' +
' _id: 0000439359317900131f111,\n' +
" name: 'Travis',\n" +
" description: 'Travis is a support animal',\n" +
" petId: '225123',\n" +
" petDetails: Map(1) { 'color' => 'brown' },\n" +
' __v: 0,\n' +
'}',
'$__path': 'petDetails',
'$__schemaType': '[object Object]'
How can have petDetails simply returned as an object and not the weird way it is currently formatted?