/services/teams

  • module
services/teams

{function()}

 

GET /services/teams

Gets teams from the database.

GET /services/teams?
    where[tournamentId]=5&
    withRelated[]=player1&
    withRelated[]=player2&
    withRelated[]=player3&
    withRelated[]=player4
    sortBy=name

Parameters

  1. where {Object}Optional

    Clause used to filter which teams are returned.

  2. withRelated {Array}Optional

    Clause used to add related data.

  3. sortBy {String}Optional

    Clause used to sort the returned teams.

Returns

{JSON}

An object that contains the teams:

{data: [{
  id: Int,
  tournamentId: Int,   // Related tournament
  name: String,     // Team name
  color: String,        // Team's jersey color
  player1Id: Int,       // Related first player
  player2Id: Int,       // Related second player
  player3Id: Int,       // Related third player
  player4Id: Int        // Related fourth player
}, ...]}

POST /services/teams

Creates a team in the database. Only admins are allowed to create teams.

POST /services/teams
     {
       "tournamentId": 1,
       "name": "Tequila Mockingbird",
       "color": "Gregory Peck Gray",
       "player1Id": 1,
       "player2Id": 2,
       "player3Id": 3,
       "player4Id": 4
     }

Parameters

  1. JSONBody {JSON}

    The raw JSON properties of a team object.

Returns

{JSON}

Returns JSON with all the properties of the newly created object, including its id.

{
  "id": 9
  "tournamentId": 1,
  "name": "Tequila Mockingbird",
  "color": "Gregory Peck Gray",
  "player1Id": 1,
  "player2Id": 2,
  "player3Id": 3,
  "player4Id": 4
}

GET /services/teams/:id

Gets a team by id from the database.

GET /services/teams/5?
    withRelated[]=player1&
      withRelated[]=player2&
      withRelated[]=player3&
      withRelated[]=player4

Parameters

  1. withRelated {Array}Optional

    Clause used to add related data.

Returns

{JSON}

An object that contains the team data:

{ id: Int, tournamentId: Int, // Related tournament name: String, // Team name color: String, // Team's jersey color player1Id: Int, // Related first player player2Id: Int, // Related second player player3Id: Int, // Related third player player4Id: Int // Related fourth player }

PUT /services/stats/:id

Updates a team in the database. Only admins are allowed to update teams.

  PUT /services/teams/9
    {
      "tournamentId": 1,
      "name": "Tequila Mockingbird is an Unoriginal Team Name",
      "color": "Gregory Peck Gray",
      "player1Id": 1,
      "player2Id": 2,
      "player3Id": 3,
      "player4Id": 4
    }

Parameters

  1. JSONBody {JSON}

    The updated properties of the team object.

Returns

{JSON}

Returns JSON with all the properties of the updated object, including its id.

{
  "id": 9,
  "tournamentId": 1,
  "name": "Tequila Mockingbird is an Unoriginal Team Name",
  "color": "Gregory Peck Gray",
  "player1Id": 1,
  "player2Id": 2,
  "player3Id": 3,
  "player4Id": 4
gi}

DELETE /services/teams/:id

Deletes a team in the database. Only admins are allowed to delete teams.

  DELETE /services/teams/9

Returns

{JSON}

Returns an empty JSON object.

{}