在该文档终于附加的子图表中,为什么?
使用此架构
mongoose.Schema({
world: String,
color: [{ name: String }]
});
给我一个文档,其中包含_id
字段的子文档。
{ _id: 'a9ec8475bf0d285e10ca8d42'
world: 'matrix',
color: [
{ name: 'blue', _id: '4a8c0e12135fa32e13db9ce9' },
{ name: 'red', _id: '4a8c0a62254cd32e13db4ad8' },
{ name: 'white', _id: '4a8c04e2687ea32e13db1da7' }
]
为什么在子图表的情况下,_id
添加/附加的最后一次添加/附加?
是否有办法首先保留_id
在文档中?
Using this schema
mongoose.Schema({
world: String,
color: [{ name: String }]
});
Gives me a document that has sub-documents containing _id
fields.
{ _id: 'a9ec8475bf0d285e10ca8d42'
world: 'matrix',
color: [
{ name: 'blue', _id: '4a8c0e12135fa32e13db9ce9' },
{ name: 'red', _id: '4a8c0a62254cd32e13db4ad8' },
{ name: 'white', _id: '4a8c04e2687ea32e13db1da7' }
]
Why is the _id
added/appended last in the case of the subdocument?
Is there a way to keep _id
first in the document?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将颜色定义为单独的架构,然后在主架构中放置颜色type colorschema
define color as a separate schema as below, then in the main schema put color of type colorSchema