blob: 445b0ff09dbfe0aa060921185f3e53a4cfe8f7e6 (
plain) (
blame)
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
|
import { DataTypes, Op } from 'sequelize'
import db from './index'
const User = db.define('user', {
id: {
type: DataTypes.INTEGER,
primaryKey: true
},
nick: DataTypes.STRING,
passw: DataTypes.STRING,
banned: DataTypes.INTEGER,
last_seen: DataTypes.DATE
}, {
timestamps: false
})
export const getMonthlyActiveUsers = async () => {
const seenDate = new Date()
seenDate.setMonth(seenDate.getMonth() - 1)
return await User.count({
where: {
banned: {
[Op.eq]: 0
},
last_seen: {
[Op.gt]: seenDate
}
}
})
}
export const getUserByName = async (name = '') => {
return await User.findOne({
where: {
nick: {
[Op.eq]: name
},
banned: {
[Op.eq]: 0
}
}
})
}
|