I am creating a search function in my app that searches through: title, description and product manufacturers name. So far, searching with title or description works fine but it does not work when I try manufacturers name (in fact, it is the only one that uses dot notation in querying)
I have some data in DB:
title: 'GLT 488',
description: 'an item',
Manufacturer:
{ _id: 5ababaa8d1c9c006c8fd8975,
key: 'audio-note',
name: 'Audio Note',
},
This is how I am using MongoDB's find function:
const regex = new RegExp(escapeRegex(req.query.search), 'gi');
q.find({
$or: [
{'title': regex},
{'description': regex},
{'Manufacturer.name': regex}
]
},