Couchdb join two documents using key

后端 未结 2 904
渐次进展
渐次进展 2020-12-06 20:51

I have two documents one with tree structure and the other one relation to the first doc. Im trying to join these two doc`s by fk and pk. I couldnt get the actual results an

2条回答
  •  我在风中等你
    2020-12-06 21:46

    It is much late but For such kind of tree structure, documents should be kept separately such as

    {
      id="firstDoc",
      type="rootLevel"
    }
    {
      id="secondDoc",
      type="firstLevel"
      parent="firstDoc"
    }
    {
      id="thirdDoc",
      type="firstLevel",
      parent="firstDoc"
    }
    

    Now different levels can be joined using the Map Reduce function, Make sure that you will use it in proper way, Also use Logging so that you will be able to know in which sequence map/reduce function are being called by CouchDB.

    Further, map Function should only be used for emitting the required document suppose if you want to to emit your level3 then in emit's value part, root.level1.level2.level3 should be there.

    For more detail about the join you can refer

    CouchDB Join using Views (map/reduce)

提交回复
热议问题