]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/server/server.ts
Little SQL optimization
[github/Chocobozzz/PeerTube.git] / server / models / server / server.ts
1 import { AllowNull, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { isHostValid } from '../../helpers/custom-validators/servers'
3 import { throwIfNotValid } from '../utils'
4
5 @Table({
6 tableName: 'server',
7 indexes: [
8 {
9 fields: [ 'host' ],
10 unique: true
11 }
12 ]
13 })
14 export class ServerModel extends Model<ServerModel> {
15
16 @AllowNull(false)
17 @Is('Host', value => throwIfNotValid(value, isHostValid, 'valid host'))
18 @Column
19 host: string
20
21 @CreatedAt
22 createdAt: Date
23
24 @UpdatedAt
25 updatedAt: Date
26 }