mongoose
mongoose copied to clipboard
Watching on mongoose document changes is broken after updating to latest version
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
At my backend I use @nestjs/mongosse: "9.0.2" and I have a piece of code which watches for changes as such:
watch.on('change', (change) => {
onChange(
change.fullDocument?.content &&
!change.fullDocument?.read &&
change.fullDocument?.last_sender_id !== userId,
);
});
After trying to update to the latest version of the @nestjs/mongoose package I get the following errors:
Property 'fullDocument' does not exist on type 'ChangeStreamDocument<PostboxRoom>'.
Property 'fullDocument' does not exist on type 'ChangeStreamDropDocument'.
399 !change.fullDocument?.read &&
~~~~~~~~~~~~
It looks like the typing had a breaking change or something similar? How should we access the fullDocument now?
Minimum reproduction code
https://gist.github.com/dimeloper/f4aa77562cc90829c06d52e486f59ab9
Steps to reproduce
No response
Expected behavior
I would expect a more helpful message that would guide me to a solution or a piece of documentation that describes what was the related breaking change.
Package version
9.0.2
mongoose version
6.1.8
NestJS version
9.0.5
Node.js version
No response
In which operating systems have you tested?
- [X] macOS
- [ ] Windows
- [ ] Linux
Other
No response
Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).