1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Try to make a better communication (between pods) module

This commit is contained in:
Chocobozzz 2016-06-18 16:13:54 +02:00
parent b2e4c0ba1a
commit 528a9efa82
20 changed files with 493 additions and 439 deletions

View file

@ -19,10 +19,13 @@ const PodsDB = mongoose.model('pods', podsSchema)
const Pods = {
add: add,
count: count,
findById: findById,
findByUrl: findByUrl,
findBadPods: findBadPods,
incrementScores: incrementScores,
list: list,
listAllIds: listAllIds,
listAllUrls: listAllUrls,
remove: remove,
removeAll: removeAll,
removeAllByIds: removeAllByIds
@ -48,6 +51,10 @@ function findBadPods (callback) {
PodsDB.find({ score: 0 }, callback)
}
function findById (id, callback) {
PodsDB.findById(id, callback)
}
function findByUrl (url, callback) {
PodsDB.findOne({ url: url }, callback)
}
@ -68,6 +75,14 @@ function list (callback) {
})
}
function listAllIds (callback) {
return PodsDB.find({}, { _id: 1 }, callback)
}
function listAllUrls (callback) {
return PodsDB.find({}, { _id: 0, url: 1 }, callback)
}
function remove (url, callback) {
if (!callback) callback = function () {}
PodsDB.remove({ url: url }, callback)