aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-22 09:15:00 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-22 09:15:00 +0200
commit46246b5f194caafba4e3a72e9365acd8b35785de (patch)
tree943689b44a9e447872cd7dd1c2a70dcc9256b990 /server/models/videos.js
parent68ce3ae021c9bc11b155044df6d23ba60e91eee4 (diff)
downloadPeerTube-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/videos.js')
-rw-r--r--server/models/videos.js11
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
127function search (name, start, count, sort, callback) { 127function 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