我正在打字稿中实现接口和猫鼬模式。 与以下问题的斗争:
架构应包含以下属性:
let MovementSchema = new Schema
({
movementName : {type: mongoose.Schema.Types.ObjectId, ref: 'MovementName'},
rounds: [{type: mongoose.Schema.Types.ObjectId, ref: 'Round'}]
});
界面如下所示:
import { ObjectId } from "bson";
export interface IMovement {
movementType : ObjectId,
rounds : [ ObjectId ]
}
问题是,ObjectId
是创建属性的好类型?
而不是ObjectId
它应该存储为string
。