aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
commit528a9efa8272532bbd0dafc35c3e05e57c50f61e (patch)
tree62d4417df4ab9b2e53c44dc7271be81b88e4e0e5 /server/models/pods.js
parentb2e4c0ba1a33b8a50491a1f8d111468a7da5640f (diff)
downloadPeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.gz
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.zst
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.zip
Try to make a better communication (between pods) module
Diffstat (limited to 'server/models/pods.js')
-rw-r--r--server/models/pods.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/models/pods.js b/server/models/pods.js
index 04cc2d6fc..daeadeb07 100644
--- a/server/models/pods.js
+++ b/server/models/pods.js
@@ -19,10 +19,13 @@ const PodsDB = mongoose.model('pods', podsSchema)
19const Pods = { 19const Pods = {
20 add: add, 20 add: add,
21 count: count, 21 count: count,
22 findById: findById,
22 findByUrl: findByUrl, 23 findByUrl: findByUrl,
23 findBadPods: findBadPods, 24 findBadPods: findBadPods,
24 incrementScores: incrementScores, 25 incrementScores: incrementScores,
25 list: list, 26 list: list,
27 listAllIds: listAllIds,
28 listAllUrls: listAllUrls,
26 remove: remove, 29 remove: remove,
27 removeAll: removeAll, 30 removeAll: removeAll,
28 removeAllByIds: removeAllByIds 31 removeAllByIds: removeAllByIds
@@ -48,6 +51,10 @@ function findBadPods (callback) {
48 PodsDB.find({ score: 0 }, callback) 51 PodsDB.find({ score: 0 }, callback)
49} 52}
50 53
54function findById (id, callback) {
55 PodsDB.findById(id, callback)
56}
57
51function findByUrl (url, callback) { 58function findByUrl (url, callback) {
52 PodsDB.findOne({ url: url }, callback) 59 PodsDB.findOne({ url: url }, callback)
53} 60}
@@ -68,6 +75,14 @@ function list (callback) {
68 }) 75 })
69} 76}
70 77
78function listAllIds (callback) {
79 return PodsDB.find({}, { _id: 1 }, callback)
80}
81
82function listAllUrls (callback) {
83 return PodsDB.find({}, { _id: 0, url: 1 }, callback)
84}
85
71function remove (url, callback) { 86function remove (url, callback) {
72 if (!callback) callback = function () {} 87 if (!callback) callback = function () {}
73 PodsDB.remove({ url: url }, callback) 88 PodsDB.remove({ url: url }, callback)