- Data store in Object format
- Used in store userProfile to get data fast not db calls and if any update invalidate data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Best approach: | |
| // OTP send API se initial TTL le lo. | |
| // Frontend me local countdown chalao. | |
| // Jab page refresh ho ya component remount ho tab TTL API hit karo. | |
| // Backend API | |
| // send otp | |
| app.post("/otp/send", async (req, res) => { |
To use Sequelize ORM with Node.js for database operations including models, migrations, associations, queries, and transactions with PostgreSQL, MySQL, or SQLite.
It provides a clean API for database operations with support for migrations, associations, and transactions.
# Sequelize core
npm install sequelize
| Database | Library | “new keyword” | Reason |
|---|---|---|---|
| MongoDB | Mongoose | ❌ Required नहीं | mongoose.connect() खुद client बना देता है |
| MongoDB | Custom Mongoose | ✔ Required | const customMongoose = new mongoose.Mongoose(); आपको नया independent client चाहिए होता है |
| Redis | ioredis | ✔ Required | const redis = new Redis(); // <- NEW keyword required Redis client एक class instance होता है |
| Redis | redis (legacy) | ✔ Required | वही reason — class instance |
See Examples: -url: https://www.prisma.io/docs/prisma-orm/quickstart/postgresql
DIRECT_URL="postgres://USER:PASSWORD@db.prisma.io:5432/postgres?sslmode=require"
DATABASE_URL="postgres://USER:PASSWORD@pooled.db.prisma.io:5432/postgres?sslmode=require"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Open CMD as administrator | |
| 2. taskkill /F /IM mysqld.exe >> ERROR: The process "mysqld.exe" not found. | |
| Step_1 >> cd "C:\Program Files\MySQL\MySQL Server 8.0\bin" | |
| Step_2 >> mysqld --initialize-insecure // Initialize(fresh setup) | |
| Step_3 >> mysqld --install MySQL80 // service installed | |
| Step_4 >> net start MySQL80 // start services | |
| Step_5 >> mysql -u root // login to mysql | |
| Step_6 >> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123'; // Password set karo | |
| Step_7 >> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1. converts the incoming data into a JavaScript object and makes it accessible through req.body | |
| // 2. { extended: true } is set, it supports >> nested objects and arrays << using the qs library. | |
| // 3. It only parses requests with Content-Type: application/x-www-form-urlencoded, ignoring other data formats. | |
| app.use(express.urlencoded({ extended: true })) | |
| app.get('/login', (req, res) => { | |
| res.send('<form method=POST action=/login><input type=text name=username><input type=number name=age><input type=submit></form>') | |
| }) | |
| express.raw() function: It parses incoming request payloads into a >> Buffer << and is based on body-parser. |
NewerOlder