Use sequelize scopes

This commit is contained in:
Chocobozzz 2017-12-14 10:07:57 +01:00
parent 94edfc3b2a
commit d48ff09d27
No known key found for this signature in database
GPG key ID: 583A612D890159BE
13 changed files with 264 additions and 312 deletions

View file

@ -1,4 +1,3 @@
import { Transaction } from 'sequelize'
import { AllowNull, Column, Default, IsInt, Model, Table } from 'sequelize-typescript'
@Table({
@ -15,21 +14,4 @@ export class ApplicationModel extends Model<ApplicationModel> {
static countTotal () {
return ApplicationModel.count()
}
static loadMigrationVersion () {
const query = {
attributes: [ 'migrationVersion' ]
}
return ApplicationModel.findOne(query).then(data => data ? data.migrationVersion : null)
}
static updateMigrationVersion (newVersion: number, transaction: Transaction) {
const options = {
where: {},
transaction: transaction
}
return ApplicationModel.update({ migrationVersion: newVersion }, options)
}
}