json - 如何使 mongoDB 子文档具有唯一 id 或递增 id?
问题描述
解决了
我有这个 MongoDB 文档:
{
_id: "5e3bf72db5074c1e205409f5",
todos: [
{
title: "title",
description: "description",
state: "state",
priority: "priority"
}
],
title: "test project"
}
我想保留项目的主要 '_id:' 属性,但还要在我的 todos 中添加一个“_id:”或类似的东西,这样我就可以更轻松地单独对它们进行 CRUD 操作。有没有办法为他们制作一个唯一的 id 或自动递增的 id?最终结果将如下所示
有没有办法做到这一点?此外,任何其他建议表示赞赏。
{
_id: another unique id or autoincrement key,
title: "title",
description: "description",
state: "state",
priority: "priority"
}
解决方案
推荐阅读
- reactjs - Next-Redux-Wrapper 不更新 SSR 存储
- dependency-injection - Flutter:(如何)我可以拥有每个依赖于 Provider 的小部件的 PageView 吗?
- cassandra - 基于聚合的日期顶点从不同的顶点获取标签
- python - 如何在python的.txt输出中四舍五入数组格式的数字
- linux - 为什么 crontab 成功运行我的 shell 脚本但无法启动我的二进制文件程序?
- c# - 如何将流从 Naudio 传递到 MS SpeechRecognization?
- angular - 在 TypeScript Angular 中使用 Map() 方法,在函数中返回 Observable 数组
- python - 如何通过 tkinter 发送消息?
- sql - SAS:在时间间隔内选择观察值
- c# - C# - 如果某些方法具有属性 A 但没有属性 B,如何编译失败?