简体   繁体   English

如何在PHP中显示mongodb嵌入式文档的find()结果

[英]how to display find() result of mongodb embedded document in php

{
   "_id": NumberInt(13),
   "name": "vishal",

   "friends": [
     {
       "name1": "vini",
       "count": NumberInt(213) 
   },
   {
       "name1": "sumesh",
       "count": NumberInt(47) 
   }],
   "blog": NumberInt(5) 
}

i need to display the name,name1 of all doc & blog in php , using foreach() i got the parent document "name" but dint get name1& blog ? 我需要使用foreach()在php中显示所有文档和博客的名称,name1,但我得到了父文档“名称”,但是却得到了name1&Blog?

you can try unwind in aggregation pipeline 您可以尝试在聚合管道中展开

db.collection.aggregate([{$unwind:"$friends"}])

Hope it will help 希望对你有帮助

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM