diff options
Diffstat (limited to 'server/models/poolRequests.js')
-rw-r--r-- | server/models/poolRequests.js | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/server/models/poolRequests.js b/server/models/poolRequests.js deleted file mode 100644 index 28093a94c..000000000 --- a/server/models/poolRequests.js +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const mongoose = require('mongoose') | ||
4 | |||
5 | const logger = require('../helpers/logger') | ||
6 | |||
7 | // --------------------------------------------------------------------------- | ||
8 | |||
9 | const poolRequestsSchema = mongoose.Schema({ | ||
10 | type: String, | ||
11 | id: String, // Special id to find duplicates (video created we want to remove...) | ||
12 | request: mongoose.Schema.Types.Mixed | ||
13 | }) | ||
14 | const PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema) | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | const PoolRequests = { | ||
19 | create: create, | ||
20 | findById: findById, | ||
21 | list: list, | ||
22 | removeRequestById: removeRequestById, | ||
23 | removeRequests: removeRequests | ||
24 | } | ||
25 | |||
26 | function create (id, type, request, callback) { | ||
27 | PoolRequestsDB.create({ id: id, type: type, request: request }, callback) | ||
28 | } | ||
29 | |||
30 | function findById (id, callback) { | ||
31 | PoolRequestsDB.findOne({ id: id }, callback) | ||
32 | } | ||
33 | |||
34 | function list (callback) { | ||
35 | PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) | ||
36 | } | ||
37 | |||
38 | function removeRequestById (id, callback) { | ||
39 | PoolRequestsDB.remove({ id: id }, callback) | ||
40 | } | ||
41 | |||
42 | function removeRequests (ids) { | ||
43 | PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) { | ||
44 | if (err) { | ||
45 | logger.error('Cannot remove requests from the pool requests database.', { error: err }) | ||
46 | return // Abort | ||
47 | } | ||
48 | |||
49 | logger.info('Pool requests flushed.') | ||
50 | }) | ||
51 | } | ||
52 | |||
53 | // --------------------------------------------------------------------------- | ||
54 | |||
55 | module.exports = PoolRequests | ||