Skip to content

Separate mongoose and connection in options param #29

@antonio-spinelli

Description

@antonio-spinelli

I found a problem installing plugin to a Schema when I use it with NestJs/Mongoose. The only instance that I can access is the Connection mongoose class and it's not fully compatible with the mongoose option needed by the plugin.
I use an ugly way to solve this in my project:

constructor(@InjectConnection() private readonly connection: Connection) {}

...

;(this.connection as any).Schema = mongoose.Schema
schema.plugin(MongooseHistoryPlugin({mongoose: this.connection}))

Can you split those 2 in options or use require mongoose for static Schema calls and ask only for connection instance?
Both options will not generate breaking changes.
I can make a PR if you want.

PS: a typescript interface with all new document methods will be cool

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions