Firebase为以下用户提供的最新Feed [英] Firebase newest feed for following users
问题描述
想象一下,我正在排序这样的用户
$ b $
用户:{
脸书:123456789:{
博客:[{
//博客列表
$ :[{
//博客列表
}],
以下内容:[{
//用户列表auth.ids
}]
}
$ / code>
获取登录的用户博客对象并迭代并推送到数组这个
var blogRef = new Firebase(FirebaseUrl +/ users /+ authData.uid +/ blog);
var userBlog = $ firebaseArray(blogRef);
var userBlogDatas = []
blogRef.limitToLast(10).on(child_added,function(snapshot){
var snap = snapshot.val();
userBlogDatas。推(快照);
});
到目前为止一切正常。但是,我怎样才能从下面的用户提供最新的博客帖子。现在我有一些想法,代表获取用户的博客数据,并推到阵列。我不确定是否正确或不...
我还读了 https://github.com/firebase/firefeed/blob/master/ www / js / firefeed.js 代码,但我无法获取任何信息。
任何想法都将非常有用。
$ b
谢谢
如果我理解这个问题,有两种方法可以做到这一点正确的。
一种方法是,不是存储user_id,而是将用户标识存储为键,将标识存储为
用户
脸书:123456789
博客
//博客列表
跟随
user_id_0:blog_id_x
U ser_id_1:blog_id_y
然后,您可以在以下节点的每个博客中添加观察者。您可以从键/值对中获取路径。在这种情况下,Facebook:123456789如下:
/ users / user_id_0 / blog / blog_id_x
/ users / user_id_1 / blog / blog_id_y
另一个选项是在下面的节点中创建一个包含两个值的子节点: user_id和blog_id。
用户
脸书:123456789
博客
//博客列表
跟随
follow_id_0
userid:user_id_0
blog:blog_id_0
follow_id_1
userid:user_id_0
blog:blog_id_1
在这种情况下,脸书:123456789在user_id_0的博客0和博客1之后。 user_id_0和user_id_1实际上是Facebook:abcdefg用户ID
I'm working with Angularjs and Firebase. Right now I'm new at firebase for this I'm struggling to find solutions for my issues.
Imagine I'm sorting users like this
users:{
facebook:123456789:{
blog: [{
// List of blogs
}],
following: [{
// List of users auth.ids
}]
},
facebook:123456780:{
blog: [{
// List of blogs
}],
following: [{
// List of users auth.ids
}]
}
}
And getting logged in user blog object and iterating and pushing it to the array like this
var blogRef = new Firebase(FirebaseUrl + "/users/" + authData.uid + "/blog");
var userBlog = $firebaseArray(blogRef);
var userBlogDatas = []
blogRef.limitToLast(10).on("child_added", function(snapshot) {
var snap = snapshot.val();
userBlogDatas.push(snap);
});
So far everything working fine.
But how can i get latest blogposts from feeds from following users. Right now I have some idea which represents getting user blog datas and pushing them into array. I'm not sure is it right way or not...
I also read https://github.com/firebase/firefeed/blob/master/www/js/firefeed.js code but I could not get any information for myself.
Any ideas will be really helpfull.
Thank you
There's a couple of ways to do this if I am understanding the question correctly.
One way is that instead of storing the user_id, store the user id as a key and the blog id as the value like
users
facebook:123456789
blog
// List of blogs
following
user_id_0: blog_id_x
user_id_1: blog_id_y
Then you can add an observer to each blog in the following node. You can get the path from the key/value pair. In this case Facebook:123456789 is following:
/users/user_id_0/blog/blog_id_x
/users/user_id_1/blog/blog_id_y
Another option would be to create a child node within the following node that contains two values: the user_id and blog_id.
users
facebook:123456789
blog
// List of blogs
following
follow_id_0
userid: user_id_0
blog: blog_id_0
follow_id_1
userid: user_id_0
blog: blog_id_1
In this case, facebook:123456789 is following user_id_0's blog 0 and blog 1
Note: user_id_0 and user_id_1 are actually Facebook:abcdefg users id's
这篇关于Firebase为以下用户提供的最新Feed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!