[UI/Mobile] Search keywords are now ANDed
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
|
||||
#include "SearchFilter.hpp"
|
||||
|
||||
namespace Database
|
||||
|
||||
@@ -64,12 +64,23 @@ class SearchFilter
|
||||
return SearchFilter({{field, {id} }});
|
||||
}
|
||||
|
||||
// Single Field Name match
|
||||
static SearchFilter ByName(Field field, std::vector<std::string> keywords)
|
||||
// Single Field Name match OR
|
||||
static SearchFilter ByNameOr(Field field, std::vector<std::string> keywords)
|
||||
{
|
||||
return NameLikeMatch({{{field, keywords}}});
|
||||
}
|
||||
|
||||
// Single Field Name match AND
|
||||
static SearchFilter ByNameAnd(Field field, std::vector<std::string> keywords)
|
||||
{
|
||||
NameLikeMatchType nameLikeMatch;
|
||||
|
||||
for (auto keyword : keywords)
|
||||
nameLikeMatch.push_back({{{field, {keyword}}}});
|
||||
|
||||
return NameLikeMatch(nameLikeMatch);
|
||||
}
|
||||
|
||||
// The filter is a AND of the following conditions:
|
||||
|
||||
// ((Field1.name LIKE STR1-1 OR Field1.name LIKE STR1-2 ...) OR (Field2.name LIKE STR2-1 OR Field2.name LIKE STR2-2 ...) ...
|
||||
|
||||
Reference in New Issue
Block a user