此项目同步自 sequelize / sequelize 项目.
更新日志请参阅: CHANGELOG
Sequelize 是一个易用且基于 promise 的 Node.js ORM 工具 适用于 Postgres, MySQL, MariaDB, SQLite, DB2, Microsoft SQL Server, Snowflake, Oracle DB 和 Db2 for IBM i. 它具有强大的事务支持, 关联关系, 预读和延迟加载,读取复制等功能.
Sequelize 遵从 语义版本控制 和 官方 Node.js LTS 版本. Sequelize v7 版本正式支持 Node.js ^14.17,0
, ^16.0.0
. 其他版本或可正常工作.
你目前正在查看 Sequelize 的教程和指南.你可能还对API 参考 (英文)感兴趣.
在此处可以找到主要版本的升级信息:
注意 由于当前alpha阶段api调整, 文档中的API参考指向尚未确定. 可前往 V7 API 参考自行查询.
# 使用 npm npm install sequelize # 这将安装最新版本的 Sequelize # 使用 yarn yarn add sequelize
# 用于支持数据库方言的库: # 使用 npm npm i pg pg-hstore # PostgreSQL npm i mysql2 # MySQL npm i mariadb # MariaDB npm i sqlite3 # SQLite npm i tedious # Microsoft SQL Server npm i ibm_db # DB2 npm i odbc # IBM i # 使用 yarn yarn add pg pg-hstore # PostgreSQL yarn add mysql2 # MySQL yarn add mariadb # MariaDB yarn add sqlite3 # SQLite yarn add tedious # Microsoft SQL Server yarn add ibm_db # DB2 yarn add odbc # IBM i
import { Sequelize, Model, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize'; const sequelize = new Sequelize('sqlite::memory:'); class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> { declare username: string | null; declare birthday: Date | null; } User.init({ username: DataTypes.STRING, birthday: DataTypes.DATE }, { sequelize, modelName: 'user' }); (async () => { await sequelize.sync(); const jane = await User.create({ username: 'janedoe', birthday: new Date(1980, 6, 20), }); console.log(jane.toJSON()); })();
const { Sequelize, Model, DataTypes } = require('sequelize'); const sequelize = new Sequelize('sqlite::memory:'); class User extends Model {} User.init({ username: DataTypes.STRING, birthday: DataTypes.DATE }, { sequelize, modelName: 'user' }); (async () => { await sequelize.sync(); const jane = await User.create({ username: 'janedoe', birthday: new Date(1980, 6, 20) }); console.log(jane.toJSON()); })();
请通过 Getting started - 入门 来学习更多相关内容. 如果你想要学习 Sequelize API 请通过 API 参考 (英文).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4