]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/videos.js
Extends the search feature by customizing the search field (name,
[github/Chocobozzz/PeerTube.git] / server / models / videos.js
index 9521e63e314ca35a08fd60d41ed8876e932b94d2..7bd41f7eea7836bfc3ec5d1309a36a53bdb89500 100644 (file)
@@ -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)
 }