Use sequelize scopes
This commit is contained in:
parent
94edfc3b2a
commit
d48ff09d27
13 changed files with 264 additions and 312 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue