-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdb.js
48 lines (42 loc) · 967 Bytes
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { Sequelize, DataTypes } = require('sequelize')
let bizSequelize
exports.getDB = async function() {
if (bizSequelize) {
return bizSequelize
}
// dtm_busi中存在 user_account 和 barrier两张表
// 可替换自己本地db地址
bizSequelize = new Sequelize('dtm_busi', 'root', '***', {
host: '127.0.0.1',
port: 3306,
dialect: 'mysql',
})
await bizSequelize.authenticate()
return bizSequelize
}
let UserAccount
exports.initModel = function(sequelize) {
UserAccount = sequelize.define('user_account', {
id: {
type: DataTypes.BIGINT,
primaryKey: true,
},
userId: {
type: DataTypes.BIGINT,
},
balance: {
type: DataTypes.NUMBER
},
tradingBalance: {
type: DataTypes.NUMBER
}
}, {
tableName: 'user_account',
underscored: true,
createdAt: 'create_time',
updatedAt: 'update_time',
})
}
exports.getUserAccount = function() {
return UserAccount
}