Open tsetsoo opened 3 years ago
I don't see any reason why this feature could not be added. Please do feel free to create a PR for it.
I am using Mongo DB as storage, but not rest-layer-mongo.
Want to share what you are using? Is it in a state in which other could use it, or it's written more specifically for the purpose at hand?
I've opened #274 with the initial implementation of the $not
operator with regex, functioning as an opposite to $regex
.
I'll add a second PR with the implementation of $not
-ing a whole expression since that seems a bit trickier
Want to share what you are using? Is it in a state in which other could use it, or it's written more specifically for the purpose at hand?
Unfortunately, it's written for the purpose at hand. One of the main blocker would have been the support for mgo over mongo.
Regardless, I'll open a PR in rest-layer-mongo after I'm finished here, to add support for $not
$not-ing a whole expression since that seems a b
To be honest, I am not sure how useful it is to be able to not the whole expression. The docs does state that
{price: {$not: {$gt: 12}}}
is not equivalent to{price: {$lte: 12}}
, since the prior would match any documents where the price is not set while the latter would not. If this is really the query you want, you could just do {$or: [{price: {$lte: 12}}, {price:{$exists: false}]}
, which would be more explicit anyways.
So at least I am not against only implement $not
as an oposite to $regex
. An views from you @rs?
For reference: https://docs.mongodb.com/manual/reference/operator/query/not/
Hello,
I am using Mongo DB as storage, but not rest-layer-mongo.
I want to implement Contains and Does Not Contain filters. For Contains I can use the
$regex
operation. However, for Does Not Contain I cannot use$regex
, since Go does not support lookarounds and regexes are currently validated with Go's standard library. Using$not
seems to me like the obvious alternative.Per #272 I know that there is not active development on this library, so this issue is to ask if a reason exist for this feature to be missing. If there is no such reason, I will implement it myself (including support for
$not
-ing a regex and$not
-ing a whole expression).237 looks like an appropriate PR to model after