UNPKG

mongoose-softdelete-typescript

Version:

Mongoose soft deletion plugin for typescript, support transaction

16 lines (15 loc) 781 B
import { ClientSession, Document, FilterQuery, Model, Schema } from 'mongoose'; export interface ISoftDeletedDocument extends Document { isDeleted: Boolean; deletedAt: Date | null; softDelete(session?: ClientSession): Promise<ISoftDeletedDocument>; restore(session?: ClientSession): Promise<ISoftDeletedDocument>; findDeleted(): Promise<any>; } export interface ISoftDeletedModel<T> extends Model<T & ISoftDeletedDocument> { softDelete(conditions: FilterQuery<ISoftDeletedDocument>, session?: ClientSession): Promise<any>; restore(conditions: FilterQuery<ISoftDeletedDocument>, session?: ClientSession): Promise<any>; findDeleted(cond: boolean): Promise<any>; } declare const softDeletePlugin: (schema: Schema) => void; export { softDeletePlugin };