groups working

This commit is contained in:
Adolfo Reyna
2021-08-19 10:19:10 -07:00
parent 95a7bcb3ff
commit 9f5f23364b
5 changed files with 117 additions and 50 deletions

View File

@@ -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;
}
}