TeamService

Source: TeamService.js:28

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


Constructor

new TeamService(): TeamService

Instance Methods

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

Get all teams for a user.

Parameters

  • ownerIds (Array.<string> | null) — Array of owner IDs the acting user has access to.
  • actingUserId (UUID) — The acting user ID.
  • isAdmin (boolean, optional, default: false)
  • options (Object) — Options for filtering.
    • options.all (boolean) — Whether to fetch all teams.

Returns

  • Promise.<Array> — List of teams.

findByName( name: string, ownerIds: Array.<UUID>, actingUserId: UUID, isAdmin?: boolean, ): Promise.<Array>

Find teams by name for a user.

Parameters

  • name (string) — The name of the team.
  • ownerIds (Array.<UUID>) — Array of owner IDs the acting user has access to.
  • actingUserId (UUID) — The acting user ID.
  • isAdmin (boolean, optional, default: false)

Returns

  • Promise.<Array> — List of teams.

findById( id: UUID, actingUserId: UUID, isAdmin?: boolean, ): Promise.<Object>

Find a team by ID for a user.

Parameters

  • id (UUID) — The ID of the team.
  • actingUserId (UUID) — The acting user ID.
  • isAdmin (boolean, optional, default: false)

Returns

  • Promise.<Object> — The team object.

getCount(): Promise.<number>

Get the total count of teams.

Returns

  • Promise.<number> — The count of teams.

getTrend(): Promise.<number>

Get the trend of team creation and deletion.

Returns

  • Promise.<number> — The trend value.

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

Create a new team.

Parameters

  • name (string) — The name of the team.
  • ClubId (UUID) — The club ID.
  • SeasonId (UUID) — The season ID.
  • 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> — The created team object.

findOrCreate( name: string, ClubId: UUID, ownerId: UUID | null, actingUserId: UUID, isAdmin?: boolean, ): Promise.<Array.<(Object|boolean)>>

Find or create a team.

Parameters

  • name (string) — The name of the team.
  • ClubId (UUID) — The club ID.
  • 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.<Array.<(Object|boolean)>> — The found or created team object and a boolean indicating if the team was created.

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

Update a team.

Parameters

  • id (UUID) — The ID of the team.
  • data (Object) — The data to update.
  • actingUserId (UUID) — The acting user ID.
  • options.all (boolean, optional, default: false)

Returns

  • Promise.<Object> — The updated team object.

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

Remove a team.

Parameters

  • id (UUID) — The ID of the team.
  • actingUserId (UUID) — The acting user ID.
  • isAdmin (boolean, optional, default: false)
  • options (Object) — Options for filtering.
    • options.all (boolean) — Whether to remove all teams.

Returns

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