This repository has been archived by the owner on Feb 14, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdb.mjs
119 lines (115 loc) · 2.27 KB
/
db.mjs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';
import Sequelize from 'sequelize';
let { DataTypes, Model } = Sequelize,
{ STRING, BOOLEAN, ARRAY, DATE, JSONB, INTEGER } = DataTypes;
const sequelize = new Sequelize({
database: process.env.SERVERDB,
username: process.env.SERVERUSERNAME,
password: process.env.SERVERPASSWORD,
host: process.env.SERVERIP,
port: 5432,
dialect: 'postgres',
logging: false
});
export class User extends Model {}
User.init(
{
id: {
type: STRING,
primaryKey: true
},
username: STRING(60),
displayName: STRING,
email: STRING(60),
staff: STRING,
password: STRING(2000),
domain: STRING,
subdomain: STRING,
bannedAt: DATE,
sessions: ARRAY(JSONB)
},
{
sequelize
}
);
User.sync({
force: false
})
.then(() => {
console.log('Users synced to database successfully!');
})
.catch(err => {
console.error('an error occurred while performing this operation', err);
});
export class Uploads extends Model {}
Uploads.init(
{
filename: {
type: STRING,
primaryKey: true
},
userid: STRING,
size: INTEGER
},
{
sequelize
}
);
Uploads.sync({
force: false
})
.then(() => {
console.log('Uploads synced to database successfully!');
})
.catch(err => {
console.error('an error occurred while performing this operation', err);
});
export class Domains extends Model {}
Domains.init(
{
domain: {
type: STRING,
primaryKey: true
},
allowsSubdomains: BOOLEAN
},
{
sequelize
}
);
Domains.sync({
force: false
})
.then(() => {
console.log('Domains synced to database successfully!');
})
.catch(err => {
console.error('an error occurred while performing this operation', err);
});
export class Instructions extends Model {}
Instructions.init(
{
name: {
primaryKey: true,
type: STRING
},
steps: ARRAY(STRING(2000)),
filename: STRING(500),
fileContent: STRING(5000),
description: STRING(300),
displayName: STRING
},
{
sequelize
}
);
Instructions.sync({
force: false
})
.then(() => {
console.log('Instructions synced to database successfully!');
})
.catch(err => {
console.error('an error occurred while performing this operation', err);
});
export { sequelize as __sequelize };