久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 国产成人精品综合 | 91精品国产91久久久久游泳池 | 国产精品国产三级国产aⅴ原创 | 欧美精品二区 | 久久毛片网站 | 午夜理伦三级理论三级在线观看 | 九九九视频在线 | 夜夜艹 | 国产一区欧美 | 午夜寂寞影院在线观看 | www.99re| 久久里面有精品 | 午夜私人影院 | 日韩在线精品视频 | 97国产成人 | 综合久久99 | 成人在线视频网 | 视频1区2区 | 亚洲一区欧美一区 | www.99热这里只有精品 | 超碰在线免费 | 中文字幕第一页在线 | 看av网 | 欧美激情国产日韩精品一区18 | 色播99| 伊人网综合在线观看 | 日韩中文一区二区 | 毛片免费观看 | 福利一区二区 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 亚洲中字在线 | 精品国产91亚洲一区二区三区www | 黄a大片 | 爱高潮www亚洲精品 中文字幕免费视频 | 成人在线观看免费 | 日韩电影中文字幕 | 亚洲精品乱码久久久久久蜜桃91 | 亚洲国产高清高潮精品美女 | 色爱区综合 | 精品成人一区 | 国产亚洲一区二区精品 |