这是我的代码:
import mongoose from "mongoose"
export type data = {
name: string
active: boolean
}
export interface document extends mongoose.Document {
name: string,
active: boolean
}
export interface model extends mongoose.Model<document> {
build(attrs: document): document
}
我使用data
作为输出结果的参考,使用document
对于猫鼬模型。
Butdocument
anddata
是相同的!
如何使用data for document来避免这个部分?
{
name: string
active: boolean
}
我试过这种方法,但不适合我:
export interface document extends mongoose.Document = data
export interface document extends mongoose.Document {
data
}
我修改了:
interface document extends mongoose.Document {
name: string,
active: boolean
}
export type data = Omit<document, keyof mongoose.Document>