From 127944aacb52721877449a1f202dc0add866ef39 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 11 Jun 2017 17:35:32 +0200 Subject: [PATCH] Better models define typing --- server/models/application.ts | 2 +- server/models/author.ts | 2 +- server/models/job.ts | 2 +- server/models/oauth-client.ts | 4 ++-- server/models/oauth-token.ts | 4 ++-- server/models/pod.ts | 4 ++-- server/models/request-to-pod.ts | 4 ++-- server/models/request-video-event.ts | 4 ++-- server/models/request-video-qadu.ts | 4 ++-- server/models/request.ts | 4 ++-- server/models/tag.ts | 4 ++-- server/models/user-video-rate.ts | 4 ++-- server/models/user.ts | 4 ++-- server/models/video-abuse.ts | 4 ++-- server/models/video-blacklist.ts | 4 ++-- server/models/video-tag.ts | 4 ++-- server/models/video.ts | 4 ++-- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/server/models/application.ts b/server/models/application.ts index 14b87777a..55bb40d84 100644 --- a/server/models/application.ts +++ b/server/models/application.ts @@ -13,7 +13,7 @@ let Application: Sequelize.Model let loadMigrationVersion: ApplicationMethods.LoadMigrationVersion let updateMigrationVersion: ApplicationMethods.UpdateMigrationVersion -export default function defineApplication (sequelize: Sequelize.Sequelize, DataTypes) { +export default function defineApplication (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { Application = sequelize.define('Application', { migrationVersion: { diff --git a/server/models/author.ts b/server/models/author.ts index 3264d3a88..e0fb250f9 100644 --- a/server/models/author.ts +++ b/server/models/author.ts @@ -14,7 +14,7 @@ import { let Author: Sequelize.Model let findOrCreateAuthor: AuthorMethods.FindOrCreateAuthor -export default function defineAuthor (sequelize: Sequelize.Sequelize, DataTypes) { +export default function defineAuthor (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { Author = sequelize.define('Author', { name: { diff --git a/server/models/job.ts b/server/models/job.ts index 1afae8f08..d4380a575 100644 --- a/server/models/job.ts +++ b/server/models/job.ts @@ -15,7 +15,7 @@ import { let Job: Sequelize.Model let listWithLimit: JobMethods.ListWithLimit -export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes) { +export default function defineJob (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { Job = sequelize.define('Job', { state: { diff --git a/server/models/oauth-client.ts b/server/models/oauth-client.ts index 22fae2842..a5438f45a 100644 --- a/server/models/oauth-client.ts +++ b/server/models/oauth-client.ts @@ -14,8 +14,8 @@ let countTotal: OAuthClientMethods.CountTotal let loadFirstClient: OAuthClientMethods.LoadFirstClient let getByIdAndSecret: OAuthClientMethods.GetByIdAndSecret -export default function (sequelize, DataTypes) { - OAuthClient = sequelize.define('OAuthClient', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + OAuthClient = sequelize.define('OAuthClient', { clientId: { type: DataTypes.STRING, diff --git a/server/models/oauth-token.ts b/server/models/oauth-token.ts index d70bd2bce..91cef11dd 100644 --- a/server/models/oauth-token.ts +++ b/server/models/oauth-token.ts @@ -18,8 +18,8 @@ let getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser let getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser let removeByUserId: OAuthTokenMethods.RemoveByUserId -export default function (sequelize, DataTypes) { - OAuthToken = sequelize.define('OAuthToken', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + OAuthToken = sequelize.define('OAuthToken', { accessToken: { type: DataTypes.STRING, diff --git a/server/models/pod.ts b/server/models/pod.ts index 107744c43..fef9d4da6 100644 --- a/server/models/pod.ts +++ b/server/models/pod.ts @@ -27,8 +27,8 @@ let loadByHost: PodMethods.LoadByHost let removeAll: PodMethods.RemoveAll let updatePodsScore: PodMethods.UpdatePodsScore -export default function (sequelize, DataTypes) { - Pod = sequelize.define('Pod', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + Pod = sequelize.define('Pod', { host: { type: DataTypes.STRING, diff --git a/server/models/request-to-pod.ts b/server/models/request-to-pod.ts index 3562069cc..d2f31463c 100644 --- a/server/models/request-to-pod.ts +++ b/server/models/request-to-pod.ts @@ -12,8 +12,8 @@ import { let RequestToPod: Sequelize.Model let removeByRequestIdsAndPod: RequestToPodMethods.RemoveByRequestIdsAndPod -export default function (sequelize, DataTypes) { - RequestToPod = sequelize.define('RequestToPod', {}, { +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + RequestToPod = sequelize.define('RequestToPod', {}, { indexes: [ { fields: [ 'requestId' ] diff --git a/server/models/request-video-event.ts b/server/models/request-video-event.ts index e422649af..32438b581 100644 --- a/server/models/request-video-event.ts +++ b/server/models/request-video-event.ts @@ -24,8 +24,8 @@ let listWithLimitAndRandom: RequestVideoEventMethods.ListWithLimitAndRandom let removeByRequestIdsAndPod: RequestVideoEventMethods.RemoveByRequestIdsAndPod let removeAll: RequestVideoEventMethods.RemoveAll -export default function (sequelize, DataTypes) { - RequestVideoEvent = sequelize.define('RequestVideoEvent', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + RequestVideoEvent = sequelize.define('RequestVideoEvent', { type: { type: DataTypes.ENUM(values(REQUEST_VIDEO_EVENT_TYPES)), diff --git a/server/models/request-video-qadu.ts b/server/models/request-video-qadu.ts index 38627ad55..27ce0ff29 100644 --- a/server/models/request-video-qadu.ts +++ b/server/models/request-video-qadu.ts @@ -29,8 +29,8 @@ let listWithLimitAndRandom: RequestVideoQaduMethods.ListWithLimitAndRandom let removeByRequestIdsAndPod: RequestVideoQaduMethods.RemoveByRequestIdsAndPod let removeAll: RequestVideoQaduMethods.RemoveAll -export default function (sequelize, DataTypes) { - RequestVideoQadu = sequelize.define('RequestVideoQadu', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + RequestVideoQadu = sequelize.define('RequestVideoQadu', { type: { type: DataTypes.ENUM(values(REQUEST_VIDEO_QADU_TYPES)), diff --git a/server/models/request.ts b/server/models/request.ts index 71f81ae66..e6c367f28 100644 --- a/server/models/request.ts +++ b/server/models/request.ts @@ -19,8 +19,8 @@ let listWithLimitAndRandom: RequestMethods.ListWithLimitAndRandom let removeWithEmptyTo: RequestMethods.RemoveWithEmptyTo let removeAll: RequestMethods.RemoveAll -export default function (sequelize, DataTypes) { - Request = sequelize.define('Request', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + Request = sequelize.define('Request', { request: { type: DataTypes.JSON, diff --git a/server/models/tag.ts b/server/models/tag.ts index c4402e83c..54a5f79e5 100644 --- a/server/models/tag.ts +++ b/server/models/tag.ts @@ -13,8 +13,8 @@ import { let Tag: Sequelize.Model let findOrCreateTags: TagMethods.FindOrCreateTags -export default function (sequelize, DataTypes) { - Tag = sequelize.define('Tag', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + Tag = sequelize.define('Tag', { name: { type: DataTypes.STRING, diff --git a/server/models/user-video-rate.ts b/server/models/user-video-rate.ts index 6b71e8412..0326e1796 100644 --- a/server/models/user-video-rate.ts +++ b/server/models/user-video-rate.ts @@ -19,8 +19,8 @@ import { let UserVideoRate: Sequelize.Model let load: UserVideoRateMethods.Load -export default function (sequelize, DataTypes) { - UserVideoRate = sequelize.define('UserVideoRate', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + UserVideoRate = sequelize.define('UserVideoRate', { type: { type: DataTypes.ENUM(values(VIDEO_RATE_TYPES)), diff --git a/server/models/user.ts b/server/models/user.ts index cd383a16a..1a56a6dc3 100644 --- a/server/models/user.ts +++ b/server/models/user.ts @@ -32,8 +32,8 @@ let loadById: UserMethods.LoadById let loadByUsername: UserMethods.LoadByUsername let loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail -export default function (sequelize, DataTypes) { - User = sequelize.define('User', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + User = sequelize.define('User', { password: { type: DataTypes.STRING, diff --git a/server/models/video-abuse.ts b/server/models/video-abuse.ts index 92168439c..5602ef968 100644 --- a/server/models/video-abuse.ts +++ b/server/models/video-abuse.ts @@ -15,8 +15,8 @@ import { let VideoAbuse: Sequelize.Model let listForApi: VideoAbuseMethods.ListForApi -export default function (sequelize, DataTypes) { - VideoAbuse = sequelize.define('VideoAbuse', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + VideoAbuse = sequelize.define('VideoAbuse', { reporterUsername: { type: DataTypes.STRING, diff --git a/server/models/video-blacklist.ts b/server/models/video-blacklist.ts index f36756085..040ed03d7 100644 --- a/server/models/video-blacklist.ts +++ b/server/models/video-blacklist.ts @@ -17,8 +17,8 @@ let listForApi: BlacklistedVideoMethods.ListForApi let loadById: BlacklistedVideoMethods.LoadById let loadByVideoId: BlacklistedVideoMethods.LoadByVideoId -export default function (sequelize, DataTypes) { - BlacklistedVideo = sequelize.define('BlacklistedVideo', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + BlacklistedVideo = sequelize.define('BlacklistedVideo', {}, { indexes: [ diff --git a/server/models/video-tag.ts b/server/models/video-tag.ts index 2ccaf820d..514eede25 100644 --- a/server/models/video-tag.ts +++ b/server/models/video-tag.ts @@ -11,8 +11,8 @@ import { let VideoTag: Sequelize.Model -export default function (sequelize, DataTypes) { - VideoTag = sequelize.define('VideoTag', {}, { +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + VideoTag = sequelize.define('VideoTag', {}, { indexes: [ { fields: [ 'videoId' ] diff --git a/server/models/video.ts b/server/models/video.ts index 2234664f4..78119f516 100644 --- a/server/models/video.ts +++ b/server/models/video.ts @@ -68,8 +68,8 @@ let loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor let loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags let searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags -export default function (sequelize, DataTypes) { - Video = sequelize.define('Video', +export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { + Video = sequelize.define('Video', { id: { type: DataTypes.UUID, -- 2.25.1