Class: SessionsModel

SessionsModel(id, activityId, locationId, trainerId, date, time, title)

Represents a gym session stored in the sessions table.

Constructor

new SessionsModel(id, activityId, locationId, trainerId, date, time, title)

Parameters:
Name Type Description
id number | null

Session identifier.

activityId number

Activity identifier.

locationId number

Location identifier.

trainerId number

Trainer user identifier.

date string | Date

Session date.

time string

Session time.

title string

Session title.

Source:

Classes

SessionsModel

Methods

(static) create(session) → {Promise.<OkPacket>}

Create a session.

Parameters:
Name Type Description
session SessionsModel

Session to create.

Source:
Returns:

Database result.

Type
Promise.<OkPacket>

(static) delete(sid) → {Promise.<OkPacket>}

Delete a session by its identifier.

Parameters:
Name Type Description
sid string

Session identifier.

Source:
Returns:

Database result.

Type
Promise.<OkPacket>

(async, static) getAll() → {Promise.<Array.<SessionsModel>>}

Retrieve all sessions.

Source:
Returns:

Stored sessions.

Type
Promise.<Array.<SessionsModel>>

(async, static) getById(sid) → {Promise.<SessionsModel>}

Retrieve a session by its identifier.

Parameters:
Name Type Description
sid string

Session identifier.

Source:
Throws:

"not found" when no session matches the identifier.

Type
string
Returns:

Matching session.

Type
Promise.<SessionsModel>

(static) tableToModel(row) → {SessionsModel}

Convert a database row into a SessionsModel instance.

Parameters:
Name Type Description
row Object

Database row.

Source:
Returns:

Mapped session.

Type
SessionsModel

(static) update(session) → {Promise.<OkPacket>}

Update an existing session.

Parameters:
Name Type Description
session SessionsModel

Session to update.

Source:
Returns:

Database result.

Type
Promise.<OkPacket>