feed with followers only

This commit is contained in:
Adolfo Reyna
2021-09-02 12:02:09 -07:00
parent fa0d6ee199
commit 9a302a87de
4 changed files with 70 additions and 2 deletions

View File

@@ -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)=>{