mongoose-soft-delete
mongoose-soft-delete copied to clipboard
Type `Test` does not satisfy the constraint `Document<any, any, any>`.
Mongoose removed support for extends Document
Removed
LeanDocument
and support forextends Document
. - Mongoose > Migrating from 6.x to 7.x.
How to reproduce it?
Removing the extends Document
from the How It Works TypeScript version example.
import * as mongoose from "mongoose";
import { SoftDeleteModel, softDeletePlugin } from "soft-delete-plugin-mongoose";
interface Test {
name: string;
lastName: string;
}
const TestSchema = new mongoose.Schema({
name: String,
lastName: String,
});
TestSchema.plugin(softDeletePlugin);
const testModel = mongoose.model<Test, SoftDeleteModel<Test>>("Test", TestSchema);
You'll get this error.
./index.ts:16:56 - error TS2344: Type 'Test' does not satisfy the constraint 'Document<any, any, any>'.
Type 'Test' is missing the following properties from type 'Document<any, any, any>': $assertPopulated, $clone, $getAllSubdocs, $ignore, and 47 more.
16 const testModel = mongoose.model<Test, SoftDeleteModel<Test>>("Test", TestSchema);
I would appreciate any help. Thx.