如何在打字稿界面中存储对象ID属性?



我正在打字稿中实现接口和猫鼬模式。 与以下问题的斗争:

架构应包含以下属性:

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

最新更新