groups working
This commit is contained in:
@@ -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