From the course: Building Full-Stack Applications with HTMX
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Seeding the database with articles - HTMX Tutorial
From the course: Building Full-Stack Applications with HTMX
Seeding the database with articles
- [Instructor] In order to visualize our articles as we infinitely scroll, we need to have a substantial amount of articles in our database to fetch. In this video, we'll be creating a database schema for our articles, and also seeding our database. In order to get these records ready, we'll be building a post schema and model that we'll use to populate our database with article records matching the structure of our schema. With around 100 dummy articles, we should have enough to work with when scrolling through our articles, and loading them incrementally. So let's begin. First, we're going to be constructing our schema using the Mongoose library. And for the sake of organization, go (indistinct) creating a models folder here at the root of the project. This folder will contain our schema files, and for our post schema, let's go ahead and create post.js, which will contain our schema definition. Inside this file, we'll be creating a product schema that will have the following fields:…