groups working
This commit is contained in:
@@ -67,7 +67,6 @@ postDB = (DB)=>{
|
||||
lastUpdated: new Date()
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(update));
|
||||
return DB.postCols.updateOne({
|
||||
_id: id,
|
||||
"comments.createdAt": commentDate
|
||||
@@ -101,6 +100,15 @@ postDB = (DB)=>{
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
DB.getPost = (postId) => {
|
||||
let _id = DB.ObjectID(postId);
|
||||
return DB.postCols.findOne({_id}).catch((err)=>{
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = postDB;
|
||||
@@ -23,9 +23,9 @@ userDB = (DB) => {
|
||||
return r;
|
||||
}
|
||||
|
||||
DB.getProfiles = async (profileId) => {
|
||||
const _id = DB.ObjectID(profileId);
|
||||
return await DB.profileCols.find({ _id }).toArray().catch((err) => {
|
||||
DB.getUserProfiles = async (userId) => {
|
||||
const userid = DB.ObjectID(userId);
|
||||
return await DB.profileCols.find({ userid }).toArray().catch((err) => {
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
@@ -43,6 +43,29 @@ userDB = (DB) => {
|
||||
return r[0];
|
||||
}
|
||||
|
||||
//Groups
|
||||
DB.getGroups = async () => {
|
||||
let r = await DB.profileCols.find({isGroup: true})
|
||||
.sort({ lastUpdate: -1 }).limit(10)
|
||||
.toArray().catch((err) => {
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
return r;
|
||||
}
|
||||
|
||||
DB.getGroup = async (groupid) => {
|
||||
const _id = DB.ObjectID(groupid);
|
||||
if(userProfileCache[groupid]) return userProfileCache[groupid];
|
||||
let r = await DB.profileCols.findOne({_id, isGroup: true})
|
||||
.toArray().catch((err) => {
|
||||
console.log(err);
|
||||
return false;
|
||||
});
|
||||
if (r) userProfileCache[r.id] = r;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user