Я следующие обучающим Угловая Метеор, и имеет следующий код:
import { Meteor } from 'meteor/meteor';
import { Counts } from 'meteor/tmeasday:publish-counts';
import { Parties } from './collection';
if (Meteor.isServer) {
Meteor.publish('parties', function(options, searchString) {
const selector = {
$or: [{
// the public parties
$and: [{
public: true
}, {
public: {
$exists: true
}
}]
}, {
// when logged in user is the owner
$and: [{
owner: this.userId
}, {
owner: {
$exists: true
}
}]
}]
};
if (typeof searchString === 'string' && searchString.length) {
selector.name = {
$regex: `.*${searchString}.*`,
$options : 'i'
};
}
Counts.publish(this, 'numberOfParties', Parties.find(selector), {
noReady: true
});
return Parties.find(selector, options);
});
}
Я пытаюсь изменить selector.name включить поле описания, а также , Я проверил добавление selector.description, но это ничего не делает. Можно ли изменить селектор, чтобы включить поиск нескольких полей при совпадении регулярного выражения с любым полем документа?
Awesome! Спасибо, перед этим я ударился головой, чтобы разобраться в селекторе. Вы сделали это очень ясно. – Neo