Node.js ORM Sequelize All In One

Node.js ORM Sequelize All In One

Sequelize is an easy-to-use and promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, DB2, Microsoft SQL Server, and Snowflake.
It features solid transaction support, relations, eager and lazy loading, read replication and more.

https://sequelize.org/

https://www.npmjs.com/package/sequelize

image

sqlite3

$ npm i sequelize sqlite3
# or
$ yarn add sequelize sqlite3
import { Sequelize, DataTypes } from 'sequelize';

const sequelize = new Sequelize('sqlite::memory:');
// DEFINE MODELS
const User = sequelize.define('User', {
  username: DataTypes.STRING,
  birthday: DataTypes.DATE,
});
// PERSIST
const jane = await User.create({
  username: 'janedoe',
  birthday: new Date(1980, 6, 20),
});
// QUERY
const users = await User.findAll();

https://sequelize.org/docs/v6/getting-started/

sequelize-cli

$ npm i -D sequelize-cli
$ npx sequelize --help
$ sequelize --version

$ sequelize db:migrate
$ sequelize db:seed
$ sequelize init

https://www.npmjs.com/package/sequelize-cli

demos

macOS

$ brew list | grep mysql

$ brew services list | grep mysql
Name                  Status     User       File
httpd                 error  256 xgqfrms-mm ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
[email protected] none       xgqfrms-mm
php                   none
unbound               none

(🐞 反爬蟲測試!打擊盜版⚠️)如果你看到這個信息, 說明這是一篇剽竊的文章,請訪問 https://www.cnblogs.com/xgqfrms/ 查看原創文章!

refs



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 發佈文章使用:只允許註冊用戶纔可以訪問!

原創文章,版權所有©️xgqfrms, 禁止轉載 🈲️,侵權必究⚠️!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章