Understanding the movie module

Now that the genres have been created, it’s time to include movies for rating in our database. In essence, the administrator adds a movie, links to the movie trailer or a brief snippet, and then adds the movie to a genre. A movie can only be created and edited by an admin, but other app users can access them and leave reviews. Let’s get to work on making our first movie!

Setting up the movie model

Let's add a movieModel.go file to the models folder. This file will have the movie struct and the parameters we need to ask the admin user for. The movie struct will be expecting the following parameters from the frontend:

  • Name: Contains the name of the movie to be created.

  • Topic: A scene, character, plot, or theme in the movie to be created.

  • Genre_id: Contains the ID of the genre the movie belongs to.

  • Movie_URL: A link to the movie trailer on IMDB, YouTube, or any video service.

  • Created_at: The time when the movie was created.

  • Updated_at: The time when the movie was updated.

  • Movie_id: Represents the ID of the newly created movie in the database.

Get hands-on with 1200+ tech skills courses.