NestJS + mongoose + mongoose-audit-trail

Viewed 252

I'm trying to use the 'mongoose-audit-trail' plugin in nestjs, but I'm getting the following error "Operation 'histories.findOne()' buffering timed out after 10000ms"

export const s = SchemaFactory.createForClass(Product);
s.plugin(require('mongoose-audit-trail').plugin);

Apparently there seems to be something in the connection that you couldn't use!

Or if anyone has any tips on another plugin for @nest to generate change histories I'd appreciate it!

1 Answers

I have recently been working on something similar. I had a problem where I couldn't get existing audit plugins working with nestjs and some of the stuff I have been working on.

I forked an existing library, and my plan is to merge it back and contribute to the original project. However, work has been crazy so not had a chance to finish it.

Maybe this can help you, if you take a look at my recent commits you'll see the modifications I have made.

https://github.com/piercy/mongoose-history-trace/tree/feat/saas

usage wise, you should just be able to use it as a plugin, passing in a few options. From what I can tell, it does work, and does everything you might need for a nestjs, mongoose audit trail.... but it should be noted that while I am working on this, I haven't really tested or put it into a production environment yet.

You are welcome to use this or even finish it off if you want. Sorry I couldn't just give you a plugin to use but hopefully this helps get you in the right direction.

Original Library is here: https://github.com/WelingtonMonteiro/mongoose-history-trace

Related