【发布时间】:2021-01-22 13:30:57
【问题描述】:
我正在尝试运行 MERN 应用程序来验证它有什么,但它在几个文件中向我发送了这个错误。
错误:类型“CatalogType”不满足约束“文档”。 “CatalogType”类型缺少“Document”类型中的以下属性:$ignore、$isDefault、$isDeleted、$isEmpty 和 45 个以上。ts(2344)
我的代码:
const {
Types: { ObjectId },
} = Schema;
export interface CatalogType {
_id: any;
code: string;
description: string;
version: number;
}
export interface CatalogDocumentType extends Document,CatalogType{
_id: number;
}
export const schema = new Schema<CatalogType>(
{
id: {
type: ObjectId,
},
code: {
type: String,
required: true,
},
description: {
type: String,
required: false,
},
version: {
type: Number,
required: false,
},
},
{
timestamps: {
currentTime: () => new TimeZone().getLocaleCSTfromGMT(),
},
},
);
export const Model = model<CatalogDocumentType>('Catalog', schema);
请帮帮我!
【问题讨论】:
标签: node.js mongodb typescript express mongoose