简体   繁体   English

Mongodb从嵌入文档的字段填充字段

[英]Mongodb populate field from embeded documents' field

How can i populate data of eventTypeId of eventSettings from embedded document events of mySchema 如何从mySchema的嵌入式文档事件填充eventSettings的eventTypeId数据

    mySchema : {
            events: {
                  eventSettings: [
                      eventTypeId: { type: ObjectId, ref: 'events'}
                  ]
               }
            }

mySchema is mongoose collection name and events is embedded document mySchema是猫鼬集合名称,事件是嵌入式文档

您可以在populate调用中使用点符号来对嵌入式文档执行操作:

MyModel.find().populate('events.eventSettings.eventTypeId').exec(...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 所有文档中的mongoDB +节点更新字段 - mongoDB + Node update field from all documents Mongodb 填充聚合字段 - Mongodb populate aggregated field 查找字段大于嵌入数组长度的文档 - Find documents having a field greater than the length of an embeded array 向所有文档添加字段 MongoDB - Adding a field to all documents MongoDB MongoDB-递归填充文档字段 - MongoDB - Populate document field recursively 将函数应用于从nodejs中的MongoDB查询返回的所有文档的字段 - Apply function to field on all documents returned from MongoDB query in nodejs 如何通过填充字段在猫鼬中查找文档? - How to find documents in mongoose by populate field? MongoDB - 更新集合中的所有文档,使用文档中已存在的另一个字段的值添加新字段 - MongoDB - Update all documents in a collection, adding a new field using value from another field that is already present in the document 将一个新字段添加到集合的所有文档中,将文档字段中的值添加到 MongoDB (Mongoose) 中,记录为 300K+ - Add a new field to all documents of a collection with the value from the document field into MongoDB (Mongoose) with records of 300K+ 在 Node.js 的 MongoDB 文档(带有 MongoClient)中附加一个数组字段,来自另一个字段 - Appending an array field, from another field, in MongoDB documents (with MongoClient) in Node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM