typescript - 如何在 Typescript 接口中存储 objectID 属性?
问题描述
我在 Typescript 中实现接口和猫鼬模式。与以下问题的斗争:
Schema 应该包含以下属性:
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
.
推荐阅读
- php - 如何在 Wordpress 上查看特定类别到特定用户 ID
- batch-file - 在 CMDER 中启动命令的批处理文件
- python - 如何在无限循环运行时避免阻塞 tkinter GUI?
- node.js - 在 NodeJs 中更改流以进行弹性搜索
- python - 请求 gmail-api 时出现 HttpError 429:超出用户速率限制
- python - 从 pyspark 的列中删除非英语单词
- ios - 视觉框架 (iOS):VNDetectFaceLandmarksRequest 和 VNDetectFaceRectanglesRequest 有何不同?
- javascript - 从没有 URL.createObjectURL() 的 blob 创建文件的替代方法
- python-3.x - 用函数python替换nan值
- apache-kafka - Kafka Connect - json 路径 - 正则表达式条件不起作用