Discussion

Why is Mongoose Entity Save not working?

When you are working with Mongoose in Node.js, you may have an issue that mongoose entity is not saved. For example;

wallet.tokens = tokens;
await wallet.save();

This happens element of entity is Mixedtype.
Mongoose is an idiot that cannot detect updates when element type is mixed.
So in this case, you can enforce updates by doing below.

wallet.markUpdated(‘tokens’);
await wallet.save();

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *