( uid: string, result: DBResult, )
| 15 | db.collection<DBResult>("results"); |
| 16 | |
| 17 | export async function addResult( |
| 18 | uid: string, |
| 19 | result: DBResult, |
| 20 | ): Promise<{ insertedId: ObjectId }> { |
| 21 | const { data: user } = await tryCatch(getUser(uid, "add result")); |
| 22 | |
| 23 | if (!user) throw new MonkeyError(404, "User not found", "add result"); |
| 24 | result.uid ??= uid; |
| 25 | // result.ir = true; |
| 26 | const res = await getResultCollection().insertOne(result); |
| 27 | return { |
| 28 | insertedId: res.insertedId, |
| 29 | }; |
| 30 | } |
| 31 | |
| 32 | export async function deleteAll(uid: string): Promise<DeleteResult> { |
| 33 | return await getResultCollection().deleteMany({ uid }); |
nothing calls this directly
no test coverage detected