Class MongoFilters
java.lang.Object
services.moleculer.mongo.MongoFilters
- Direct Known Subclasses:
MongoDAO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected io.datatree.TreeCreates a filter that matches all documents where the value of a field is an array that contains all the specified values.protected io.datatree.Treeand(io.datatree.Tree... filters) Creates a filter that performs a logical AND of the provided list of filters.protected io.datatree.TreecreateFilter(org.bson.conversions.Bson bson) Create a Tree object from a Bson filter.protected io.datatree.TreeCreates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.protected io.datatree.TreeCreates a filter that matches all documents where the "_id" field equals the specified document identifier.protected io.datatree.TreeCreates a filter that matches all documents where the value of the field name equals the specified value.protected io.datatree.TreeCreates a filter that matches all documents that either contain the given field.protected io.datatree.Treeexpr(io.datatree.Tree expression) Allows the use of aggregation expressions within the query language.protected io.datatree.TreegeoIntersects(String fieldName, com.mongodb.client.model.geojson.Geometry geometry) Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.protected io.datatree.TreeCreates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.protected io.datatree.TreegeoWithinBox(String fieldName, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.protected io.datatree.TreegeoWithinCenter(String fieldName, double x, double y, double radius) Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.protected io.datatree.TreegeoWithinPolygon(String fieldName, List<List<Double>> points) Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.protected io.datatree.TreeCreates a filter that matches all documents where the value of the given field is greater than the specified value.protected io.datatree.TreeCreates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.protected io.datatree.TreeCreates a filter that matches all documents where the value of a field equals any value in the list of specified values.protected io.datatree.TreeCreates a filter that matches all documents where the value of the given field is less than the specified value.protected io.datatree.TreeCreates a filter that matches all documents where the value of the given field is less than or equal to the specified value.protected io.datatree.TreeCreates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents).protected io.datatree.TreeCreates a filter that matches all documents where the value of the field name does not equal the specified value.protected io.datatree.Treenear(String fieldName, com.mongodb.client.model.geojson.Point geometry, Double maxDistance, Double minDistance) Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.protected io.datatree.TreeCreates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.protected io.datatree.Treenor(io.datatree.Tree... filters) Creates a filter that performs a logical NOR operation on all the specified filters.protected io.datatree.Treenot(io.datatree.Tree filter) Creates a filter that matches all documents that do not match the passed in filter.protected io.datatree.TreeCreates a filter that matches all documents that either do not contain the given field.protected io.datatree.Treeor(io.datatree.Tree... filters) Creates a filter that preforms a logical OR of the provided list of filters.protected io.datatree.TreeCreates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.protected io.datatree.TreeCreates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.protected io.datatree.TreeCreates a filter that matches all documents where the value of a field is an array of the specified size.protected io.datatree.TreeCreates a filter that matches all documents matching the given search term.protected io.datatree.TreeCreates a filter that matches all documents matching the given the search term with the given text search options.protected org.bson.conversions.BsontoBson(io.datatree.Tree tree) Converts Tree object to Bson object.protected io.datatree.TreeCreates a filter that matches all documents for which the given expression is true.
-
Constructor Details
-
MongoFilters
public MongoFilters()
-
-
Method Details
-
or
protected io.datatree.Tree or(io.datatree.Tree... filters) Creates a filter that preforms a logical OR of the provided list of filters.- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
and
protected io.datatree.Tree and(io.datatree.Tree... filters) Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" operator if absolutely necessary, as the query language implicity ands together all the keys. In other words, a query expression like:
will generate a MongoDB query like:and(eq("x", 1), lt("y", 3)){x : 1, y : {$lt : 3}}- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
all
-
nor
protected io.datatree.Tree nor(io.datatree.Tree... filters) Creates a filter that performs a logical NOR operation on all the specified filters.- Parameters:
filters- the list of values- Returns:
- the filter
-
not
protected io.datatree.Tree not(io.datatree.Tree filter) Creates a filter that matches all documents that do not match the passed in filter. Requires the field name to passed as part of the value passed in and lifts it to create a valid "$not" query:
will generate a MongoDB query like:not(eq("x", 1)){x : $not: {$eq : 1}}- Parameters:
filter- the value- Returns:
- the filter
-
eq
Creates a filter that matches all documents where the "_id" field equals the specified document identifier.- Parameters:
id- document identifier (value of the "_id" field)- Returns:
- the filter
-
eq
Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.- Parameters:
fieldName- the field namevalue- the value, which may be null- Returns:
- the filter
-
ne
-
in
-
nin
-
lt
-
lte
-
gt
-
gte
-
exists
Creates a filter that matches all documents that either contain the given field.- Parameters:
fieldName- the field name- Returns:
- the filter
-
notExists
Creates a filter that matches all documents that either do not contain the given field.- Parameters:
fieldName- the field name- Returns:
- the filter
-
regex
-
regex
Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.- Parameters:
fieldName- the field namepattern- the patternoptions- the options- Returns:
- the filter
-
where
Creates a filter that matches all documents for which the given expression is true.- Parameters:
javaScriptExpression- the JavaScript expression- Returns:
- the filter
-
elemMatch
Creates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.- Parameters:
fieldName- the field namefilter- the filter to apply to each element- Returns:
- the filter
-
expr
protected io.datatree.Tree expr(io.datatree.Tree expression) Allows the use of aggregation expressions within the query language.- Parameters:
expression- the aggregation expression- Returns:
- the filter
-
text
Creates a filter that matches all documents matching the given search term.- Parameters:
search- the search term- Returns:
- the filter
-
text
Creates a filter that matches all documents matching the given the search term with the given text search options.- Parameters:
search- the search termoptions- the text search options to use- Returns:
- the filter
-
geoIntersects
protected io.datatree.Tree geoIntersects(String fieldName, com.mongodb.client.model.geojson.Geometry geometry) Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
-
geoWithin
protected io.datatree.Tree geoWithin(String fieldName, com.mongodb.client.model.geojson.Geometry geometry) Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
-
geoWithinBox
protected io.datatree.Tree geoWithinBox(String fieldName, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.- Parameters:
fieldName- the field namelowerLeftX- the lower left x coordinate of the boxlowerLeftY- the lower left y coordinate of the boxupperRightX- the upper left x coordinate of the boxupperRightY- the upper left y coordinate of the box- Returns:
- the filter
-
geoWithinCenter
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.- Parameters:
fieldName- the field namex- the x coordinate of the circley- the y coordinate of the circleradius- the radius of the circle, as measured in the units used by the coordinate system- Returns:
- the filter
-
geoWithinPolygon
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.- Parameters:
fieldName- the field namepoints- a list of pairs of x, y coordinates. Any extra dimensions are ignored- Returns:
- the filter
-
mod
Creates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents).- Parameters:
fieldName- the field namedivisor- the modulusremainder- the remainder- Returns:
- the filter
-
near
protected io.datatree.Tree near(String fieldName, com.mongodb.client.model.geojson.Point geometry, Double maxDistance, Double minDistance) Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry objectmaxDistance- the maximum distance from the point, in meters. It may be null.minDistance- the minimum distance from the point, in meters. It may be null.- Returns:
- the filter
-
size
Creates a filter that matches all documents where the value of a field is an array of the specified size.- Parameters:
fieldName- the field namesize- the size of the array- Returns:
- the filter
-
createFilter
protected io.datatree.Tree createFilter(org.bson.conversions.Bson bson) Create a Tree object from a Bson filter.- Parameters:
bson- input Bson- Returns:
- the filter
-
toBson
protected org.bson.conversions.Bson toBson(io.datatree.Tree tree) Converts Tree object to Bson object.- Parameters:
tree- input Tree object- Returns:
- the Bson
-