Given two files app.js and a database file cricketTeam.db consisting a table cricket_team.
Write APIs to perform operations on the table cricket_team containing the following columns,
| Columns | Type |
|---|---|
| player_id | INTEGER |
| player_name | TEXT |
| jersey_number | INTEGER |
| role | TEXT |
Returns a list of all players in the team
[
{
playerId: 1,
playerName: "Lakshman",
jerseyNumber: 5,
role: "All-rounder"
},
...
]
Creates a new player in the team (database). player_id is auto-incremented
{
"playerName": "Vishal",
"jerseyNumber": 17,
"role": "Bowler"
}
Player Added to Team
Returns a player based on a player ID
{
playerId: 1,
playerName: "Lakshman",
jerseyNumber: 5,
role: "All-rounder"
}
Updates the details of a player in the team (database) based on the player ID
{
"playerName": "Maneesh",
"jerseyNumber": 54,
"role": "All-rounder"
}
Player Details Updated
Deletes a player from the team (database) based on the player ID
Player Removed
Use npm install to install the packages.
Export the express instance using the default export syntax.
Use Common JS module syntax.