Files
zkldi_Tachi/server/src/utils/session.ts
T
2022-12-28 11:59:45 +00:00

23 lines
675 B
TypeScript

import db from "external/mongo/db";
import type { ScoreDocument, SessionDocument } from "tachi-common";
/**
* Returns all the score documents inside a session.
* @param session The session to retrieve the score documents of.
*/
export function GetScoresFromSession(session: SessionDocument) {
return db.scores.find({
scoreID: { $in: session.scoreIDs },
});
}
/**
* Returns the session a score belongs to, if there is one. A score can only be part of one session implicitly.
* @param score The score to return the associated session of.
*/
export function GetSessionFromScore(score: ScoreDocument) {
return db.sessions.findOne({
scoreIDs: score.scoreID,
});
}