Is there a way to retrieve a document with one-to-many relationships in a query? When I attempt to do so, I receive the object ID as a reference, but I actually want the full document.
await Schedule.find({});
This code snippet returns:
"schedule": [
{
"_id": "63a4b45275be846cf3ed135d",
"date": "2023-01-01T23:00:00.000Z",
"timeSlots": [
"63a4b45275be846cf3ed134c",
"63a4b45275be846cf3ed134d",
"63a4b45275be846cf3ed134e",]
It currently only returns the object ID, but ideally, it should return:
{
_id: new ObjectId("63a4b45275be846cf3ed134c"),
slot: '11:00',
isBooked: false,
isCompleted: false,
service: 'HAIRCUT',
__v: 0
},
{
_id: new ObjectId("63a4b45275be846cf3ed134d"),
slot: '11:30',
isBooked: false,
isCompleted: false,
service: 'HAIRCUT',
__v: 0
},
{
_id: new ObjectId("63a4b45275be846cf3ed134e"),
slot: '12:00',
isBooked: false,
isCompleted: false,
service: 'HAIRCUT',
__v: 0
},
{
_id: new ObjectId("63a4b45275be846cf3ed1353"),
slot: '14:30',
isBooked: false,
isCompleted: false,
service: 'HAIRCUT',
__v: 0
},
{
_id: new ObjectId("63a4b45275be846cf3ed1351"),
slot: '13:30',
isBooked: false,
isCompleted: false,
service: 'HAIRCUT',
__v: 0
},
Instead of just displaying the object ID.