-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
59 lines (56 loc) · 1.43 KB
/
Copy pathdb.js
File metadata and controls
59 lines (56 loc) · 1.43 KB
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
49
50
51
52
53
54
55
56
57
58
59
import { Sequelize } from 'sequelize'
export const SQLize = new Sequelize('database', 'user', 'password', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
// SQLite only
storage: 'database.sqlite',
});
export function Wallets(sequelize) {
return sequelize.define('wallets', {
username: {
type: Sequelize.STRING,
unique: true,
primaryKey: true
},
balance: Sequelize.INTEGER,
address: Sequelize.STRING,
withdraw_address: Sequelize.STRING,
usage_count: {
type: Sequelize.INTEGER,
defaultValue: 0,
allowNull: false,
},
});
}
export function Transactions(Wallets, sequelize) {
return sequelize.define('transactions', {
tx_id: {
type: Sequelize.STRING,
unique: true,
primaryKey: true
},
amount: Sequelize.INTEGER,
type: Sequelize.STRING,
address: Sequelize.STRING,
from: {
type: Sequelize.STRING,
references: {
model: Wallets,
key: 'username'
}
},
to: {
type: Sequelize.STRING,
references: {
model: Wallets,
key: 'username'
}
},
usage_count: {
type: Sequelize.INTEGER,
defaultValue: 0,
allowNull: false,
},
});
}