mongoose-soft-delete icon indicating copy to clipboard operation
mongoose-soft-delete copied to clipboard

Type `Test` does not satisfy the constraint `Document<any, any, any>`.

Open juliojordan opened this issue 8 months ago • 0 comments

Mongoose removed support for extends Document

Removed LeanDocument and support for extends 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.

juliojordan avatar Jun 28 '24 09:06 juliojordan