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="735xn7f" 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="jzx7ld7" id='VApZH'><tfoot id='VApZH'></tfoot><dl id='VApZH'><fieldset id='VApZH'></fieldset></dl></div>

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

                  問題描述

                  我使用 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 記錄以獲得層次結構?

                  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:

                  假設您有一個 User 架構來跟蹤用戶的朋友.

                  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 選項來告訴 mongoose 填充所有用戶朋友的 friends 數組:

                  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-填充

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

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

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                  Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標記的緯度和經度)
                      <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="dntl7pp" 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>
                            主站蜘蛛池模板: 乐考网-银行从业_基金从业资格考试_初级/中级会计报名时间_中级经济师 | 洁净棚-洁净工作棚-无菌室-净化工程公司_北京卫护科技有限公司 | ICP备案查询_APP备案查询_小程序备案查询 - 备案巴巴 | 喷漆房_废气处理设备-湖北天地鑫环保设备有限公司 | 气动隔膜阀_气动隔膜阀厂家_卫生级隔膜阀价格_浙江浙控阀门有限公司 | 底部填充胶_电子封装胶_芯片封装胶_芯片底部填充胶厂家-东莞汉思新材料 | 哈希余氯测定仪,分光光度计,ph在线监测仪,浊度测定仪,试剂-上海京灿精密机械有限公司 | 天津次氯酸钠酸钙溶液-天津氢氧化钠厂家-天津市辅仁化工有限公司 | 拖鞋定制厂家-品牌拖鞋代加工厂-振扬实业中国高端拖鞋大型制造商 | 中天寰创-内蒙古钢结构厂家|门式刚架|钢结构桁架|钢结构框架|包头钢结构煤棚 | 深圳市宏康仪器科技有限公司-模拟高空低压试验箱-高温防爆试验箱-温控短路试验箱【官网】 | 泥沙分离_泥沙分离设备_泥砂分离机_洛阳隆中重工机械有限公司 | 冷藏车-东风吸污车-纯电动环卫车-污水净化车-应急特勤保障车-程力专汽厂家-程力专用汽车股份有限公司销售二十一分公司 | 皮带机-带式输送机价格-固定式胶带机生产厂家-河南坤威机械 | 世纪豪门官网 世纪豪门集成吊顶加盟电话 世纪豪门售后电话 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 大连海岛旅游网>>大连旅游,大连海岛游,旅游景点攻略,海岛旅游官网 | 台式低速离心机-脱泡离心机-菌种摇床-常州市万丰仪器制造有限公司 | 钢托盘,铁托盘,钢制托盘,镀锌托盘,饲料托盘,钢托盘制造商-南京飞天金属13260753852 | 皮带机_移动皮带机_大倾角皮带机_皮带机厂家 - 新乡市国盛机械设备有限公司 | 琉璃瓦-琉璃瓦厂家-安徽盛阳新型建材科技有限公司| 开业庆典_舞龙舞狮_乔迁奠基仪式_开工仪式-神挚龙狮鼓乐文化传媒 | 合肥卓创建筑装饰,专业办公室装饰、商业空间装修与设计。 | 水质监测站_水质在线分析仪_水质自动监测系统_多参数水质在线监测仪_水质传感器-山东万象环境科技有限公司 | 空气能采暖,热泵烘干机,空气源热水机组|设备|厂家,东莞高温热泵_正旭新能源 | 执业药师报名条件,考试时间,考试真题,报名入口—首页 | 深圳善跑体育产业集团有限公司_塑胶跑道_人造草坪_运动木地板 | 集菌仪_智能集菌仪_全封闭集菌仪_无菌检查集菌仪厂家-那艾 | 涡轮流量计_LWGY智能气体液体电池供电计量表-金湖凯铭仪表有限公司 | 工业车间焊接-整体|集中除尘设备-激光|等离子切割机配套除尘-粉尘烟尘净化治理厂家-山东美蓝环保科技有限公司 | 四川成都干燥设备_回转筒干燥机_脉冲除尘器_输送设备_热风炉_成都川工星科机电设备有限公司 | 泥沙分离_泥沙分离设备_泥砂分离机_洛阳隆中重工机械有限公司 | 金属清洗剂,防锈油,切削液,磨削液-青岛朗力防锈材料有限公司 | 进口试验机价格-进口生物材料试验机-西安卡夫曼测控技术有限公司 | 淘气堡_室内儿童乐园_户外无动力儿童游乐设备-高乐迪(北京) | 众品地板网-地板品牌招商_地板装修设计_地板门户的首选网络媒体。 | 电车线(用于供电给电车的输电线路)-百科 | 电销卡 防封电销卡 不封号电销卡 电话销售卡 白名单电销卡 电销系统 外呼系统 | 济南网站建设_济南网站制作_济南网站设计_济南网站建设公司_富库网络旗下模易宝_模板建站 | 数显水浴恒温振荡器-分液漏斗萃取振荡器-常州市凯航仪器有限公司 | 大倾角皮带机-皮带输送机-螺旋输送机-矿用皮带输送机价格厂家-河南坤威机械 |