I have a mongodb collection with documents structured like this
{
...
"ownerName":"Bob",
"city":"Oregon",
"refNote":"sadkj1233233@qwertz",
}
I want to filter and select only documents where refNote not ends with @qwertz
CodePudding user response:
You can use regular expression and $not operator,
$regexto pass string that you want to search, specify$at the end of string to search exact from end of the string,$notto check opposit condition
db.collection.find({
refNote: {
$not: {
$regex: "@qwertz$"
}
}
})
