diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
commit | 9f10b2928df655c3672d9607e864e667d4bc903a (patch) | |
tree | 7743911b974b3a7fb0d4c7cec2a723942466b7f1 /models/poolRequests.js | |
parent | d7c01e7793d813d804a3b5716d8288f9dcf71a16 (diff) | |
download | PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.gz PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.zst PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.zip |
Remove useless anonymous functions of files
Diffstat (limited to 'models/poolRequests.js')
-rw-r--r-- | models/poolRequests.js | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/models/poolRequests.js b/models/poolRequests.js index 5070a1331..970315597 100644 --- a/models/poolRequests.js +++ b/models/poolRequests.js | |||
@@ -1,57 +1,55 @@ | |||
1 | ;(function () { | 1 | 'use strict' |
2 | 'use strict' | ||
3 | 2 | ||
4 | var mongoose = require('mongoose') | 3 | var mongoose = require('mongoose') |
5 | 4 | ||
6 | var logger = require('../helpers/logger') | 5 | var logger = require('../helpers/logger') |
7 | 6 | ||
8 | // --------------------------------------------------------------------------- | 7 | // --------------------------------------------------------------------------- |
9 | 8 | ||
10 | var poolRequestsSchema = mongoose.Schema({ | 9 | var poolRequestsSchema = mongoose.Schema({ |
11 | type: String, | 10 | type: String, |
12 | id: String, // Special id to find duplicates (video created we want to remove...) | 11 | id: String, // Special id to find duplicates (video created we want to remove...) |
13 | request: mongoose.Schema.Types.Mixed | 12 | request: mongoose.Schema.Types.Mixed |
14 | }) | 13 | }) |
15 | var PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema) | 14 | var PoolRequestsDB = mongoose.model('poolRequests', poolRequestsSchema) |
16 | 15 | ||
17 | // --------------------------------------------------------------------------- | 16 | // --------------------------------------------------------------------------- |
18 | 17 | ||
19 | var PoolRequests = { | 18 | var PoolRequests = { |
20 | create: create, | 19 | create: create, |
21 | findById: findById, | 20 | findById: findById, |
22 | list: list, | 21 | list: list, |
23 | removeRequestById: removeRequestById, | 22 | removeRequestById: removeRequestById, |
24 | removeRequests: removeRequests | 23 | removeRequests: removeRequests |
25 | } | 24 | } |
26 | 25 | ||
27 | function create (id, type, request, callback) { | 26 | function create (id, type, request, callback) { |
28 | PoolRequestsDB.create({ id: id, type: type, request: request }, callback) | 27 | PoolRequestsDB.create({ id: id, type: type, request: request }, callback) |
29 | } | 28 | } |
30 | 29 | ||
31 | function findById (id, callback) { | 30 | function findById (id, callback) { |
32 | PoolRequestsDB.findOne({ id: id }, callback) | 31 | PoolRequestsDB.findOne({ id: id }, callback) |
33 | } | 32 | } |
34 | 33 | ||
35 | function list (callback) { | 34 | function list (callback) { |
36 | PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) | 35 | PoolRequestsDB.find({}, { _id: 1, type: 1, request: 1 }, callback) |
37 | } | 36 | } |
38 | 37 | ||
39 | function removeRequestById (id, callback) { | 38 | function removeRequestById (id, callback) { |
40 | PoolRequestsDB.remove({ id: id }, callback) | 39 | PoolRequestsDB.remove({ id: id }, callback) |
41 | } | 40 | } |
42 | 41 | ||
43 | function removeRequests (ids) { | 42 | function removeRequests (ids) { |
44 | PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) { | 43 | PoolRequestsDB.remove({ _id: { $in: ids } }, function (err) { |
45 | if (err) { | 44 | if (err) { |
46 | logger.error('Cannot remove requests from the pool requests database.', { error: err }) | 45 | logger.error('Cannot remove requests from the pool requests database.', { error: err }) |
47 | return // Abort | 46 | return // Abort |
48 | } | 47 | } |
49 | 48 | ||
50 | logger.info('Pool requests flushed.') | 49 | logger.info('Pool requests flushed.') |
51 | }) | 50 | }) |
52 | } | 51 | } |
53 | 52 | ||
54 | // --------------------------------------------------------------------------- | 53 | // --------------------------------------------------------------------------- |
55 | 54 | ||
56 | module.exports = PoolRequests | 55 | module.exports = PoolRequests |
57 | })() | ||