Gathering detailed insights and metrics for egg-sequelize-ts
Gathering detailed insights and metrics for egg-sequelize-ts
Gathering detailed insights and metrics for egg-sequelize-ts
Gathering detailed insights and metrics for egg-sequelize-ts
npm install egg-sequelize-ts
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
24 Stars
99 Commits
10 Forks
1 Watchers
10 Branches
1 Contributors
Updated on Aug 27, 2024
Latest Version
0.2.3-0
Package Id
egg-sequelize-ts@0.2.3-0
Unpacked Size
25.87 kB
Size
8.78 kB
File Count
9
NPM Version
6.4.1
Node Version
8.11.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
注意:这个项目已经不再维护或更新。可能存在安全漏洞或与当前技术栈不兼容的风险。请考虑使用其他更现代的解决方案。
插件只是将 egg-sequelize
中的 sequelize 替换为 sequelize-typescript, 同时保证用户在 egg.js 创建的项目中使用 egg-sequelize
的方法尽量一致,在使用时的不同,我将下面一一阐述。 其他内容部分请查看 egg-sequelize。
此插件已在生产项目中得到实践。
能让使用 typescript
编写的 egg.js 项目中能够使用 sequelize方法,并同时得到egg.js所赋予的功能。
1$ npm i --save egg-sequelize-ts 2$ yarn add egg-sequelize-ts
config/plugin.js
config/plugin.js
文件中引入 egg-sequelize-ts
组件1exports.sequelize = { 2 enable: true, 3 package: 'egg-sequelize-ts' 4}
conif/config.{env}.js
在 conif/config.{env}.js
中编写 sequelize 配置1 config.sequelize = { 2 dialect: 'mysql', 3 host: '127.0.0.1', 4 port: 3306, 5 database: 'database' 6 };
分别以 model/user.js 和 service/user.js 举例说明
note 注意我们都是从
sequelize-typescript
中导出类名,方法,属性等。
1// app/model/user.js 2 3/** 4 * @desc 用户表 5 */ 6import { AutoIncrement, Column, DataType, Model, PrimaryKey, Table } from 'sequelize-typescript'; 7@Table({ 8 modelName: 'user' 9}) 10export class User extends Model<User> { 11 12 @PrimaryKey 13 @AutoIncrement 14 @Column({ 15 type: DataType.INTEGER(11), 16 comment: '用户ID', 17 comment: 'user id' 18 }) 19 id: number; 20 21 @Column({ 22 comment: '用户姓名', 23 }) 24 name: string; 25 26 @Column({ 27 comment: '用户邮箱' 28 }) 29 email: string; 30 31 @Column({ 32 comment: '用户手机号码' 33 }) 34 phone: string; 35 36 @Column({ 37 field: 'created_at' 38 }) 39 createdAt: Date; 40 41 @Column({ 42 field: 'updated_at' 43 }) 44 updatedAt: Date; 45}; 46export default () => User; 47
1// app/service/user.js 2import { Service } from 'egg'; 3import { Sequelize } from 'sequelize-typescript'; 4 5class UserService extends Service { 6 async index() { 7 const { or } = Sequelize.Op; 8 const users = await this.ctx.model.User.findOne({ 9 where: { 10 [or]: [ 11 { name, phone }, 12 { id } 13 ] 14 } 15 }); 16 this.ctx.body = users; 17 } 18}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
87 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More