diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-22 20:58:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-25 17:32:16 +0200 |
commit | e02643f32e4c97ca307f8fc5b69be79c40d70a3b (patch) | |
tree | b7f6269913cd5a0e4f26a9461a043deb0c168be0 /server/models/request-to-pod.ts | |
parent | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (diff) | |
download | PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.tar.gz PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.tar.zst PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.zip |
Type models
Diffstat (limited to 'server/models/request-to-pod.ts')
-rw-r--r-- | server/models/request-to-pod.ts | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/server/models/request-to-pod.ts b/server/models/request-to-pod.ts index 479202e40..681f808b7 100644 --- a/server/models/request-to-pod.ts +++ b/server/models/request-to-pod.ts | |||
@@ -1,5 +1,19 @@ | |||
1 | module.exports = function (sequelize, DataTypes) { | 1 | import * as Sequelize from 'sequelize' |
2 | const RequestToPod = sequelize.define('RequestToPod', {}, { | 2 | |
3 | import { addMethodsToModel } from './utils' | ||
4 | import { | ||
5 | RequestToPodClass, | ||
6 | RequestToPodInstance, | ||
7 | RequestToPodAttributes, | ||
8 | |||
9 | RequestToPodMethods | ||
10 | } from './request-to-pod-interface' | ||
11 | |||
12 | let RequestToPod: Sequelize.Model<RequestToPodInstance, RequestToPodAttributes> | ||
13 | let removeByRequestIdsAndPod: RequestToPodMethods.RemoveByRequestIdsAndPod | ||
14 | |||
15 | export default function (sequelize, DataTypes) { | ||
16 | RequestToPod = sequelize.define('RequestToPod', {}, { | ||
3 | indexes: [ | 17 | indexes: [ |
4 | { | 18 | { |
5 | fields: [ 'requestId' ] | 19 | fields: [ 'requestId' ] |
@@ -11,18 +25,20 @@ module.exports = function (sequelize, DataTypes) { | |||
11 | fields: [ 'requestId', 'podId' ], | 25 | fields: [ 'requestId', 'podId' ], |
12 | unique: true | 26 | unique: true |
13 | } | 27 | } |
14 | ], | 28 | ] |
15 | classMethods: { | ||
16 | removeByRequestIdsAndPod | ||
17 | } | ||
18 | }) | 29 | }) |
19 | 30 | ||
31 | const classMethods = [ | ||
32 | removeByRequestIdsAndPod | ||
33 | ] | ||
34 | addMethodsToModel(RequestToPod, classMethods) | ||
35 | |||
20 | return RequestToPod | 36 | return RequestToPod |
21 | } | 37 | } |
22 | 38 | ||
23 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |
24 | 40 | ||
25 | function removeByRequestIdsAndPod (requestsIds, podId, callback) { | 41 | removeByRequestIdsAndPod = function (requestsIds, podId, callback) { |
26 | if (!callback) callback = function () { /* empty */ } | 42 | if (!callback) callback = function () { /* empty */ } |
27 | 43 | ||
28 | const query = { | 44 | const query = { |
@@ -34,5 +50,5 @@ function removeByRequestIdsAndPod (requestsIds, podId, callback) { | |||
34 | } | 50 | } |
35 | } | 51 | } |
36 | 52 | ||
37 | this.destroy(query).asCallback(callback) | 53 | RequestToPod.destroy(query).asCallback(callback) |
38 | } | 54 | } |