aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/request-to-pod.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/request-to-pod.js')
-rw-r--r--server/models/request-to-pod.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/server/models/request-to-pod.js b/server/models/request-to-pod.js
new file mode 100644
index 000000000..f42a53458
--- /dev/null
+++ b/server/models/request-to-pod.js
@@ -0,0 +1,42 @@
1'use strict'
2
3// ---------------------------------------------------------------------------
4
5module.exports = function (sequelize, DataTypes) {
6 const RequestToPod = sequelize.define('RequestToPod', {}, {
7 indexes: [
8 {
9 fields: [ 'requestId' ]
10 },
11 {
12 fields: [ 'podId' ]
13 },
14 {
15 fields: [ 'requestId', 'podId' ],
16 unique: true
17 }
18 ],
19 classMethods: {
20 removePodOf
21 }
22 })
23
24 return RequestToPod
25}
26
27// ---------------------------------------------------------------------------
28
29function removePodOf (requestsIds, podId, callback) {
30 if (!callback) callback = function () {}
31
32 const query = {
33 where: {
34 requestId: {
35 $in: requestsIds
36 },
37 podId: podId
38 }
39 }
40
41 this.destroy(query).asCallback(callback)
42}