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

      1. <small id='ahvjK'></small><noframes id='ahvjK'>

        <tfoot id='ahvjK'></tfoot>
          <bdo id='ahvjK'></bdo><ul id='ahvjK'></ul>
        <legend id='ahvjK'><style id='ahvjK'><dir id='ahvjK'><q id='ahvjK'></q></dir></style></legend>

        NoSQL 数据结构,用于使用 Firebase 和查询选择字段

        时间:2023-09-08
          <tbody id='13bPu'></tbody>

        <legend id='13bPu'><style id='13bPu'><dir id='13bPu'><q id='13bPu'></q></dir></style></legend>
          1. <i id='13bPu'><tr id='13bPu'><dt id='13bPu'><q id='13bPu'><span id='13bPu'><b id='13bPu'><form id='13bPu'><ins id='13bPu'></ins><ul id='13bPu'></ul><sub id='13bPu'></sub></form><legend id='13bPu'></legend><bdo id='13bPu'><pre id='13bPu'><center id='13bPu'></center></pre></bdo></b><th id='13bPu'></th></span></q></dt></tr></i><div id='13bPu'><tfoot id='13bPu'></tfoot><dl id='13bPu'><fieldset id='13bPu'></fieldset></dl></div>
            <tfoot id='13bPu'></tfoot>
              • <bdo id='13bPu'></bdo><ul id='13bPu'></ul>

                <small id='13bPu'></small><noframes id='13bPu'>

                  本文介绍了NoSQL 数据结构,用于使用 Firebase 和查询选择字段子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Firebase 创建一个 NoSQL 数据库,但由于我是一名 SQL 思想家,因此我需要一些关于 Firebase 查询和 NoSQL 数据结构的建议.

                  I’m creating a NoSQL database using Firebase, but as I’m a SQL thinker my mind needs some advices about Firebase queries and NoSQL Data Structure.

                  我正在使用 Ionic 2 (AngularJS 2) 为移动应用程序做一些实验,我担心的是速度(用户时间)和我的表格的正确结构.

                  I am making some experiments for a Mobile App using also Ionic 2 (AngularJS 2), and my concerns are about the speed (user time) and the correct structure of my tables.

                  在应用程序中,我列出了用户所做的事情,并且用户可能是组的一部分,现在在 Firebase 网站的非规范化之后,我创建了这个架构

                  In the App I have a list of things that Users have Made and Users could be part of a Group, now following the de-normalization from the Firebase website I made this schema

                  Users : {
                     Id : {
                         Name: string
                         Picture: base64 56x56 pixels (image)
                         Addresses : {}
                         Groups : {
                             Worker: boolean 
                             Student: boolean
                         }
                     }
                  }
                  
                  Groups : {
                    Worker : {
                      Desc: string
                      Members : {
                        Userid: boolean
                      }
                    }
                    Student : {
                      Desc: string
                      Members : {
                        Userid: boolean
                      }
                    }
                  }
                  
                  Made : {
                    Id : {
                      Name: string
                      Thumb: base64 56x56 pixels (image)
                      Desc: string
                      User: userid
                      Images:  base64 dimensions could vary
                    }
                  }
                  

                  我要做的是显示用户所做的事情的列表,其中包含很少的信息,例如名称和拇指图像,单击它会打开带有其他信息的描述.

                  What I have to do is to show a list of things that an user made, with few information like name and thumb image, by clicking on it opens the description with the other infos.

                  现在,如果我使用以下代码段获取列表,它会返回所有信息,但一开始我只需要姓名和拇指(或其他内容)

                  Now if I use the following snippet for getting the list, it returns me all the info but at the beginning I need just name and thumb (or something else)

                  return firebase.database().ref('/made/' + madeId)
                  .once('value').then(function(snapshot) {
                    var username = snapshot.val().username;
                    // ...
                  });
                  

                  那么,firebase 中有什么方法可以做类似(?)的事情:

                  So, is there any way in firebase to do something like(?):

                  SELECT name, thumb FROM Table_Made
                  

                  为了只获取每个查询我需要的字段?或者

                  In order to get only the fields that I need for each query? Or

                  最好有另一个只有名称和图像的表吗?

                  Is better to have another table with only the name and the image?

                  同时拥有拇指和图像是个好主意吗?为了加速json,因为拇指一般比图片小.

                  Is a good idea to have both thumb and the image? In order to speed up the json because the thumb is generally smaller than the image.

                  查看 Firebase 文档,似乎小于 10mb 的图像可以以 base64 格式保存到文档中,以防存储空间更大.您对此有何看法?

                  Looking at Firebase doc, it seems that images smaller than 10mb could be saved as base64 into the document and in case are bigger on the storage. What is your idea about that?

                  推荐答案

                  Firebase 客户端总是检索完整的节点.无法仅获取节点属性的子集.

                  Firebase clients always retrieve complete nodes. There is no way to get just a subset of the properties of a node.

                  像往常一样:如果您在数据模型上实现用例时遇到问题,请更改数据模型以适应您的用例.所以在这种情况下,这意味着您可以将名称和缩略图拆分为一个单独的节点.

                  As usual: if you are having problems implementing your use-case on the data model, change the data model to fit your use-case. So in this case, that means that you could split off the name and thumbnail into a separate node.

                  MadeListinfo : {
                    Id : {
                      Name: string
                      Thumb: base64 56x56 pixels (image)
                    }
                  }
                  

                  这篇关于NoSQL 数据结构,用于使用 Firebase 和查询选择字段子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:根据 Firebase 中的子子项过滤产品 下一篇:Mongoose 多对多

                  相关文章

                  最新文章

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

                  <i id='jsceK'><tr id='jsceK'><dt id='jsceK'><q id='jsceK'><span id='jsceK'><b id='jsceK'><form id='jsceK'><ins id='jsceK'></ins><ul id='jsceK'></ul><sub id='jsceK'></sub></form><legend id='jsceK'></legend><bdo id='jsceK'><pre id='jsceK'><center id='jsceK'></center></pre></bdo></b><th id='jsceK'></th></span></q></dt></tr></i><div id='jsceK'><tfoot id='jsceK'></tfoot><dl id='jsceK'><fieldset id='jsceK'></fieldset></dl></div>
                1. <tfoot id='jsceK'></tfoot>
                  1. <legend id='jsceK'><style id='jsceK'><dir id='jsceK'><q id='jsceK'></q></dir></style></legend>

                    1. <small id='jsceK'></small><noframes id='jsceK'>