Given two files app.js
and a database file moviesData.db
consisting of two tables movie
and director
.
Write APIs to perform CRUD operations on the tables movie
, director
containing the following columns,
Movie Table
Columns | Type |
---|---|
movie_id | INTEGER |
director_id | INTEGER |
movie_name | TEXT |
lead_actor | TEXT |
Director Table
Columns | Type |
---|---|
director_id | INTEGER |
director_name | TEXT |
Returns a list of all movie names in the movie table
[
{
movieName: "Captain America: The First Avenger",
},
...
]
Creates a new movie in the movie table. movie_id
is auto-incremented
{
"directorId": 6,
"movieName": "Jurassic Park",
"leadActor": "Jeff Goldblum"
}
Movie Successfully Added
Returns a movie based on the movie ID
{
movieId: 12,
directorId: 3,
movieName: "The Lord of the Rings",
leadActor: "Elijah Wood",
}
Updates the details of a movie in the movie table based on the movie ID
{
"directorId": 24,
"movieName": "Thor",
"leadActor": "Christopher Hemsworth"
}
Movie Details Updated
Deletes a movie from the movie table based on the movie ID
Movie Removed
Returns a list of all directors in the director table
[
{
directorId: 1,
directorName: "Joe Johnston",
},
...
]
Returns a list of all movie names directed by a specific director
[
{
movieName: "Captain Marvel",
},
...
]
Use npm install
to install the packages.
Export the express instance using the default export syntax.
Use Common JS module syntax.