diff options
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 } ); |