Open danielbayerlein opened 2 years ago
Hey there @danielbayerlein, I created some types for my own use.
mongoose-patch-history.d.ts
declare module "mongoose-patch-history" {
import mongoose = require("mongoose");
export default function (schema: mongoose.Schema, opts: { mongoose: mongoose.Mongoose; name: string }): void;
}
This is the easiest to get it working quickly.
If you want to put some work in and provide typings I'd be happy to review them or extend the missing parts. Unfortunately I don't have that much time currently to implement them myself.
More types added:
declare module 'mongoose-patch-history' {
import type { Operation } from 'fast-json-patch';
import type { Schema } from 'mongoose';
export type MongoosePatchHistoryPatch = {
ops: Operation & { originalValue?: any; }[];
ref: Types.ObjectId;
date: Date;
};
export type MongoosePatchHistoryOptions = {
mongoose: Mongoose;
name: string;
removePatches?: boolean;
transforms?: [(name: string) => string, (name: string) => string];
includes?: Record<string, Record<string, unknown>>;
excludes?: string[];
trackOriginalValue?: boolean;
};
export default function (
schema: Schema,
options: MongoosePatchHistoryOptions,
): void;
}
Thanks for you input! Looks good.
If I might ask for you opinion:
patches
for each mongoose.document
This might be checked with @codepunkt too.
@vinerich I think both points make a lot of sense! Sounds like version 3 of mongoose-patch-history
.
Has anyone created types for
mongoose-patch-history
? Or is something planned?