From e02643f32e4c97ca307f8fc5b69be79c40d70a3b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 22 May 2017 20:58:25 +0200 Subject: Type models --- server/models/pod-interface.ts | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 server/models/pod-interface.ts (limited to 'server/models/pod-interface.ts') diff --git a/server/models/pod-interface.ts b/server/models/pod-interface.ts new file mode 100644 index 000000000..14c88bec6 --- /dev/null +++ b/server/models/pod-interface.ts @@ -0,0 +1,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 { + id: number + createdAt: Date + updatedAt: Date + + toFormatedJSON: PodMethods.ToFormatedJSON, +} + +export interface PodModel extends PodClass, Sequelize.Model {} -- cgit v1.2.3