server for simple media sharing and social network, intended for children
Kindergram backend model
2 docs per post:
{
type:"postmeta", // doc type
appname:"", // application that creates the media
followinglist: [], // users following the posting user when posted
likes: [], // users who like it
username: "", // user who posted
media_id: "", // id of media doc
time: integer // unix time when posted
}
media doc: contains the binary, has media_id as key
{
type: "user",
username: "" // users id
apps: [] // list of apps you use
}
{
type: "follow_mapping"
username: "damienkatz", //user who is following someone
following_username: "sergey" //user who is being followed
}
following activity stream:
function(doc, meta) {
if (doc.type != "postmeta")
return;
emit([doc.username, doc.time], {poster: doc.username, media_id: doc.media_id, likes: doc.likes});
doc.followinglist.forEach(function(user) {
emits([user, doc.time], {poster: doc.username, media_id: doc.media_id, likes: doc.likes});
});
}
my_activity_stream:
function(doc, meta) {
if (doc.type != "postmeta")
return;
emit([doc.user, doc.time], {poster: doc.username, media_id: doc.media_id, likes: doc.likes});
}
my_followers:
function(doc, meta) {
if (doc.type = "following") {
emit(doc.following_username, doc.username);
}
}
who_i_follow:
function(doc, meta) {
if (doc.type = "following") {
emit(doc.username, doc.following_username);
}
}
popular posts: ????