diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-08 20:08:16 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-08 20:08:16 -0500 |
commit | e0531157a745ac6178d55cc159b5932fa36ff20f (patch) | |
tree | a8de340d0c48269619e9bfde536932eb08556593 /src/lib/models/Stat.ts | |
parent | 0e160ae77477f0986a02746e84158329299f438f (diff) | |
download | tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.gz tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.bz2 tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.zip |
database migrations - use jsonb over text + JSON.parse, refactor bad word & automod - store word in shared db
closes: #53
Diffstat (limited to 'src/lib/models/Stat.ts')
-rw-r--r-- | src/lib/models/Stat.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/models/Stat.ts b/src/lib/models/Stat.ts index 06ee21f..8f90724 100644 --- a/src/lib/models/Stat.ts +++ b/src/lib/models/Stat.ts @@ -1,6 +1,5 @@ import { type Sequelize } from 'sequelize'; import { BaseModel } from './BaseModel.js'; -import { jsonBigint } from './__helpers.js'; const { DataTypes } = (await import('sequelize')).default; type Environment = 'production' | 'development' | 'beta'; @@ -34,7 +33,17 @@ export class Stat extends BaseModel<StatModel, StatModelCreationAttributes> impl Stat.init( { environment: { type: DataTypes.STRING, primaryKey: true }, - commandsUsed: jsonBigint('commandsUsed') + commandsUsed: { + type: DataTypes.TEXT, + get: function (): bigint { + return BigInt(this.getDataValue('commandsUsed')); + }, + set: function (val: bigint) { + return this.setDataValue('commandsUsed', <any>`${val}`); + }, + allowNull: false, + defaultValue: `${0n}` + } }, { sequelize } ); |