From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Property and user models

Property and user models

So with MongoDB, we don't need to describe our data in the database layer like we would with like MySQL or Postgres or any relational database. Instead, we create our models within our application, and we're going to use Mongoose to do that. So we're going to create our user model and our property model in this video. Later on, we'll have a message model as well when we get into the internal messaging system, but that's not for a while. So let's go into, I'm just going to close all these up. And in the root, we're going to have a new folder called Models. And in Models, let's start with our user model. So I'm going to call it user with an uppercase U, user.js. And then here, we're going to import a few things from Mongoose. So we're going to bring in schema. So when we create a model, it has a schema attached. And the schema is where we define all of our fields, such as email, username, password, all that good stuff. So let's say schema. We're also going to bring in model, because…

Contents