我们正在使用Parse和Firebase为iOS和Android构建实时社交新闻Feed应用。 Parse用于用户管理和推送通知。
要求:
根据兴趣分类,将有多个新闻频道,比如食品,科技,旅游,金融,商业等。
频道管理员可以将文字/图片/视频/音频帖子发布到频道新闻Feed。 用户可以关注一个或多个频道,并且将按照反向时间顺序从他们所关注的频道获得帖子的统一新闻馈送。 他们可以喜欢/喜欢一些帖子。
我们正在寻找一种方法,将来自用户所遵循的所有频道的Feed分组并将其传递给用户的设备。 Pubnub可以使用频道组(https://www.pubnub.com/products/stream-controller/)
实现此目的由于我们正在考虑扩展到安装应用程序的一百万台设备,因此我需要帮助确定Firebase中正确的数据模型才能实现这一目标。
以下是我现在建模的方式:
频道树将存储频道列表以及PostsFeed,其中包含与频道关联的帖子ID。当我们需要显示特定频道的Feed时,这将有所帮助,我们只需要查看一个地方。
实际的帖子将在帖子树中,这也是所有帖子的全球列表。
喜欢作为数组存储在每个帖子中。
{
"Channels": {
"-JwGRWPudmaRwT8dpx40": {
"channelId": "RrHhZCXQkL",
"channelName": "C1",
"PostsFeed": {
"-JwGRWPudmaRwT8dpx79": {
"date": "2015-08-09T07:52:12.GMT"
},
"-JwGRiLa2Nz1vfhWNgFa": {
"date": "2015-08-09T07:52:50.GMT"
}
}
},
"-JwGRWPudmaRwT8dpx50": {
"channelId": "IxyMMJdPjs",
"channelName": "C2",
"PostsFeed": {
"-JwGReVetAxVWWJkc3L4": {
"date": "2015-08-09T07:52:50.GMT"
}
}
},
"-JwGRWPudmaRwT8dpx60": {
"channelId": "ePuAN4qAj7",
"channelName": "C3",
"PostsFeed": {
"-JwGRlNNQkefrr953PgX": {
"date": "2015-08-09T07:53:18.GMT"
}
}
}
},
"Posts": {
"-JwGRWPudmaRwT8dpx79": {
"audio": "",
"audio_duration": 0,
"channelId": "RrHhZCXQkL",
"channelName": "C1",
"channelPicture": "https: //a.cloudfront.net/fgzoFVtexv/channel/7636019341/picture.jpg",
"channelThumbnail": "https: //a.cloudfront.net/fgzoFVtexv/channel/7636019341/thumbnail.jpg",
"date": "2015-08-09T07: 52: 12.GMT",
"interval": 1439106732.326777,
"key": "-JwGRWPudmaRwT8dpx79",
"likes": [
"sEIXov9ebP"
],
"name": "PowerUser",
"picture": "https: //a.cloudfront.net/fgzoFVtexv/picture/2376019341/picture.jpg",
"picture_height": 424,
"picture_width": 638,
"text": "[Picturepost ]",
"thumbnail": "",
"type": "picture",
"userId": "fgzoFVtexv",
"video": "",
"video_duration": 0
},
"-JwGReVetAxVWWJkc3L4": {
"audio": "",
"audio_duration": 0,
"channelId": "IxyMMJdPjs",
"channelName": "C2",
"channelPicture": "https: //a.cloudfront.net/fgzoFVtexv/channel/7066019341/picture.jpg",
"channelThumbnail": "https: //a.cloudfront.net/fgzoFVtexv/channel/7066019341/thumbnail.jpg",
"date": "2015-08-09T07: 52: 50.GMT",
"interval": 1439106770.490803,
"key": "-JwGReVetAxVWWJkc3L4",
"likes": [
"sEIXov9ebP"
],
"name": "PowerUser",
"picture": "https: //a.cloudfront.net/fgzoFVtexv/picture/0776019341/picture.jpg",
"picture_height": 636,
"picture_width": 638,
"text": "[ Picturepost]",
"thumbnail": "",
"type": "picture",
"userId": "fgzoFVtexv",
"video": "",
"video_duration": 0
},
"-JwGRiLa2Nz1vfhWNgFa": {
"audio": "",
"audio_duration": 0,
"channelId": "ePuAN4qAj7",
"channelName": "C1",
"channelPicture": "https: //a.cloudfront.net/fgzoFVtexv/channel/8756019341/picture.jpg",
"channelThumbnail": "https: //a.cloudfront.net/fgzoFVtexv/channel/8756019341/thumbnail.jpg",
"date": "2015-08-09T07: 53: 04.GMT",
"interval": 1439106784.834503,
"key": "-JwGRiLa2Nz1vfhWNgFa",
"likes": [
"sEIXov9ebP"
],
"name": "PowerUser",
"picture": "https: //a.cloudfront.net/fgzoFVtexv/picture/4876019341/picture.jpg",
"picture_height": 638,
"picture_width": 638,
"text": "[Picturepost]]",
"thumbnail": "",
"type": "picture",
"userId": "fgzoFVtexv",
"video": "",
"video_duration": 0
},
"-JwGRlNNQkefrr953PgX": {
"audio": "",
"audio_duration": 0,
"channelId": "ePuAN4qAj7",
"channelName": "C3",
"channelPicture": "https: //a.cloudfront.net/fgzoFVtexv/channel/8756019341/picture.jpg",
"channelThumbnail": "https: //a.cloudfront.net/fgzoFVtexv/channel/8756019341/thumbnail.jpg",
"date": "2015-08-09T07: 53: 18.GMT",
"interval": 1439106798.653415,
"key": "-JwGRlNNQkefrr953PgX",
"likes": [
"sEIXov9ebP"
],
"name": "PowerUser",
"picture": "https: //a.cloudfront.net/fgzoFVtexv/picture/8976019341/picture.jpg",
"picture_height": 304,
"picture_width": 638,
"text": "[Picturepost]",
"thumbnail": "",
"type": "picture",
"userId": "fgzoFVtexv",
"video": "",
"video_duration": 0
}
}
}