MCPcopy Create free account
hub / github.com/monkeytypegame/monkeytype / getPartialUser

Function getPartialUser

backend/src/dal/user.ts:265–281  ·  view source on GitHub ↗
(
  uid: string,
  stack: string,
  fields: K[],
)

Source from the content-addressed store, hash-verified

263 * @throws MonkeyError if user does not exist
264 */
265export async function getPartialUser<K extends keyof DBUser>(
266 uid: string,
267 stack: string,
268 fields: K[],
269): Promise<Pick<DBUser, K>> {
270 const projection = new Map(fields.map((it) => [it, 1]));
271 const partialUser = await getUsersCollection().findOne(
272 { uid },
273 { projection },
274 );
275 if (partialUser === null) throw new MonkeyError(404, "User not found", stack);
276
277 if (fields.includes("personalBests" as K)) {
278 return migrateUser(partialUser);
279 }
280 return partialUser;
281}
282
283export async function findByName(name: string): Promise<DBUser | undefined> {
284 const found = await getUsersCollection().findOne(

Callers 14

checkUserPermissionsFunction · 0.90
getQuotesFunction · 0.90
approveQuoteFunction · 0.90
submitRatingFunction · 0.90
getTagsFunction · 0.85
getThemesFunction · 0.85
getPersonalBestsFunction · 0.85
getStatsFunction · 0.85
getFavoriteQuotesFunction · 0.85
recordAutoBanEventFunction · 0.85
getInboxFunction · 0.85
updateStreakFunction · 0.85

Calls 2

getUsersCollectionFunction · 0.85
migrateUserFunction · 0.85

Tested by

no test coverage detected