【发布时间】:2021-06-15 21:13:08
【问题描述】:
假设我有一个包含多个插槽的库存的用户架构。如何将这些 slotsimg 和 slottext 字段嵌套在 inventory 字段中?
例如这样:
const UserSchema = new mongoose.Schema({
Inventory: {
slot1img: {
type: String,
},
slot1text: {
type: String,
},
slot2img: {
type: String,
},
slot2text: {
type: String,
},
slot3img: {
type: String,
},
},
});
但是,如果我这样尝试,它根本不会出现在数据库中,那么我该怎么做呢?
【问题讨论】:
-
Schema 本身不会显示在数据库中,您是否保存了文档?
-
@Joe 我知道,是的,我知道。感谢您的帮助,但我已经找到了解决方案。
标签: javascript mongodb nested schema field