{"id":13512179,"url":"https://github.com/demopark/sequelize-docs-Zh-CN","last_synced_at":"2025-03-30T22:32:01.496Z","repository":{"id":37359659,"uuid":"97200082","full_name":"demopark/sequelize-docs-Zh-CN","owner":"demopark","description":"Sequelize 文档的中文版本:  v7.0.0-alpha.18 | v6.32.0","archived":false,"fork":false,"pushed_at":"2025-01-02T06:49:56.000Z","size":643,"stargazers_count":3001,"open_issues_count":25,"forks_count":497,"subscribers_count":60,"default_branch":"master","last_synced_at":"2025-03-28T16:00:27.746Z","etag":null,"topics":["mysql","orm","postgresql","sequelize","transaction"],"latest_commit_sha":null,"homepage":"https://demopark.github.io/sequelize-docs-Zh-CN/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/demopark.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"demopark","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://raw.githubusercontent.com/demopark/electron-api-demos-Zh_CN/master/assets/img/td.png"]}},"created_at":"2017-07-14T06:19:52.000Z","updated_at":"2025-03-24T10:31:23.000Z","dependencies_parsed_at":"2023-01-28T04:30:41.157Z","dependency_job_id":"627eea20-3a3e-440a-a9a3-8cd6cfab10e0","html_url":"https://github.com/demopark/sequelize-docs-Zh-CN","commit_stats":{"total_commits":65,"total_committers":14,"mean_commits":4.642857142857143,"dds":0.2153846153846154,"last_synced_commit":"40b3c827cff12644fda552f5d6f7190463683033"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demopark%2Fsequelize-docs-Zh-CN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demopark%2Fsequelize-docs-Zh-CN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demopark%2Fsequelize-docs-Zh-CN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demopark%2Fsequelize-docs-Zh-CN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demopark","download_url":"https://codeload.github.com/demopark/sequelize-docs-Zh-CN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246390897,"owners_count":20769475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","orm","postgresql","sequelize","transaction"],"created_at":"2024-08-01T03:01:34.151Z","updated_at":"2025-03-30T22:32:01.488Z","avatar_url":"https://github.com/demopark.png","language":null,"funding_links":["https://patreon.com/demopark","https://raw.githubusercontent.com/demopark/electron-api-demos-Zh_CN/master/assets/img/td.png","https://opencollective.com/sequelize"],"categories":["Others","Code"],"sub_categories":["library/repositories"],"readme":"# Sequelize Docs 中文版\n\n![](http://docs.sequelizejs.com/manual/asset/logo-small.png)\n\n[![npm version](https://badgen.net/npm/v/@sequelize/core)](https://www.npmjs.com/package/@sequelize/core)\n[![npm downloads](https://badgen.net/npm/dm/@sequelize/core)](https://www.npmjs.com/package/@sequelize/core)\n[![contributors](https://img.shields.io/github/contributors/sequelize/sequelize)](https://github.com/sequelize/sequelize/graphs/contributors)\n[![Open Collective](https://img.shields.io/opencollective/backers/sequelize)](https://opencollective.com/sequelize#section-contributors)\n[![sponsor](https://img.shields.io/opencollective/all/sequelize?label=sponsors)](https://opencollective.com/sequelize)\n[![Merged PRs](https://badgen.net/github/merged-prs/sequelize/sequelize)](https://github.com/sequelize/sequelize)\n[![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)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003e 此项目同步自 [sequelize](https://github.com/sequelize) / [sequelize](https://github.com/sequelize/sequelize) 项目.\n\u003e \n\u003e 更新日志请参阅: [CHANGELOG](CHANGELOG.md)\n\nSequelize 是一个易用且基于 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). 它具有强大的事务支持, 关联关系, 预读和延迟加载,读取复制等功能.\n\nSequelize 遵从 [语义版本控制](http://semver.org) 和 [官方 Node.js LTS 版本](https://nodejs.org/en/about/releases/). Sequelize v7 版本正式支持 Node.js `^14.17,0`, `^16.0.0`. 其他版本或可正常工作.\n\n你目前正在查看 Sequelize 的**教程和指南**.你可能还对[API 参考](https://sequelize.org/api/v7/) (英文)感兴趣.\n\n\n![赞赏支持](https://raw.githubusercontent.com/demopark/electron-api-demos-Zh_CN/master/assets/img/td.png)\n\n\n## 文档版本\n\n- [v7 中文文档](https://github.com/demopark/sequelize-docs-Zh-CN/tree/master)(开发版本)\n\n- [v6 中文文档](https://github.com/demopark/sequelize-docs-Zh-CN/tree/v6)(保持更新)\n\n- [v5 中文文档](https://github.com/demopark/sequelize-docs-Zh-CN/tree/v5)(停止更新)\n\n- [v4 中文文档](https://github.com/demopark/sequelize-docs-Zh-CN/tree/v4)(停止更新)\n\n## 主要版本变更日志\n\n在此处可以找到主要版本的升级信息：\n\n- [从 v5 升级到 v6](other-topics/upgrade-to-v6.md)\n- [从 v6 升级到 v7](other-topics/upgrade-to-v7.md)\n\n## 文档(v7-alpha)\n\n**注意** 由于当前alpha阶段api调整, 文档中的API参考指向尚未确定. 可前往 [V7 API 参考](https://sequelize.org/api/v7/)自行查询.\n\n### 核心概念\n\n- [Getting Started - 入门](core-concepts/getting-started.md)\n- [Model Basics - 模型基础](core-concepts/model-basics.md)\n- [Model Instances - 模型实例](core-concepts/model-instances.md)\n- [Model Querying - Basics - 模型查询(基础)](core-concepts/model-querying-basics.md)\n- [Model Querying - Finders - 模型查询(查找器)](core-concepts/model-querying-finders.md)\n- [Getters, Setters \u0026 Virtuals - 获取器, 设置器 \u0026 虚拟字段](core-concepts/getters-setters-virtuals.md)\n- [Validations \u0026 Constraints - 验证 \u0026 约束](core-concepts/validations-and-constraints.md)\n- [Raw Queries - 原始查询](core-concepts/raw-queries.md)\n- [Associations - 关联](core-concepts/assocs.md)\n- [Paranoid - 偏执表](core-concepts/paranoid.md)\n\n### 高级关联概念\n\n- [Eager Loading - 预先加载](advanced-association-concepts/eager-loading.md)\n- [Creating with Associations - 创建关联](advanced-association-concepts/creating-with-associations.md)\n- [Advanced M:N Associations - 高级 M:N 关联](advanced-association-concepts/advanced-many-to-many.md)\n- [Association Scopes - 关联作用域](advanced-association-concepts/association-scopes.md)\n- [Polymorphic Associations - 多态关联](advanced-association-concepts/polymorphic-associations.md)\n\n### 其它主题\n\n- [Dialect-Specific Things - 方言特定事项](other-topics/dialect-specific-things.md)\n- [Transactions - 事务](other-topics/transactions.md)\n- [Hooks - 钩子](other-topics/hooks.md)\n- [Query Interface - 查询接口](other-topics/query-interface.md)\n- [Naming Strategies - 命名策略](other-topics/naming-strategies.md)\n- [Scopes - 作用域](other-topics/scopes.md)\n- [Sub Queries - 子查询](other-topics/sub-queries.md)\n- [Other Data Types - 其他数据类型](other-topics/other-data-types.md)\n- [Constraints \u0026 Circularities - 约束 \u0026 循环](other-topics/constraints-and-circularities.md)\n- [Extending Data Types - 扩展数据类型](other-topics/extending-data-types.md)\n- [Indexes - 索引](other-topics/indexes.md)\n- [Optimistic Locking - 乐观锁定](other-topics/optimistic-locking.md)\n- [Read Replication - 读取复制](other-topics/read-replication.md)\n- [Connection Pool - 连接池](other-topics/connection-pool.md)\n- [Working with Legacy Tables - 使用遗留表](other-topics/legacy.md)\n- [Migrations - 迁移](other-topics/migrations.md)\n- [TypeScript](other-topics/typescript.md)\n- [Resources - 资源](other-topics/resources.md)\n\n## 安装\n\n```sh\n# 使用 npm\nnpm install sequelize # 这将安装最新版本的 Sequelize\n# 使用 yarn\nyarn add sequelize\n```\n\n```sh\n# 用于支持数据库方言的库:\n# 使用 npm\nnpm i pg pg-hstore # PostgreSQL\nnpm i mysql2 # MySQL\nnpm i mariadb # MariaDB\nnpm i sqlite3 # SQLite\nnpm i tedious # Microsoft SQL Server\nnpm i ibm_db # DB2\nnpm i odbc # IBM i\n\n# 使用 yarn\nyarn add pg pg-hstore # PostgreSQL\nyarn add mysql2 # MySQL\nyarn add mariadb # MariaDB\nyarn add sqlite3 # SQLite\nyarn add tedious # Microsoft SQL Server\nyarn add ibm_db # DB2\nyarn add odbc # IBM i\n```\n\n## 简单示例\n\n#### TypeScript\n\n```javascript\nimport { Sequelize, Model, DataTypes, InferAttributes, InferCreationAttributes } from 'sequelize';\n\nconst sequelize = new Sequelize('sqlite::memory:');\n\nclass User extends Model\u003cInferAttributes\u003cUser\u003e, InferCreationAttributes\u003cUser\u003e\u003e {\n  declare username: string | null;\n  declare birthday: Date | null;\n}\n\nUser.init({\n  username: DataTypes.STRING,\n  birthday: DataTypes.DATE\n}, { sequelize, modelName: 'user' });\n\n(async () =\u003e {\n  await sequelize.sync();\n  const jane = await User.create({\n    username: 'janedoe',\n    birthday: new Date(1980, 6, 20),\n  });\n  console.log(jane.toJSON());\n})();\n```\n\n#### JavaScript (CJS)\n\n```javascript\nconst { Sequelize, Model, DataTypes } = require('sequelize');\nconst sequelize = new Sequelize('sqlite::memory:');\n\nclass User extends Model {}\nUser.init({\n  username: DataTypes.STRING,\n  birthday: DataTypes.DATE\n}, { sequelize, modelName: 'user' });\n\n(async () =\u003e {\n  await sequelize.sync();\n  const jane = await User.create({\n    username: 'janedoe',\n    birthday: new Date(1980, 6, 20)\n  });\n  console.log(jane.toJSON());\n})();\n```\n\n请通过 [Getting started - 入门](core-concepts/getting-started.md) 来学习更多相关内容. 如果你想要学习 Sequelize API 请通过 [API 参考](https://sequelize.org/api/v7/) (英文).\n\n## 下载量趋势\n\n[近五年Sequelize下载量趋势](https://npm-compare.com/img/npm-trend/FIVE_YEARS/sequelize.png)\n\n\u003ca href=\"https://npm-compare.com/sequelize#timeRange=FIVE_YEARS\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://npm-compare.com/img/npm-trend/FIVE_YEARS/sequelize.png\" width=\"100%\" alt=\"NPM Usage Trend of sequelize\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemopark%2Fsequelize-docs-Zh-CN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemopark%2Fsequelize-docs-Zh-CN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemopark%2Fsequelize-docs-Zh-CN/lists"}