I need an advice about NoSQL/MongoDb and data/models structure

前端 未结 5 1168
醉梦人生
醉梦人生 2021-02-05 14:30

Recently I\'m exploring NoSQL Databases. I need an advice about how to store data in the most optimal and efficient way for a given problem. I\'m targeting MongoDB, now. However

5条回答
  •  猫巷女王i
    2021-02-05 15:16

    In CouchDB this is very simple. One view emits:

    function(doc) {
     if(doc.type == "vote") {
       emit(doc.story_id, doc.user_id);
     }
    }
    

    Another view emits:

    function(doc) {
     if(doc.type == "vote") {
       emit(doc.user_id, doc.story_id);
     }
    }
    

    Both are queries extremely fast since there is no join. If you do need user data or story data, CouchDB supports multi-document fetch. Also quite fast and is one way to do a "join".

提交回复
热议问题