Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as typegoose from '@typegoose/typegoose'
import uuid from 'uuid/v4'
import { SessionNetworkInfo } from 'entities/sessionnetworkinfo'
/**
* Handles an user's session information
*/
@typegoose.index({ sessionId: 1, userId: 1 }, { unique: true })
export class UserSession {
/**
* retrieve every session in the db
* @param colOffset the index where the collection should begin
* @param colLength the collection's length
* @returns a promise with the sessions
*/
public static async getAll(colOffset: number, colLength: number): Promise {
return UserSessionModel.find({}).skip(colOffset).limit(colLength)
.exec()
}
/**
* retrieve an user's session by its owning user's ID
* @param userId the owning user's ID
* @returns the requested UserSession, if found. otherwise it will return a null object