1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 08:35:17 +00:00

Add /groups/get_my_list

This commit is contained in:
2019-12-13 17:49:58 +01:00
parent 8737607b53
commit ee6579efa0
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import { DatabaseHelper } from "./DatabaseHelper";
/**
* Groups helper
*
* @author Pierre HUBERT
*/
const GROUPS_LIST_TABLE = "comunic_groups";
const GROUPS_MEMBERS_TABLE = "comunic_groups_members";
export class GroupsHelper {
/**
* Get the list of groups of a user
*
* @param userID Target user ID
*/
public static async GetListUser(userID: number) : Promise<Array<number>> {
const list = await DatabaseHelper.Query({
table: GROUPS_MEMBERS_TABLE,
where: {
user_id: userID
},
fields: ["groups_id"]
});
return list.map(e => e.groups_id);
}
}