SeasonService

Source: SeasonService.js:18

Service for managing season entities and their associations. Handles CRUD operations and season-specific logic.


Constructor

new SeasonService(): SeasonService

Instance Methods

getAll( ownerIds: Array.<string> | null, actingUserId: UUID, options: Object, ): Promise.<Array>

Get all seasons for a user.

Parameters

  • ownerIds (Array.<string> | null) — Array of owner IDs the acting user has access to.
  • actingUserId (UUID) — The acting user ID.
  • options (Object) — Options for fetching seasons.
    • options.all (boolean) — Whether to fetch all seasons.

Returns

  • Promise.<Array> — List of seasons.

getCount(): Promise.<number>

Get the total count of seasons.

Returns

  • Promise.<number> — Count of seasons.

getTrend(): Promise.<number>

Get the trend of season creation in the last 30 days.

Returns

  • Promise.<number> — Count of seasons created in the last 30 days.

create( name: string, year: number, ownerId: UUID | null, actingUserId: UUID, isAdmin?: boolean, ): Promise.<Object>

Create a new season.

Parameters

  • name (string) — Name of the season.
  • year (number) — Year of the season.
  • ownerId (UUID | null) — Owner ID. If null/undefined, falls back to actingUserId
  • actingUserId (UUID) — The acting user ID.
  • isAdmin (boolean, optional, default: false)

Returns

  • Promise.<Object> — Created season object.

update( id: UUID, data: Object, actingUserId: UUID, options: Object, ): Promise.<Object>

Update an existing season.

Parameters

  • id (UUID) — ID of the season to update.
  • data (Object) — Data to update the season with.
  • actingUserId (UUID) — The acting user ID.
  • options (Object) — Options for updating the season.
    • options.all (boolean) — Whether to update all seasons.

Returns

  • Promise.<Object> — Updated season object.

Throws

  • Will throw an error if the season is not found.

remove( id: UUID, actingUserId: UUID, options: Object, ): Promise.<void>

Remove a season.

Parameters

  • id (UUID) — ID of the season to remove.
  • actingUserId (UUID) — The acting user ID.
  • options (Object) — Options for removing the season.
    • options.all (boolean) — Whether to remove all seasons.

Returns

  • Promise.<void> — Resolves when the season is removed.

Throws

  • Will throw an error if the season is not found.