These are chat archives for Automattic/mongoose

7th
Feb 2019
Nqsty
@Nqsty
Feb 07 19:04

Hey, I'm having a weird situation with the following:

const notification = new Notification({
  type,
  item: data, // data = { _id: ObjectId(...), a: 1, b: 2 }
});

Where data is another mongoose Model.
Later I try to get notification.item.a and what I get is undefined because notification.item returns the ObjectId.
The issue is that I do the exact same thing at other places and it does what I expect. So is there any rule to when it returns the ObjectId or the object?