Coder Social home page Coder Social logo

911061873 / sequelize-docs-zh-cn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from demopark/sequelize-docs-zh-cn

0.0 0.0 0.0 638 KB

Sequelize 文档的中文版本: v7.0.0-alpha.18 | v6.32.0

Home Page: https://demopark.github.io/sequelize-docs-Zh-CN/

License: GNU General Public License v2.0

sequelize-docs-zh-cn's Introduction

Sequelize Docs 中文版

npm version npm downloads contributors Open Collective sponsor Merged PRs semantic-release License: MIT

此项目同步自 sequelize / sequelize 项目.

更新日志请参阅: CHANGELOG

Sequelize 是一个易用且基于 promise 的 Node.js ORM 工具 适用于 Postgres, MySQL, MariaDB, SQLite, DB2, Microsoft SQL Server, Snowflake, Oracle DBDb2 for IBM i. 它具有强大的事务支持, 关联关系, 预读和延迟加载,读取复制等功能.

Sequelize 遵从 语义版本控制官方 Node.js LTS 版本. Sequelize v7 版本正式支持 Node.js ^14.17,0, ^16.0.0. 其他版本或可正常工作.

你目前正在查看 Sequelize 的教程和指南.你可能还对API 参考 (英文)感兴趣.

赞赏支持

文档版本

主要版本变更日志

在此处可以找到主要版本的升级信息:

文档(v7-alpha)

注意 由于当前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

简单示例

TypeScript

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());
})();

JavaScript (CJS)

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 参考 (英文).

sequelize-docs-zh-cn's People

Contributors

demopark avatar xiaohp avatar cocacolf avatar carlhey avatar kennytian avatar xiaoyao96 avatar wujjpp avatar xlfsummer avatar simonguo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.