Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD - @types/mongoose-history-plugin #28

Open
chrissmithgo opened this issue Oct 13, 2020 · 1 comment
Open

ADD - @types/mongoose-history-plugin #28

chrissmithgo opened this issue Oct 13, 2020 · 1 comment

Comments

@chrissmithgo
Copy link

Would be great to include typescript declaration file for mongoose-history-plugin.

Else...
Anyone already have a TypeScript Ambient Declarations Class file for mongoose-history-plugin ?

@moshtaghi
Copy link

for the future :))

  import { Mongoose, Connection, Types } from 'mongoose'

  export interface MongooseHistoryPluginOptions {
    mongoose: Mongoose
    connection?: Connection
    modelName?: string
    ignore?: string[]
    ignorePopulatedFields?: boolean
  }

  export interface MongooseHistoryPluginDiffItem {
    version: string
    diff: Record<string, [string | Record<string, [string, string]>, string | Record<string, [string, string]>]>
    event: string
    timestamp: string
    user: Types.ObjectId
    data?: unknown
  }

  export interface MongooseHistoryPluginDocumentMethods {
    getDiffs: () => Promise<MongooseHistoryPluginDiffItem[]>
  }

  const mongooseHistoryPlugin: <T>(options: MongooseHistoryPluginOptions) => Schema<Document<T>>

  export default mongooseHistoryPlugin
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants