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

Function replaceObjectId

backend/src/utils/misc.ts:202–213  ·  view source on GitHub ↗
(
  data: T | null,
)

Source from the content-addressed store, hash-verified

200 data: T | null,
201): (T & { _id: string }) | null;
202export function replaceObjectId<T extends { _id: ObjectId }>(
203 data: T | null,
204): (T & { _id: string }) | null {
205 if (data === null) {
206 return null;
207 }
208 const result = {
209 ...data,
210 _id: data._id.toString(),
211 } as T & { _id: string };
212 return result;
213}
214
215/**
216 * convert database objects into api objects

Callers 9

convertFunction · 0.90
getResultByIdFunction · 0.90
getLastResultFunction · 0.90
getPresetsFunction · 0.90
getUserFunction · 0.90
addTagFunction · 0.90
addCustomThemeFunction · 0.90
getRatingFunction · 0.90
replaceObjectIdsFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected