From 528a9efa8272532bbd0dafc35c3e05e57c50f61e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 18 Jun 2016 16:13:54 +0200 Subject: Try to make a better communication (between pods) module --- server/models/pods.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'server/models/pods.js') 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) 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) -- cgit v1.2.3