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 - Next.js Tutorial
From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Create MongoDB database8m 44s
-
(Locked)
MongoDB Compass and importing data4m 36s
-
(Locked)
Database connection and Mongoose6m 31s
-
(Locked)
Your first API route6m 5s
-
(Locked)
Property and user models12m 30s
-
(Locked)
Fetch data using server component9m 48s
-
(Locked)
Requests file4m 25s
-
(Locked)
Fetch single property10m 51s
-
(Locked)
Single property page11m 54s
-
(Locked)
Property details component15m 34s
-
(Locked)
Spinner component2m 37s
-
(Locked)
-
-
-
-
-
-
-