From 46246b5f194caafba4e3a72e9365acd8b35785de Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 22 May 2016 09:15:00 +0200 Subject: Extends the search feature by customizing the search field (name, podUrl...) --- server/models/videos.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/models') diff --git a/server/models/videos.js b/server/models/videos.js index 9521e63e3..7bd41f7ee 100644 --- a/server/models/videos.js +++ b/server/models/videos.js @@ -124,8 +124,15 @@ function removeByIds (ids, callback) { VideosDB.remove({ _id: { $in: ids } }, callback) } -function search (name, start, count, sort, callback) { - const query = { name: new RegExp(name) } +function search (value, field, start, count, sort, callback) { + const query = {} + // Make an exact search with the magnet + if (field === 'magnetUri') { + query[field] = value + } else { + query[field] = new RegExp(value) + } + findWithCount(query, start, count, sort, callback) } -- cgit v1.2.3