const AdressSchema = new Schema(
{
title: {
type: String,
required: true,
},
location: {
type: Object,
required: true,
},
})
location is where I want to find any matching expression
this is how I do it but returns empty result
async get() {
return this.Model.find($or: [{ title: { $regex: regex } },{location: { $regex: regex } }])
}
Regular expressions match strings.
MongoDB query language operators are type sensitive.
type: Object
is not a string.
Therefore the $regex
operator will never match a location
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.