MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / listGroup

Method listGroup

packages/hydrooj/src/model/user.ts:483–499  ·  view source on GitHub ↗
(domainId: string, uid?: number, names?: string[], search?: string, limit?: number)

Source from the content-addressed store, hash-verified

481 }
482
483 static async listGroup(domainId: string, uid?: number, names?: string[], search?: string, limit?: number) {
484 const filter: Filter<GDoc> = { domainId };
485 if (typeof uid === 'number') filter.uids = uid;
486 const $and: Filter<GDoc>[] = [];
487 if (names?.length) $and.push({ name: { $in: names } });
488 if (search) $and.push({ name: { $regex: escapeRegExp(search), $options: 'i' } });
489 if ($and.length) filter.$and = $and;
490 let cursor = collGroup.find(filter);
491 if (limit) cursor = cursor.limit(limit);
492 const groups = await cursor.toArray();
493 if (uid) {
494 groups.push({
495 _id: new ObjectId(), domainId, uids: [uid], name: uid.toString(),
496 });
497 }
498 return groups;
499 }
500
501 static delGroup(domainId: string, name: string) {
502 deleteUserCache(domainId);

Callers 13

applyFunction · 0.80
getByIdMethod · 0.80
getMethod · 0.80
postMethod · 0.80
domain.tsFile · 0.80
getMethod · 0.80
getMethod · 0.80
getHomeworkMethod · 0.80
getContestMethod · 0.80
postMethod · 0.80
getMethod · 0.80
__prepareMethod · 0.80

Calls 2

findMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected