pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='3YxlY'><tr id='3YxlY'><dt id='3YxlY'><q id='3YxlY'><span id='3YxlY'><b id='3YxlY'><form id='3YxlY'><ins id='3YxlY'></ins><ul id='3YxlY'></ul><sub id='3YxlY'></sub></form><legend id='3YxlY'></legend><bdo id='3YxlY'><pre id='3YxlY'><center id='3YxlY'></center></pre></bdo></b><th id='3YxlY'></th></span></q></dt></tr></i><div class="0wgymp5" id='3YxlY'><tfoot id='3YxlY'></tfoot><dl id='3YxlY'><fieldset id='3YxlY'></fieldset></dl></div>
    <tfoot id='3YxlY'></tfoot>
    1. <legend id='3YxlY'><style id='3YxlY'><dir id='3YxlY'><q id='3YxlY'></q></dir></style></legend>

      <small id='3YxlY'></small><noframes id='3YxlY'>

        <bdo id='3YxlY'></bdo><ul id='3YxlY'></ul>

        貓鼬填充嵌入式

        Mongoose populate embedded(貓鼬填充嵌入式)

            <bdo id='VApZH'></bdo><ul id='VApZH'></ul>

            <small id='VApZH'></small><noframes id='VApZH'>

            • <legend id='VApZH'><style id='VApZH'><dir id='VApZH'><q id='VApZH'></q></dir></style></legend>

                <tfoot id='VApZH'></tfoot>

                <i id='VApZH'><tr id='VApZH'><dt id='VApZH'><q id='VApZH'><span id='VApZH'><b id='VApZH'><form id='VApZH'><ins id='VApZH'></ins><ul id='VApZH'></ul><sub id='VApZH'></sub></form><legend id='VApZH'></legend><bdo id='VApZH'><pre id='VApZH'><center id='VApZH'></center></pre></bdo></b><th id='VApZH'></th></span></q></dt></tr></i><div class="ahsvc00" id='VApZH'><tfoot id='VApZH'></tfoot><dl id='VApZH'><fieldset id='VApZH'></fieldset></dl></div>

                  <tbody id='VApZH'></tbody>
                  本文介紹了貓鼬填充嵌入式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我使用 Mongoose.js,無法解決 3 級層次文檔的問題.

                  I use Mongoose.js and cannot solve problem with 3 level hierarchy document.

                  有兩種方法.

                  第一 - 沒有參考.

                  C = new Schema({
                      'title': String,
                  });
                  
                  B = new Schema({
                      'title': String,
                      'c': [C]
                  });
                  
                  A = new Schema({
                      'title': String,
                      'b': [B]
                  });
                  

                  我需要顯示 C 記錄.我如何填充/找到它,只知道 C 的 _id?

                  I need to show C record. How can i populate / find it, knowing only _id of C?

                  我正在嘗試使用:

                  A.findOne({'b.c._id': req.params.c_id}, function(err, a){
                      console.log(a);
                  });
                  

                  但我不知道如何從 returnet 中獲取我需要的僅 c 對象.

                  But i dont know how to get from returnet a object only c object that i need.

                  其次如果使用 refs:

                  C = new Schema({
                      'title': String,
                  });
                  
                  B = new Schema({
                      'title': String,
                      'c': [{ type: Schema.Types.ObjectId, ref: 'C' }]
                  });
                  
                  A = new Schema({
                      'title': String,
                      'b': [{ type: Schema.Types.ObjectId, ref: 'B' }]
                  });
                  

                  如何填充所有 B、C 記錄以獲得層次結(jié)構(gòu)?

                  How to populate all B, C records to get hierarchy?

                  我試圖使用這樣的東西:

                  I was try to use something like this:

                  A
                  .find({})
                  .populate('b')
                  .populate('b.c')
                  .exec(function(err, a){
                      a.forEach(function(single_a){
                          console.log('- ' + single_a.title);
                          single_a.b.forEach(function(single_b){
                              console.log('-- ' + single_b.title);
                              single_b.c.forEach(function(single_c){
                                  console.log('--- ' + single_c.title);
                              });
                          });
                      });
                  });
                  

                  但它會為 single_c.title 返回 undefined.我有辦法填充它嗎?

                  But it will return undefined for single_c.title. I there way to populate it?

                  謝謝.

                  推薦答案

                  在 Mongoose 4 中,您可以跨多個級別填充文檔:

                  In Mongoose 4 you can populate documents across multiple levels:

                  假設(shè)您有一個 User 架構(gòu)來跟蹤用戶的朋友.

                  Say you have a User schema which keeps track of the user's friends.

                  var userSchema = new Schema({
                    name: String,
                    friends: [{ type: ObjectId, ref: 'User' }]
                  });
                  

                  首先populate() 讓你得到一個用戶好友列表.但是,如果您還想要用戶的朋友的朋友怎么辦?在這種情況下,您可以指定 populate 選項(xiàng)來告訴 mongoose 填充所有用戶朋友的 friends 數(shù)組:

                  Firstly populate() lets you get a list of user friends. But what if you also wanted a user's friends of friends? In that case, you can specify a populate option to tell mongoose to populate the friends array of all the user's friends:

                  User.
                    findOne({ name: 'Val' }).
                    populate({
                      path: 'friends',
                      // Get friends of friends - populate the 'friends' array for every friend
                      populate: { path: 'friends' }
                    });
                  

                  取自:http://mongoosejs.com/docs/populate.html#deep-填充

                  這篇關(guān)于貓鼬填充嵌入式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點(diǎn)是否在傳單中的另一個內(nèi)部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標(biāo)記群集圖標(biāo)顏色,繼承其余默認(rèn) CSS 屬性)
                  Trigger click on leaflet marker(觸發(fā)點(diǎn)擊傳單標(biāo)記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認(rèn)加載磁貼顏色?)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側(cè)邊欄)
                  Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標(biāo)記的緯度和經(jīng)度)
                      <tbody id='2Nwka'></tbody>

                      <tfoot id='2Nwka'></tfoot>
                      <legend id='2Nwka'><style id='2Nwka'><dir id='2Nwka'><q id='2Nwka'></q></dir></style></legend>

                    • <i id='2Nwka'><tr id='2Nwka'><dt id='2Nwka'><q id='2Nwka'><span id='2Nwka'><b id='2Nwka'><form id='2Nwka'><ins id='2Nwka'></ins><ul id='2Nwka'></ul><sub id='2Nwka'></sub></form><legend id='2Nwka'></legend><bdo id='2Nwka'><pre id='2Nwka'><center id='2Nwka'></center></pre></bdo></b><th id='2Nwka'></th></span></q></dt></tr></i><div class="gorjj0w" id='2Nwka'><tfoot id='2Nwka'></tfoot><dl id='2Nwka'><fieldset id='2Nwka'></fieldset></dl></div>

                      <small id='2Nwka'></small><noframes id='2Nwka'>

                          • <bdo id='2Nwka'></bdo><ul id='2Nwka'></ul>
                            主站蜘蛛池模板: 探伤仪,漆膜厚度测试仪,轮胎花纹深度尺厂家-淄博创宇电子 | 氢氧化钙设备_厂家-淄博工贸有限公司 | 消泡剂_水处理消泡剂_切削液消泡剂_涂料消泡剂_有机硅消泡剂_广州中万新材料生产厂家 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | 广东泵阀展|阀门展-广东国际泵管阀展览会 | 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 氮化镓芯片-碳化硅二极管 - 华燊泰半导体 | 不锈钢闸阀_球阀_蝶阀_止回阀_调节阀_截止阀-可拉伐阀门(上海)有限公司 | 学生作文网_中小学生作文大全与写作指导 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | 双相钢_双相不锈钢_双相钢圆钢棒_双相不锈钢报价「海新双相钢」 双能x射线骨密度检测仪_dxa骨密度仪_双能x线骨密度仪_品牌厂家【品源医疗】 | 武汉森源蓝天环境科技工程有限公司-为环境污染治理提供协同解决方案 | 密集架-密集柜厂家-智能档案密集架-自动选层柜订做-河北风顺金属制品有限公司 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 丝印油墨_水性油墨_环保油墨油漆厂家_37国际化工 | 杜甫仪器官网|实验室平行反应器|升降水浴锅|台式低温循环泵 | 针焰试验仪,灼热丝试验仪,漏电起痕试验仪,水平垂直燃烧试验仪 - 苏州亚诺天下仪器有限公司 | 闪蒸干燥机-喷雾干燥机-带式干燥机-桨叶干燥机-[常州佳一干燥设备] | SRRC认证_电磁兼容_EMC测试整改_FCC认证_SDOC认证-深圳市环测威检测技术有限公司 | 铁艺,仿竹,竹节,护栏,围栏,篱笆,栅栏,栏杆,护栏网,网围栏,厂家 - 河北稳重金属丝网制品有限公司 山东太阳能路灯厂家-庭院灯生产厂家-济南晟启灯饰有限公司 | 苏州防水公司_厂房屋面外墙防水_地下室卫生间防水堵漏-苏州伊诺尔防水工程有限公司 | 臻知网大型互动问答社区-你的问题将在这里得到解答!-无锡据风网络科技有限公司 | 聚合甘油__盐城市飞龙油脂有限公司 | 二手回收公司_销毁处理公司_设备回收公司-找回收信息网 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 培训无忧网-教育培训咨询招生第三方平台 | 超声波清洗机_大型超声波清洗机_工业超声波清洗设备-洁盟清洗设备 | 智慧旅游_智慧景区_微景通-智慧旅游景区解决方案提供商 | 定制液氮罐_小型气相液氮罐_自增压液氮罐_班德液氮罐厂家 | CPSE安博会| PCB接线端子_栅板式端子_线路板连接器_端子排生产厂家-置恒电气 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 多物理场仿真软件_电磁仿真软件_EDA多物理场仿真软件 - 裕兴木兰 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 永嘉县奥阳陶瓷阀门有限公司 | 冷轧机|两肋冷轧机|扁钢冷轧机|倒立式拉丝机|钢筋拔丝机|收线机-巩义市华瑞重工机械制造有限公司 | 数控走心机-走心机价格-双主轴走心机-宝宇百科 | 防爆电机_防爆电机型号_河南省南洋防爆电机有限公司 | 珠海冷却塔降噪维修_冷却塔改造报价_凉水塔风机维修厂家- 广东康明节能空调有限公司 | 聚丙烯酰胺_阴离子_阳离子「用量少」巩义亿腾厂家直销,售后无忧 聚合甘油__盐城市飞龙油脂有限公司 |