Home

0

useState

Basic usage 1const [count, setCount] = useState(initialState) count is to read state, setCount is to update state, and initialState is initial value. ​ State is an array Because React renderin

0

Responsive design

Responsive Layout One page corresponds to multiple devices. When the device screen/pc webpage size changes, the page layout (not the element/text size) will be changed automatically. There

0

Reference

The schema part of the associated code In the schema we care about two pieces of information: the type of the association id (type), and which collection the association is (ref). The association of

0

Error handling

Method 1: try catch wraps the async request 1234567891011async function addStudent(req, res){ const {firstName, lastName, email} = req.body; const student = new Student({

0

Project structure

Create a project First create the src folder in the project folder, then create the entry file index.js in it, then run npm init -y . Then install express, dotenv, cors, morgan, Mongoose packages. n

0

Mongoose

Mongoose Introduction Mongoose is a package that uses promises and async/await. Mongoose is an ORM (object relational mapper) or ODM (object data mapping), which is specific to Mongodb. It enca

0

Relationships

Association (similar to sql) In sql, the association may be 1-to-many, and the many parts may be 0, 1, and Many. The data in Mongodb is stored in the form of an array, so it may be 0 data, regardles

0

CORS

Interface cross domain problem There are two main solutions to solve the interface cross-domain problem: CORS (mainstream solution, recommended) JSONP (flawed solution, only supports GET requests)

0

Interface (Summary)

Create interface steps (summarize previous lessons) Create the basic server: app.js 123456const express = require('express')const app = express()//main codeapp.listen(80, function(){

0

Middleware classification

Classification of middleware Express officially divides common middleware usage into five categories: Application-level middleware Route-level middleware Error-level middleware Express built-in