1 import { AllowNull, Column, CreatedAt, DataType, HasMany, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { OAuthTokenModel } from './oauth-token'
5 tableName: 'oAuthClient',
8 fields: [ 'clientId' ],
12 fields: [ 'clientId', 'clientSecret' ],
17 export class OAuthClientModel extends Model {
27 @Column(DataType.ARRAY(DataType.STRING))
30 @Column(DataType.ARRAY(DataType.STRING))
31 redirectUris: string[]
39 @HasMany(() => OAuthTokenModel, {
42 OAuthTokens: OAuthTokenModel[]
44 static countTotal () {
45 return OAuthClientModel.count()
48 static loadFirstClient () {
49 return OAuthClientModel.findOne()
52 static getByIdAndSecret (clientId: string, clientSecret: string) {
56 clientSecret: clientSecret
60 return OAuthClientModel.findOne(query)