我有一个Contact
接口,它扩展了mongoose.Document
接口:
import * as mongoose from 'mongoose';
export interface Contact extends mongoose.Document {
firstname: string;
lastname: string;
address: string;
phone: string;
email: string;
}
有时,我需要像下面这样使用此接口Contact
:
const contacts: Contact[] = [
{
firstname: 'Marley',
lastname: 'Schultz',
address: '531 Walter Roads',
phone: '1-898-444-3407 x33699'
email: 'Deon_Hammes@gmail.com',
}
];
由于Contact
扩展了mongoose.Document
,TypeScript抱怨mongoose.Document
的属性(increment
,model
,isDeleted
,...)丢失了。
是否可以从Contact
获取类型,但排除mongoose.Document
的属性?