Playing Next Lesson In
seconds

Let's Learn AdonisJS 6 #2.11

Defining A Structure for our Movie using Models

In This Lesson

We'll introduce the concept of models by using one to define the properties our movies should contain. We'll then stub some methods that will mock calls we'll later be able to use to load data from our database.

Created by
@tomgobich
Published

Join the Discussion 10 comments

Create a free account to join in on the discussion
  1. @shark

    Hello! I just wanted to say how much I’ve enjoyed your videos so far. They’re clear, precise, and the audio/video quality is excellent. I’m a mostly self-taught beginner with AdonisJS, yet I’m able to follow along and actually understand what’s going on — which says a lot about the quality of your work.

    However, I’m a bit confused about the whole routing section (videos 2.0 to 2.8). That approach doesn’t really seem like something we should follow in practice — mainly due to security and complexity concerns — and then from video 2.8 onward you switch to what is clearly the proper way to do things. I have to admit I had to rewatch those earlier parts several times and only kept about 8–10 minutes that were actually useful to me.

    As a beginner, I tend to follow everything closely, only to end up moving on to something completely different afterward. I’m not saying the explanations aren’t interesting, but giving too much information at once can end up diluting the key ideas.

    I hope this comes across as constructive feedback — now I’m getting back to work! 😊

    1
    1. Responding to shark
      @tomgobich

      Thank you very much for the constructive feedback, @shark! There's nothing wrong or insecure with using callbacks for route handlers within small applications, but you're right they don't scale well at all. The app.makeUrl does also utilize join from node:path which normalizes to help protect against path traversal.

      My thinking here was to set a premise first, then replace them with AdonisJS implementations while also painting a picture on why you'd want to extract to service and controllers as things grow.

      My execution on that, however, did have room for improvement. I can definitely see your point, in that, it can feel disorienting/disappointing to start with one thing only to switch away from it a few lessons later. I have learned quite a bit from hindsight and feedback like yours on this series. If I were remaking this series today, it would look vastly different. It'd be more condensed, there are plenty of things I'd remove altogether (especially in this module). It'd also have more soft mentions to things like my sentence above mentioning app.makeUrl performs normalizations through node:path's join method.

      Thank you again for your feedback! I greatly appreciate you taking the time to share, and I hope you'll find I do it justice in future series!

      1
  2. cannot fine module 'luxon' or its corresponding type declarations

    0
  3. error message: Argument of type 'Hash' is not assignable to parameter of type '() => Hash'.

    0
  4. Command "make:model" is not defined

    0
    1. Responding to amitava-mukherji
      @tomgobich

      Hi Amitava! Can you please provide some additional context around these errors? Did you clone this series' repo at a certain branch? Is this a brand new AdonisJS 6 project?

      0
      1. Responding to tomgobich

        I've found the same error running "node ace make:model movie"

        This command is unavailable in the ace make options (running "node ace list").

        0
        1. Responding to antoniogiroz
          @tomgobich

          Hi Antoniogiroz! Please make sure you have Lucid installed and configure inside of your project.

          npm i @adonisjs/lucid
          Copied!

          Then

          node ace configure @adonisjs/lucid
          Copied!

          If you continue to have issues, please provide some more details or a repository with a reproduction of your issue.

          1
          1. Responding to tomgobich

            It works! Thanks!

            1
            1. Responding to antoniogiroz
              @tomgobich

              Awesome to hear! Anytime!!

              0