- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是场景:我有一个主题列表,每个主题都包含帖子,并且每个帖子都被用户列表“喜欢”。因此我的数据看起来像这样:
"topics": {
"topic1": {
"posts": {
"post1": true,
"post2": true
}
}
},
"posts": {
"post1": {
"title": "An awesome post",
"likes": {
"user1": true
}
},
"post2": {
"title": "An even better post",
"likes": {
"user1": true,
"user2": true
}
}
},
"users": {
"user1": {
"name": "Mr. T",
"email": "t@t.com"
},
"user2": {
"name": "Mr. Hello World",
"email": "hello@world.com"
}
}
Firebase.util.intersection(
fb.child('topics').child('topic1').child('posts'),
fb.child('posts')
)
最佳答案
See a working example here
这种非规范化的要点是在您抓取帖子时获取用户。没有什么比听起来更复杂的了。去抓他们吧。
Firebase 在内部做了大量工作来优化请求,并为所有监听器重新使用相同的套接字连接,因此这是非常高效的——几乎没有比下载的字节量更多的开销,无论它们是否被分成单独的路径或存储在一起。
HTML:
<h3>Normalizing user profiles into posts</h3>
<ul ng-controller="ctrl">
<li ng-repeat="post in posts | orderByPriority" ng-init="user = users.$load(post.user)">
{{user.name}}: {{post.title}}
</li>
</ul>
var app = angular.module('app', ['firebase']);
var fb = new Firebase(URL);
app.controller('ctrl', function ($scope, $firebase, userCache) {
$scope.posts = $firebase(fb.child('posts'));
$scope.users = userCache(fb.child('users'));
});
app.factory('userCache', function ($firebase) {
return function (ref) {
var cachedUsers = {};
cachedUsers.$load = function (id) {
if( !cachedUsers.hasOwnProperty(id) ) {
cachedUsers[id] = $firebase(ref.child(id));
}
return cachedUsers[id];
};
cachedUsers.$dispose = function () {
angular.forEach(cachedUsers, function (user) {
user.$off();
});
};
return cachedUsers;
}
});
关于firebase - 如何加入在 Firebase 中深入两级以上的非规范化数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23123269/
我正在寻找一个库函数来规范化 Python 中的 URL,即删除路径中的“./”或“../”部分,或添加默认端口或转义特殊字符等。结果应该是指向同一网页的两个 URL 唯一的字符串。例如 http:/
我有 2 个版本的 XSD 文件,我想看看它们之间做了哪些更改。不幸的是,发布者选择完全重写 XSD,更改元素、属性、命名空间前缀等的顺序。是否有工具(命令行或 GUI)可以将它们转换为我可以使用的规
我一直在想,同时使用 normalize.css 和某种 CSS 重置会不会有什么大问题?我一直在四处挖掘,我遇到的所有文章都只是以非此即彼的方式谈论它们,而没有谈及将两者结合起来。 诚然,我在规范化
这对我来说是一个新话题,我已经阅读了几篇文章,但我仍然不清楚,甚至不确定以下问题是否与这篇文章的标题有关。 我的系统向用户发送数据。用户可以选择通过以下方式发送数据: XML 电子邮件 发布 根据用户
我正在从设计不佳的旧数据库升级到新数据库。在旧数据库中有带有字段 Id 和 Commodities 的 tableA。 Id 是主键,包含一个 int,Commodities 包含一个逗号分隔的列表。
假设我有包含此字符串的 Apache Solr 索引文档: Klüft skräms inför 我希望能够使用此关键字通过搜索找到它(注意“u”-“ü”): kluft 有没有办法做到这一点 ? 最
假设您正在处理常规的联系人数据库(您知道...姓名,电话号码,地址,电子邮件等...)。如果您在本地对此感到疑惑,那么一般来说这不是什么大问题,但是当我们查看国际场景时,它就是。 查看电话号码系统,您
尝试在不使用 python 中的任何包的情况下计算 L1 范数 假设我有向量:l = [2.34, 3.32, 6.32, 2.5, 3,3, 5.32] 我想找到这个向量的L1,没有任何包: 我已经
我们拥有 10 年的存档体育数据,分布在不同的数据库中。 尝试将所有数据合并到一个数据库中。由于我们将处理 10 倍的记录数量,因此我现在正在尝试重新设计架构以避免潜在的性能影响。 一项更改是将团队名
我正在使用以下设计为我的网站创建表格 设计1 设计2 由于并非所有注册用户都会尝试挑战,因此设计 1 适合。插入第三个表时,表 2 分数会相应更新。但是 user_id 字段变得多余。 设计 2 中为
我有一个带有字段 json 的表模板。由于 json 对于许多 template 来说可能是相同的 (1:n),我创建了另一个表 template_json 并添加了字段 template_json_
我有一个具有正交投影的 C++/OpenGl/Glut 应用程序。 窗口的宽度为 500 x 500 像素。目前,当鼠标点击发生时,该点将在 (0,0) 和 (500, 500) 之间。 我想获取该点
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我的印象是 JavaScript 解释器假设它正在解释的源代码已经被规范化。什么,规范化到底是做什么的?它不能是文本编辑器,否则源的明文表示会改变。是否有一些执行规范化的“预处理器”? 最佳答案 EC
我被分配了一项任务,但我不确定如何完成它: 我必须构建一个支持多种设备的消息系统,并且它应该尽可能高效。用户最多可以有 10 台设备,当用户收到消息时,所有设备都需要接收消息。 我有两个想法: Tab
我正在尝试将规范化合并到我的数据库设计中,互联网上提供的一些解释让我有点困惑 - 我不确定我是否在朝着正确的方向前进? 到目前为止我有: 用户: id username password 用户配置文件
规范化数据时,是否可以接受在同一张表中重复使用外键? 例如一家 express 公司有一个订单表和一个客户表,订单表会记录从哪个客户那里取件(Customer_ID),并且还会有一列用于说明要交付给哪
用 Java 制作规范形式的 XML 文件的最简单方法是什么?你有一些完成的代码吗?我在网上找到了几个链接,比如 this , this , 和 this ,但我无法让它工作:/ 谢谢, 伊凡 编辑:
在 Python 中是否有标准方法来规范化 unicode 字符串,以便它只理解可用于表示它的最简单的 unicode 实体? 我的意思是,可以将 ['LATIN SMALL LETTER A', '
我知道这个问题已经讨论了很多——但实际上我还没有找到这个问题的最终答案。 我想从我的 VBA(Excel)脚本中的日期“删除”(或更确切地说是标准化)时间。例如。: 20.12.2017 15:16
我是一名优秀的程序员,十分优秀!