mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04:00
22 lines
655 B
JavaScript
22 lines
655 B
JavaScript
import escapeStringRegexp from 'escape-string-regexp';
|
|
import { addCallback, Utils } from 'meteor/vulcan:lib';
|
|
|
|
function addSearchQueryParameter (parameters, terms) {
|
|
if(!!terms.query) {
|
|
|
|
const query = escapeStringRegexp(terms.query);
|
|
|
|
parameters = Utils.deepExtend(true, parameters, {
|
|
selector: {
|
|
$or: [
|
|
{username: {$regex: query, $options: 'i'}},
|
|
{email: {$regex: query, $options: 'i'}},
|
|
{displayName: {$regex: query, $options: 'i'}},
|
|
{bio: {$regex: query, $options: 'i'}},
|
|
]
|
|
}
|
|
});
|
|
}
|
|
return parameters;
|
|
}
|
|
addCallback("users.parameters", addSearchQueryParameter);
|