Một mục tập trung dữ liệu trong kho dữ liệu GitHub của TopGit: eggjs/egg-sequelize, 612 sao, nhóm Data, JavaScript. Sequelize for Egg.js
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
NOTE: This plugin just for integrate Sequelize into Egg.js, more documentation please visit http://sequelizejs.com.
Install
$ npm i --save egg-sequelize
$ npm install --save mysql2 # For both mysql and mariadb dialects
# Or use other database backend.
$ npm install --save pg pg-hstore # PostgreSQL
$ npm install --save tedious # MSSQL
Edit your own configurations in conif/config.{env}.js
exports.sequelize = {
dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
database: 'test',
host: 'localhost',
port: 3306,
username: 'root',
password: '',
// delegate: 'myModel', // load all models to `app[delegate]` and `ctx[delegate]`, default to `model`
// baseDir: 'my_model', // load all files in `app/${baseDir}` as models, default to `model`
// exclude: 'index.js', // ignore `app/${baseDir}/index.js` when load models, support glob and array
// more sequelize options
};
You can also use the connection uri to configure the connection:
exports.sequelize = {
dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
connectionUri: 'mysql://root:@127.0.0.1:3306/test',
// delegate: 'myModel', // load all models to `app[delegate]` and `ctx[delegate]`, default to `model`
// baseDir: 'my_model', // load all files in `app/${baseDir}` as models, default to `model`
// exclude: 'index.js', // ignore `app/${baseDir}/index.js` when load models, support glob and array
// more sequelize options
};
egg-sequelize has a default sequelize options below
If you define the same model for different datasource, the same model file will be excute twice for different database, so we can use the secound argument to get the sequelize instance:
// app/model/user.js
// if this file will load multiple times for different datasource
// we can use the secound argument to get the sequelize instance
module.exports = (app, model) => {
const { STRING, INTEGER, DATE } = app.Sequelize;
const User = model.define('user', {
login: STRING,
name: STRING(30),
password: STRING(32),
age: INTEGER,
last_sign_in_at: DATE,
created_at: DATE,
updated_at: DATE,
});
return User;
};
Customize Sequelize
By default, egg-sequelize will use sequelize@5, you can cusomize sequelize version by pass sequelize instance with config.sequelize.Sequelize like this:
eggjs/egg-sequelize có 612 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/eggjs/egg-sequelize. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
eggjs/egg-sequelize có những chủ đề gì?
GitHub topics của eggjs/egg-sequelize: "egg", "egg-plugin", "orm", "sequelize". TopGit xếp repo vào nhóm Data.
eggjs/egg-sequelize còn đang phát triển không?
Commit gần nhất trên eggjs/egg-sequelize là 2.5 năm trước (theo timestamp GitHub). Repo có 135 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
eggjs/egg-sequelize là gì?
eggjs/egg-sequelize (eggjs/egg-sequelize) là dự án JavaScript trên GitHub. Theo mô tả gốc: Sequelize for Egg.js
eggjs/egg-sequelize so với các dự án Data khác thế nào?
eggjs/egg-sequelize được TopGit xếp vào nhóm Data, với 612 sao GitHub và viết bằng JavaScript. Xem trang chủ đề Data trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
eggjs/egg-sequelize viết bằng ngôn ngữ gì?
eggjs/egg-sequelize chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao eggjs/egg-sequelize được xếp vào nhóm Data?
TopGit xếp eggjs/egg-sequelize vào nhóm Data dựa trên GitHub topics và mô tả của repo (gắn thẻ: "egg", "egg-plugin", "orm"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về egg-sequelize?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về egg-sequelize.