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:


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?
Always forget to mention this. I’m using Meteor v.

I assume by text you mean string?

In principle:

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


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

Thanks a lot, it worked well!

1 Like