diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-22 09:15:00 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-22 09:15:00 +0200 |
commit | 46246b5f194caafba4e3a72e9365acd8b35785de (patch) | |
tree | 943689b44a9e447872cd7dd1c2a70dcc9256b990 /server/models | |
parent | 68ce3ae021c9bc11b155044df6d23ba60e91eee4 (diff) | |
download | PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.gz PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.zst PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.zip |
Extends the search feature by customizing the search field (name,
podUrl...)
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/videos.js | 11 |
1 files changed, 9 insertions, 2 deletions
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) { | |||
124 | VideosDB.remove({ _id: { $in: ids } }, callback) | 124 | VideosDB.remove({ _id: { $in: ids } }, callback) |
125 | } | 125 | } |
126 | 126 | ||
127 | function search (name, start, count, sort, callback) { | 127 | function search (value, field, start, count, sort, callback) { |
128 | const query = { name: new RegExp(name) } | 128 | const query = {} |
129 | // Make an exact search with the magnet | ||
130 | if (field === 'magnetUri') { | ||
131 | query[field] = value | ||
132 | } else { | ||
133 | query[field] = new RegExp(value) | ||
134 | } | ||
135 | |||
129 | findWithCount(query, start, count, sort, callback) | 136 | findWithCount(query, start, count, sort, callback) |
130 | } | 137 | } |
131 | 138 | ||