-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
93 lines (89 loc) · 1.88 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { Sequelize, DataTypes } from 'sequelize';
const seq = new Sequelize({
dialect: 'sqlite',
storage: 'lib.sqlite'
});
try {
seq.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
export const Messages = seq.define('messages', {
id: {
type: DataTypes.MEDIUMINT(),
autoIncrement: true,
primaryKey: true,
},
key: {
type: DataTypes.TEXT()
},
from_id: {
type: DataTypes.BIGINT(),
defaultValue: 0,
},
message_id: {
type: DataTypes.BIGINT(),
defaultValue: 0,
},
file_name: {
type: DataTypes.TEXT()
},
file: {
type: DataTypes.BLOB()
}
}, {
timestamps: false,
foreignKey: { name:'messages', unique: false }
});
export const Users = seq.define('users', {
id: {
type: DataTypes.MEDIUMINT(),
autoIncrement: true,
primaryKey: true,
},
chat_id: {
type: DataTypes.BIGINT(),
defaultValue: 0,
},
user_id: {
type: DataTypes.BIGINT(),
defaultValue: 0,
},
last_key: {
type: DataTypes.TEXT(),
},
name: {
type: DataTypes.TEXT(),
},
email: {
type: DataTypes.TEXT(),
},
user_ie: {
type: DataTypes.MEDIUMINT(),
defaultValue: 0,
},
user_sn: {
type: DataTypes.MEDIUMINT(),
defaultValue: 0,
},
user_tf: {
type: DataTypes.MEDIUMINT(),
defaultValue: 0,
},
user_jp: {
type: DataTypes.MEDIUMINT(),
defaultValue: 0,
},
state: {
type: DataTypes.MEDIUMINT(),
defaultValue: 0,
},
last_message_id: {
type: DataTypes.BIGINT(),
defaultValue: 0,
}
}, {
timestamps: false,
foreignKey: { name:'users', unique: false }
});