I have a reservation
model in my database. This is how I fetch one entry (Using mongoose),
reservationModel.get_reservation_by_user_id(payload.user.id, function (err, reservations) {
if (err) {
console.log(err);
} else {
console.log(reservations);
console.log(reservations[0].user); // prints undefined
console.log(reservations[0].from); // prints 0900
}
});
Here is the console output.
Dialog Opened sucessful
[ { _id: 5a887a20734d1d041bb6a1f3,
tutor: '5a760a1f734d1d3bd58c8d52',
user: 'U8XDVJD26',
date: 2018-02-17T13:53:45.415Z,
day: 'Saturday',
from: '0900',
to: '1030',
active: 'no' },
{ _id: 5a887bd2734d1d041bb6a24f,
tutor: '5a760a1f734d1d3bd58c8e12',
user: 'U8XDVJD26',
date: 2018-02-17T14:00:45.415Z,
day: 'Saturday',
from: '0930',
to: '1130',
active: 'no' } ]
undefined
0900
How can I get the value of user?