Skip to content

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

Description

@juliojordan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions