简体   繁体   English

如何通过Jade和NodeJS访问嵌入式Mongodb文档?

[英]How do I access embedded Mongodb document through Jade and NodeJS?

I can obtain a non embedded field from my document through jade by doing: 通过执行以下操作,我可以通过jade从文档中获取非嵌入式字段:

each user, i in gauss_buff
   tr
   td #{user.build_num} // where build_num is an element in my document.

However, how should one access an embedded document via Jade. 但是,如何通过Jade访问嵌入式文档。 Doing user.embedded_doc_name.field didn't work. 做user.embedded_doc_name.field不起作用。

I used #{user.not_embedded_field} and I receive: 我使用#{user.not_embedded_field}并收到:

{
  "not_embedded_field" : not_embedded_field_value,
  "embedded_document": [{
         "embedded_field1" : some_value
         "embedded_field2" : some_other_value

I have hunted around, but can't find how to do this anywhere. 我到处搜寻,但是找不到任何地方该怎么做。 Any tips would be appreciated. 任何提示将不胜感激。

然后像数组一样使用它: #{user.embedded_document[0].embedded_field1}

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

相关问题 用玉获取mongoDB中嵌入式文档的长度 - get length of embedded document in mongoDB with jade 如何通过 NodeJS MongoDB 查询访问坐标值? - How would I access the values of the coordinates through a NodeJS MongoDB query? 如何在Graphql nodejs中解析用于查询的mongodb嵌入式文档数组 - How to resolve mongodb embedded document array of object for query in Graphql nodejs 使用nodejs在mongodb中插入嵌入式文档 - insert embedded document in mongodb using nodejs MongoDB,NodeJS:使用新成员更新嵌入式文档 - MongoDB, NodeJS: updating an embedded document with new members 在nodejs中,如何在嵌入的mongodb文档之间遍历以获取其键的值 - In nodejs, how do I traverse between embedded mongodb documents to get the values of their keys 如何使用Mongoose将值推入MongoDB中嵌入式文档中的数组? - How do I $push a value to an array within an embedded document in MongoDB using Mongoose? 如何从Mongodb到Mongoose的嵌套文档中获取Nodejs中的数组? - How to get an Array in Nodejs from a nested document in Mongodb through Mongoose? 如何在Jade中遍历JavaScript对象? - How do I loop through JavaScript objects in Jade? find() 如何访问文档字段以进行操作? (MongoDB,nodeJS) - How can a find() access a document field for an operation? (MongoDB, nodeJS)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM