Skip to content

Commit

Permalink
added documentation to user db operations
Browse files Browse the repository at this point in the history
  • Loading branch information
kravishankar30 committed Oct 15, 2023
1 parent 5ce8804 commit e4a96f1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit e4a96f1

Please sign in to comment.