From e4a96f1ea0434c7188bd28f1fee4bb7088ad1a12 Mon Sep 17 00:00:00 2001 From: kravishankar30 Date: Sun, 15 Oct 2023 17:48:19 -0400 Subject: [PATCH] added documentation to user db operations --- model.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/model.ts b/model.ts index 3a7843a..5a7e72d 100644 --- a/model.ts +++ b/model.ts @@ -68,6 +68,12 @@ type result_getUsers = { last_logged_on?: string; }; +/** + * Gets a list of all the users from the database "user" table. + * An optional sorts argument can be passed to the function to get a list of users sorted in a specific order. + * @param sorts optional argument used to sort the users + * @returns Returns a list of users of the type result_getUsers + */ export const getUsers = (sorts?: Sort[] | Sort): result_getUsers[] => { if (sorts) { return db @@ -97,6 +103,13 @@ export const getUsers = (sorts?: Sort[] | Sort): result_getUsers[] => { } }; +/** + * Gets the last logged in time of a specific user. + * It sorts all the sessions of a user in descending order and returns a single + * record by limiting the response to 1. + * @param user_id id of the user whose last logged on time we want + * @returns the date and time of the last login of the user. + */ export const getUserLastLoggedOn = async (user_id: number) => { let res = await db .select("created_at")