Reputation: 14145
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
Upvotes: 2
Views: 1034
Reputation: 36104
You can use regular expression and $not
operator,
$regex
to pass string that you want to search, specify $
at the end of string to search exact from end of the string,$not
to check opposit conditiondb.collection.find({
refNote: {
$not: {
$regex: "@qwertz$"
}
}
})
Upvotes: 4