]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/pod/pod-interface.ts
Remove sequelize deprecated operators
[github/Chocobozzz/PeerTube.git] / server / models / pod / pod-interface.ts
1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3
4 // Don't use barrel, import just what we need
5 import { Pod as FormattedPod } from '../../../shared/models/pods/pod.model'
6 import { ResultList } from '../../../shared/models/result-list.model'
7
8 export namespace PodMethods {
9 export type ToFormattedJSON = (this: PodInstance) => FormattedPod
10
11 export type CountAll = () => Promise<number>
12
13 export type IncrementScores = (ids: number[], value: number) => Promise<[ number, PodInstance[] ]>
14
15 export type List = () => Promise<PodInstance[]>
16
17 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<PodInstance> >
18
19 export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
20
21 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string) => Promise<number[]>
22
23 export type ListBadPods = () => Promise<PodInstance[]>
24
25 export type Load = (id: number) => Promise<PodInstance>
26
27 export type LoadByHost = (host: string) => Promise<PodInstance>
28
29 export type RemoveAll = () => Promise<number>
30
31 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
32 }
33
34 export interface PodClass {
35 countAll: PodMethods.CountAll
36 incrementScores: PodMethods.IncrementScores
37 list: PodMethods.List
38 listForApi: PodMethods.ListForApi
39 listAllIds: PodMethods.ListAllIds
40 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
41 listBadPods: PodMethods.ListBadPods
42 load: PodMethods.Load
43 loadByHost: PodMethods.LoadByHost
44 removeAll: PodMethods.RemoveAll
45 updatePodsScore: PodMethods.UpdatePodsScore
46 }
47
48 export interface PodAttributes {
49 id?: number
50 host?: string
51 publicKey?: string
52 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
53 email?: string
54 }
55
56 export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
57 createdAt: Date
58 updatedAt: Date
59
60 toFormattedJSON: PodMethods.ToFormattedJSON,
61 }
62
63 export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}