Define a Schema
An Schema is a blueprint of some data that is going to be stored in the database. We can create an schema using mongoose.Schema() class.
Javascript
const formSchema = new mongoose.Schema({ username: { type: String, required: true }, password: { type: String, required: true } }); const Form = mongoose.model( 'Form' , formSchema); |
Getting Started with MERN Stack
M (MongoDB) E (Express.js) R (React.js) N (Node.js) stack is a popular Javascript language-based stack for building full-stack applications, MongoDB, ExpressJs, and NodeJs being responsible for server building and React for client-side development. This article is going to be your guide if you want to get started with the MERN stack development.
Table of Content
- 1. Setting Up Node.Js Environment
- 2. Starting a Node.Js Project and Installing Dependencies
- 3. Create a basic server with Express.Js
- 4. Connect to MongoDB
- 5. Define a Schema
- 6. Defining a Route and Query in a Database
- 7. Create a React App
- 8. Create a Component to Make a Backend Request
- 9. Combining Everything to Make a MERN Application