feed with followers only
This commit is contained in:
@@ -91,6 +91,27 @@ postDB = (DB)=>{
|
||||
});
|
||||
}
|
||||
|
||||
DB.getFeed = async (profileId) => {
|
||||
const profile = await DB.getProfile(profileId);
|
||||
let ids = profile.following.map((id)=>DB.ObjectID(id));
|
||||
ids.push(profileId)
|
||||
const _id = DB.ObjectID(profileId);
|
||||
query = {
|
||||
$or: [
|
||||
{profileid: {
|
||||
$in: ids
|
||||
}},
|
||||
{toProfile: {
|
||||
$in: ids
|
||||
}}
|
||||
]
|
||||
};
|
||||
return DB.postCols.find(query).sort({_id: -1}).limit(20).toArray().catch((err)=>{
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
DB.getPostsOfUser = (userId) => {
|
||||
let userid = DB.ObjectID(userId);
|
||||
return DB.postCols.find({userid}).sort({_id: -1}).toArray().catch((err)=>{
|
||||
|
||||
Reference in New Issue
Block a user