I am building a warehouse website .In my website i displayed a input field and a search button. By this search button I want to search all the product which includes only my search property not the whole thing. But in mogodb, i can't do this. Because in Mongodb i have to write the whole search property for this. Example : In DB i have an property {name:Jhon Doe, email:jhon00@gmail.com} If my search value (Jhon) it will give me this property, But in mongodb i have to search by full name like (Jhon Doe).How can i solve the problem?
you don't have to to write the whole search property in mongoDb , just use regex like this :
const reg = new RegExp(inputSearch);
const preson = await Person.findOne({ "name" : { $regex: reg, $options: 'gi' } },