Fetching documents by field's text value

Hey guys!

My question is: is there a way to fetch documents by document’s field which value is text?
Please see what I have now:
let’s assume I have following schema:

{
   productName,
   productType
}

and I have for example three productTypes: Type one, Type Two, Type three, and productType is stored as a string.
I can easily fetch all the products with Products.find({}, {sort: {createdAt: -1}}).fetch(), but I need to fetch them by productType, which is text. I tried $text but no luck :frowning:
So may be some of y’all have a hint?
UPD
Always forget to mention this. I’m using Meteor v. 1.4.2.3

I assume by text you mean string?

In principle:

Products.find({productType: 'Type one'}, ...

Similarly:

const search = 'Type one';
Products.find({productType: search}, ...
2 Likes

Thanks a lot, it worked well!

1 Like