【发布时间】:2022-01-07 16:36:26
【问题描述】:
我正在尝试创建一个包含名为“business”的条目的架构,它应该是数组类型。
这是我尝试过的。
export interface IBusinessShort{
savedOn: string;
}
export interface IUser {
name: string;
email: string;
username: string;
password: string;
phoneNumber: string;
avatar?: string;
business: Array<IBusinessShort>;
}
const schema = new Schema<IUser>({
name: { type: String, required: true },
email: { type: String, required: true },
username: { type: String, required: true },
password: { type: String, required: true },
phoneNumber: { type: String, required: true },
avatar: String,
business: { type: Array, default: []},
});
我在这里做错了什么?
【问题讨论】:
标签: typescript mongodb mongoose mongoose-schema