]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/request/request-to-pod.ts
Remove any typing from server
[github/Chocobozzz/PeerTube.git] / server / models / request / request-to-pod.ts
CommitLineData
e02643f3
C
1import * as Sequelize from 'sequelize'
2
74889a71 3import { addMethodsToModel } from '../utils'
e02643f3 4import {
e02643f3
C
5 RequestToPodInstance,
6 RequestToPodAttributes,
7
8 RequestToPodMethods
9} from './request-to-pod-interface'
10
11let RequestToPod: Sequelize.Model<RequestToPodInstance, RequestToPodAttributes>
12let removeByRequestIdsAndPod: RequestToPodMethods.RemoveByRequestIdsAndPod
13
127944aa
C
14export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
15 RequestToPod = sequelize.define<RequestToPodInstance, RequestToPodAttributes>('RequestToPod', {}, {
319d072e
C
16 indexes: [
17 {
18 fields: [ 'requestId' ]
19 },
20 {
21 fields: [ 'podId' ]
22 },
23 {
24 fields: [ 'requestId', 'podId' ],
25 unique: true
26 }
e02643f3 27 ]
feb4bdfd
C
28 })
29
e02643f3
C
30 const classMethods = [
31 removeByRequestIdsAndPod
32 ]
33 addMethodsToModel(RequestToPod, classMethods)
34
feb4bdfd
C
35 return RequestToPod
36}
37
38// ---------------------------------------------------------------------------
39
6fcd19ba 40removeByRequestIdsAndPod = function (requestsIds: number[], podId: number) {
feb4bdfd
C
41 const query = {
42 where: {
43 requestId: {
44 $in: requestsIds
45 },
46 podId: podId
47 }
48 }
49
6fcd19ba 50 return RequestToPod.destroy(query)
feb4bdfd 51}