22
33![ ] ( http://docs.sequelizejs.com/manual/asset/logo-small.png )
44
5- [ ![ npm version] ( https://badgen.net/npm/v/sequelize )] ( https://www.npmjs.com/package/sequelize )
6- [ ![ Build Status] ( https://github.com/sequelize/sequelize/workflows/CI/badge.svg )] ( https://github.com/sequelize/sequelize/actions?query=workflow%3ACI )
7- [ ![ npm downloads] ( https://badgen.net/npm/dm/sequelize )] ( https://www.npmjs.com/package/sequelize )
5+ [ ![ npm version] ( https://badgen.net/npm/v/@sequelize/core )] ( https://www.npmjs.com/package/@sequelize/core )
6+ [ ![ npm downloads] ( https://badgen.net/npm/dm/@sequelize/core )] ( https://www.npmjs.com/package/@sequelize/core )
7+ [ ![ contributors] ( https://img.shields.io/github/contributors/sequelize/sequelize )] ( https://github.com/sequelize/sequelize/graphs/contributors )
8+ [ ![ Open Collective] ( https://img.shields.io/opencollective/backers/sequelize )] ( https://opencollective.com/sequelize#section-contributors )
89[ ![ sponsor] ( https://img.shields.io/opencollective/all/sequelize?label=sponsors )] ( https://opencollective.com/sequelize )
9- [ ![ Last commit] ( https://badgen.net/github/last-commit/sequelize/sequelize )] ( https://github.com/sequelize/sequelize )
1010[ ![ Merged PRs] ( https://badgen.net/github/merged-prs/sequelize/sequelize )] ( https://github.com/sequelize/sequelize )
11- [ ![ GitHub stars] ( https://badgen.net/github/stars/sequelize/sequelize )] ( https://github.com/sequelize/sequelize )
12- [ ![ Slack Status] ( http://sequelize-slack.herokuapp.com/badge.svg )] ( http://sequelize-slack.herokuapp.com/ )
13- [ ![ node] ( https://badgen.net/npm/node/sequelize )] ( https://www.npmjs.com/package/sequelize )
14- [ ![ License] ( https://badgen.net/github/license/sequelize/sequelize )] ( https://github.com/sequelize/sequelize/blob/main/LICENSE )
1511[ ![ semantic-release] ( https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg )] ( https://github.com/semantic-release/semantic-release )
12+ [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
1613
17- > 此项目同步自 [ sequelize] ( https://github.com/sequelize ) / [ sequelize] ( https://github.com/sequelize/sequelize ) 项目中的 docs .
14+ > 此项目同步自 [ sequelize] ( https://github.com/sequelize ) / [ sequelize] ( https://github.com/sequelize/sequelize ) 项目 .
1815>
1916> 更新日志请参阅: [ CHANGELOG] ( CHANGELOG.md )
2017
21- Sequelize 是一个基于 promise 的 [ Node.js] ( https://nodejs.org/zh-cn /about/ ) [ ORM 工具] ( https://en.wikipedia.org/wiki/Object-relational_mapping ) , 目前支持 [ Postgres] ( https://en.wikipedia.org/wiki/PostgreSQL ) , [ MySQL] ( https://en.wikipedia.org/wiki/MySQL ) , [ MariaDB] ( https://en.wikipedia.org/wiki/MariaDB ) , [ SQLite] ( https://en.wikipedia.org/wiki/SQLite ) 以及 [ Microsoft SQL Server] ( https://en.wikipedia.org/wiki/Microsoft_SQL_Server ) , [ Amazon Redshift ] ( https://docs.aws.amazon. com/redshift/index.html ) 和 [ Snowflake’s Data Cloud ] ( https://docs.snowflake .com/en/user-guide/intro-key-concepts.html ) . 它具有强大的事务支持, 关联关系, 预读和延迟加载,读取复制等功能.
18+ Sequelize 是一个易用且基于 promise 的 [ Node.js] ( https://nodejs.org/en /about/ ) [ ORM 工具] ( https://en.wikipedia.org/wiki/Object-relational_mapping ) 适用于 [ Postgres] ( https://en.wikipedia.org/wiki/PostgreSQL ) , [ MySQL] ( https://en.wikipedia.org/wiki/MySQL ) , [ MariaDB] ( https://en.wikipedia.org/wiki/MariaDB ) , [ SQLite] ( https://en.wikipedia.org/wiki/SQLite ) , [ DB2 ] ( https://en.wikipedia.org/wiki/IBM_Db2_Family ) , [ Microsoft SQL Server] ( https://en.wikipedia.org/wiki/Microsoft_SQL_Server ) , [ Snowflake ] ( https://www.snowflake. com/ ) , [ Oracle DB ] ( https://www.oracle.com/database/ ) 和 [ Db2 for IBM i ] ( https://www.ibm .com/support/pages/db2-ibm-i ) . 它具有强大的事务支持, 关联关系, 预读和延迟加载,读取复制等功能.
2219
23- Sequelize 遵从 [ 语义版本控制] ( http://semver.org ) 和 [ 官方 Node.js LTS 版本] ( https://nodejs.org/en/about/releases/ ) . Sequelize v7 版本正式支持 Node.js ` ^12.22.0 ` , ` ^14.17,0 ` , ` ^16.0.0 ` . 其他版本或可正常工作.
20+ Sequelize 遵从 [ 语义版本控制] ( http://semver.org ) 和 [ 官方 Node.js LTS 版本] ( https://nodejs.org/en/about/releases/ ) . Sequelize v7 版本正式支持 Node.js ` ^14.17,0 ` , ` ^16.0.0 ` . 其他版本或可正常工作.
21+
22+ 你目前正在查看 Sequelize 的** 教程和指南** .你可能还对[ API 参考] ( https://sequelize.org/api/v7/ ) (英文)感兴趣.
2423
25- 你目前正在查看 Sequelize 的** 教程和指南** .你可能还对[ API 参考] ( http://docs.sequelizejs.com/identifiers ) (英文)感兴趣.
2624
27- # 赞赏支持
2825![ 赞赏支持] ( https://raw.githubusercontent.com/demopark/electron-api-demos-Zh_CN/master/assets/img/td.png )
2926
3027
@@ -45,7 +42,9 @@ Sequelize 遵从 [语义版本控制](http://semver.org) 和 [官方 Node.js LTS
4542- [ 从 v5 升级到 v6] ( other-topics/upgrade-to-v6.md )
4643- [ 从 v6 升级到 v7] ( other-topics/upgrade-to-v7.md )
4744
48- ## 文档(v7)
45+ ## 文档(v7-alpha)
46+
47+ ** 注意** 由于当前alpha阶段api调整, 文档中的API参考指向尚未确定. 可前往 [ V7 API 参考] ( https://sequelize.org/api/v7/ ) 自行查询.
4948
5049### 核心概念
5150
@@ -93,7 +92,7 @@ Sequelize 遵从 [语义版本控制](http://semver.org) 和 [官方 Node.js LTS
9392
9493``` sh
9594# 使用 npm
96- npm i sequelize # 这将安装最新版本的 Sequelize
95+ npm install sequelize # 这将安装最新版本的 Sequelize
9796# 使用 yarn
9897yarn add sequelize
9998```
@@ -107,18 +106,50 @@ npm i mariadb # MariaDB
107106npm i sqlite3 # SQLite
108107npm i tedious # Microsoft SQL Server
109108npm i ibm_db # DB2
109+ npm i odbc # IBM i
110+
110111# 使用 yarn
111112yarn add pg pg-hstore # PostgreSQL
112113yarn add mysql2 # MySQL
113114yarn add mariadb # MariaDB
114115yarn add sqlite3 # SQLite
115116yarn add tedious # Microsoft SQL Server
116117yarn add ibm_db # DB2
118+ yarn add odbc # IBM i
117119```
118120
119121## 简单示例
120122
121- ``` js
123+ #### TypeScript
124+
125+ ``` javascript
126+ import { Sequelize , Model , DataTypes , InferAttributes , InferCreationAttributes } from ' sequelize' ;
127+
128+ const sequelize = new Sequelize (' sqlite::memory:' );
129+
130+ class User extends Model < InferAttributes< User> , InferCreationAttributes< User>> {
131+ declare username: string | null ;
132+ declare birthday: Date | null ;
133+ }
134+
135+ User .init ({
136+ username: DataTypes .STRING ,
137+ birthday: DataTypes .DATE
138+ }, { sequelize, modelName: ' user' });
139+
140+ (async () => {
141+ await sequelize .sync ();
142+ const jane = await User .create ({
143+ username: ' janedoe' ,
144+ birthday: new Date (1980 , 6 , 20 ),
145+ });
146+ console .log (jane .toJSON ());
147+ })();
148+ ```
149+
150+ #### JavaScript (CJS)
151+
152+ ``` javascript
122153const { Sequelize , Model , DataTypes } = require (' sequelize' );
123154const sequelize = new Sequelize (' sqlite::memory:' );
124155
0 commit comments