aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pod-interface.ts
blob: 14c88bec6257526942fddfc5f00189aacda3efed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as Sequelize from 'sequelize'

export namespace PodMethods {
  export type ToFormatedJSON = () => void

  export type CountAll = (callback) => void
  export type IncrementScores = (ids, value, callback) => void
  export type List = (callback) => void
  export type ListAllIds = (transaction, callback) => void
  export type ListRandomPodIdsWithRequest = (limit, tableWithPods, tableWithPodsJoins, callback) => void
  export type ListBadPods = (callback) => void
  export type Load = (id, callback) => void
  export type LoadByHost = (host, callback) => void
  export type RemoveAll = (callback) => void
  export type UpdatePodsScore = (goodPods, badPods) => void
}

export interface PodClass {
  countAll: PodMethods.CountAll
  incrementScores: PodMethods.IncrementScores
  list: PodMethods.List
  listAllIds: PodMethods.ListAllIds
  listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
  listBadPods: PodMethods.ListBadPods
  load: PodMethods.Load
  loadByHost: PodMethods.LoadByHost
  removeAll: PodMethods.RemoveAll
  updatePodsScore: PodMethods.UpdatePodsScore
}

export interface PodAttributes {
  host?: string
  publicKey?: string
  score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
  email?: string
}

export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
  id: number
  createdAt: Date
  updatedAt: Date

  toFormatedJSON: PodMethods.ToFormatedJSON,
}

export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}