Documentation ¶
Index ¶
- Variables
- func All[I expression.AnyExpression](fieldName string, values ...I) arrayFilter
- func And[T Filter](filters ...T) logicalFilter
- func BitsAllClear(fieldName string, bitmask int64) bitwiseFilter
- func BitsAllSet(fieldName string, bitmask int64) bitwiseFilter
- func BitsAnyClear(fieldName string, bitmask int64) bitwiseFilter
- func BitsAnySet(fieldName string, bitmask int64) bitwiseFilter
- func ElemMatch(fieldName string, filter bsonx.Bson) arrayFilter
- func Empty() emptyFilter
- func Eq[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func Exists(fieldName string, value bool) elementFilter
- func Expr[I expression.AnyExpression](expression I) evaluationFilter
- func GeoIntersects(fieldName string, geometry geojson.IGeometry) geoFilter
- func GeoIntersectsBson(fieldName string, geometry bsonx.Bson) geoFilter
- func GeoWithin(fieldName string, geometry geojson.IGeometry) geoFilter
- func GeoWithinBox(fieldName string, lowerLeftX, lowerLeftY, upperRightX, upperRightY float64) geoFilter
- func GeoWithinBson(fieldName string, geometry bsonx.Bson) geoFilter
- func GeoWithinCenter(fieldName string, x, y, radius float64) geoFilter
- func GeoWithinCenterSphere(fieldName string, x, y, radius float64) geoFilter
- func GeoWithinPolygon(fieldName string, points [][]float64) geoFilter
- func Gt[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func Gte[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func In[I expression.AnyExpression](fieldName string, values ...I) comparisonFilter
- func JsonSchema(schema bsonx.Bson) evaluationFilter
- func Lt[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func Lte[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func Mod(fieldName string, divisor, remainder int64) evaluationFilter
- func Ne[I expression.AnyExpression](fieldName string, value I) comparisonFilter
- func Near(fieldName string, geometry geojson.Point, maxDistance, minDistance float64) geoFilter
- func NearBson(fieldName string, geometry bsonx.Bson, maxDistance, minDistance float64) geoFilter
- func NearCoordinate(fieldName string, x, y float64, maxDistance, minDistance float64) geoFilter
- func NearSphere(fieldName string, geometry geojson.Point, maxDistance, minDistance float64) geoFilter
- func NearSphereBson(fieldName string, geometry bsonx.Bson, maxDistance, minDistance float64) geoFilter
- func NearSphereCoordinate(fieldName string, x, y float64, maxDistance, minDistance float64) geoFilter
- func Nin[I expression.AnyExpression](fieldName string, values ...I) comparisonFilter
- func Nor[T Filter](filters ...T) logicalFilter
- func Not[T Filter](f T) logicalFilter
- func Or[T Filter](filters ...T) logicalFilter
- func Regex(fieldName string, pattern, options string) evaluationFilter
- func Size(fieldName string, size int32) arrayFilter
- func Text(search string, textSearchOptions options.TextSearchOptions) evaluationFilter
- func Type(fieldName string, value bsonx.BsonType) elementFilter
- func Where(javaScriptExpression string) whereFilter
- type Filter
- type MatchFilter
- type Operator
Constants ¶
This section is empty.
Variables ¶
var ( OR = newOperator("$or", "Or") NOR = newOperator("$nor", "Nor") )
var ( DBREFKeys = []string{ "$ref", "$id", } DBREFKeysWithDb = []string{ "$ref", "$id", "$db", } )
Functions ¶
func All ¶
func All[I expression.AnyExpression](fieldName string, values ...I) arrayFilter
All The $all operator selects the documents where the value of a field is an array that contains all the specified elements. To specify an $all expression, use the following prototype: { <field>: { $all: [ <value1> , <value2> ... ] } }
func And ¶
func And[T Filter](filters ...T) logicalFilter
And Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
func BitsAllClear ¶
BitsAllClear $bitsAllClear matches documents where all of the bit positions given by the query are clear (i.e. 0) in field. { <field>: { $bitsAllClear: <numeric bitmask> } } { <field>: { $bitsAllClear: < BinData bitmask> } } { <field>: { $bitsAllClear: [ <position1>, <position2>, ... ] } } The field value must be either numeric or a BinData instance. Otherwise, $bitsAllClear will not match the current document.
func BitsAllSet ¶
BitsAllSet $bitsAllSet matches documents where all of the bit positions given by the query are set (i.e. 1) in field. { <field>: { $bitsAllSet: <numeric bitmask> } } { <field>: { $bitsAllSet: < BinData bitmask> } } { <field>: { $bitsAllSet: [ <position1>, <position2>, ... ] } } The field value must be either numeric or a BinData instance. Otherwise, $bitsAllSet will not match the current document.
func BitsAnyClear ¶
BitsAnyClear $bitsAnyClear matches documents where any of the bit positions given by the query are clear (i.e. 0) in field. { <field>: { $bitsAnyClear: <numeric bitmask> } } { <field>: { $bitsAnyClear: < BinData bitmask> } } { <field>: { $bitsAnyClear: [ <position1>, <position2>, ... ] } } The field value must be either numeric or a BinData instance. Otherwise, $bitsAnyClear will not match the current document.
func BitsAnySet ¶
BitsAnySet $bitsAnySet matches documents where any of the bit positions given by the query are set (i.e. 1) in field. { <field>: { $bitsAnySet: <numeric bitmask> } } { <field>: { $bitsAnySet: < BinData bitmask> } } { <field>: { $bitsAnySet: [ <position1>, <position2>, ... ] } } The field value must be either numeric or a BinData instance. Otherwise, $bitsAnySet will not match the current document.
func ElemMatch ¶
ElemMatch The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria. { <field>: { $elemMatch: { <query1>, <query2>, ... } } } If you specify only a single <query> condition in the $elemMatch expression, and are not using the $not or $ne operators inside of $elemMatch, $elemMatch can be omitted.
func Eq ¶
func Eq[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Eq Matches values that are equal to a specified value.
func Exists ¶
Exists When <boolean> is true, $exists matches the documents that contain the field, including documents where the field value is null. If <boolean> is false, the query returns only the documents that do not contain the field. [1] MongoDB $exists does not correspond to SQL operator exists. For SQL exists, refer to the $in operator.
func Expr ¶
func Expr[I expression.AnyExpression](expression I) evaluationFilter
Expr Allows the use of aggregation expressions within the query language. $expr has the following syntax: { $expr: { <expression> } }
func GeoIntersects ¶
GeoIntersects Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty. The $geoIntersects operator uses the $geometry operator to specify the GeoJSON object. To specify a GeoJSON polygons or multipolygons using the default coordinate reference system (CRS),
func GeoIntersectsBson ¶
GeoIntersectsBson Selects documents whose geospatial data intersects with a specified GeoJSON object; i.e. where the intersection of the data and the specified object is non-empty. The $geoIntersects operator uses the $geometry operator to specify the GeoJSON object. To specify a GeoJSON polygons or multipolygons using the default coordinate reference system (CRS),
func GeoWithin ¶
GeoWithin Selects documents with geospatial data that exists entirely within a specified shape. The specified shape can be either a GeoJSON Polygon (either single-ringed or multi-ringed), a GeoJSON MultiPolygon, or a shape defined by legacy coordinate pairs. The $geoWithin operator uses the $geometry operator to specify the GeoJSON object.
func GeoWithinBox ¶
func GeoWithinBox(fieldName string, lowerLeftX, lowerLeftY, upperRightX, upperRightY float64) geoFilter
GeoWithinBox $geoWithin The available shape operators are $box
func GeoWithinBson ¶
GeoWithinBson Selects documents with geospatial data that exists entirely within a specified shape. The specified shape can be either a GeoJSON Polygon (either single-ringed or multi-ringed), a GeoJSON MultiPolygon, or a shape defined by legacy coordinate pairs. The $geoWithin operator uses the $geometry operator to specify the GeoJSON object.
func GeoWithinCenter ¶
GeoWithinCenter $geoWithin The available shape operators are $center
func GeoWithinCenterSphere ¶
GeoWithinCenterSphere $geoWithin The available shape operators are $centerSphere
func GeoWithinPolygon ¶
GeoWithinPolygon $geoWithin The available shape operators are $polygon
func Gt ¶
func Gt[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Gt Matches values that are greater than a specified value.
func Gte ¶
func Gte[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Gte Matches values that are greater than or equal to a specified value.
func In ¶
func In[I expression.AnyExpression](fieldName string, values ...I) comparisonFilter
In Matches any of the values specified in an array.
func JsonSchema ¶
JsonSchema The $jsonSchema operator matches documents that satisfy the specified JSON Schema. The $jsonSchema operator expression has the following syntax: { $jsonSchema: <JSON Schema object> } Where the JSON Schema object is formatted according to draft 4 of the JSON Schema standard { <keyword1>: <value1>, ... }
func Lt ¶
func Lt[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Lt Matches values that are less than a specified value.
func Lte ¶
func Lte[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Lte Matches values that are less than or equal to a specified value.
func Mod ¶
Mod Select documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents). To specify a $mod expression, use the following syntax: { field: { $mod: [ divisor, remainder ] } }
func Ne ¶
func Ne[I expression.AnyExpression](fieldName string, value I) comparisonFilter
Ne Matches all values that are not equal to a specified value.
func Near ¶
Near Specifies a point for which a geospatial query returns the documents from nearest to farthest. The $near operator can specify either a GeoJSON point or legacy coordinate point.
func NearBson ¶
NearBson Specifies a point for which a geospatial query returns the documents from nearest to farthest. The $near operator can specify either a GeoJSON point or legacy coordinate point.
func NearCoordinate ¶
NearCoordinate Specifies a point for which a geospatial query returns the documents from nearest to farthest. The $near operator can specify either a GeoJSON point or legacy coordinate point.
func NearSphere ¶
func NearSphere(fieldName string, geometry geojson.Point, maxDistance, minDistance float64) geoFilter
NearSphere Specifies a point for which a geospatial query returns the documents from nearest to farthest. MongoDB calculates distances for $nearSphere using spherical geometry.
func NearSphereBson ¶
func NearSphereBson(fieldName string, geometry bsonx.Bson, maxDistance, minDistance float64) geoFilter
NearSphereBson Specifies a point for which a geospatial query returns the documents from nearest to farthest. MongoDB calculates distances for $nearSphere using spherical geometry.
func NearSphereCoordinate ¶
func NearSphereCoordinate(fieldName string, x, y float64, maxDistance, minDistance float64) geoFilter
NearSphereCoordinate Specifies a point for which a geospatial query returns the documents from nearest to farthest. MongoDB calculates distances for $nearSphere using spherical geometry.
func Nin ¶
func Nin[I expression.AnyExpression](fieldName string, values ...I) comparisonFilter
Nin Matches none of the values specified in an array.
func Nor ¶
func Nor[T Filter](filters ...T) logicalFilter
Nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
func Not ¶
func Not[T Filter](f T) logicalFilter
Not Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
func Or ¶
func Or[T Filter](filters ...T) logicalFilter
Or Inverts the effect of a query expression and returns documents that do not match the query expression.
func Regex ¶
Regex Provides regular expression capabilities for pattern matching strings in queries. MongoDB uses Perl compatible regular expressions (i.e. "PCRE" ) version 8.42 with UTF-8 support. To use $regex , use one of the following syntaxes: { <field>: { $regex: /pattern/, $options: '<options>' } } { <field>: { $regex: 'pattern', $options: '<options>' } } { <field>: { $regex: /pattern/<options> } } In MongoDB, you can also use regular expression objects (i.e. /pattern/) to specify regular expressions: { <field>: /pattern/<options> }
func Size ¶
Size The $size operator matches any array with the number of elements specified by the argument. For example: db.collection.find( { field: { $size: 2 } } ); returns all documents in collection where field is an array with 2 elements. For instance, the above expression will return { field: [ red, green ] } and { field: [ apple, lime ] } but not { field: fruit } or { field: [ orange, lemon, grapefruit ] }. To match fields with only one element within an array use $size with a value of 1, as follows: db.collection.find( { field: { $size: 1 } } ); $size does not accept ranges of values. To select documents based on fields with different numbers of elements, create a counter field that you increment when you add elements to a field. Queries cannot use indexes for the $size portion of a query, although the other portions of a query can use indexes if applicable.
func Text ¶
func Text(search string, textSearchOptions options.TextSearchOptions) evaluationFilter
Text performs a text search on the content of the fields indexed with a text index. A $text expression has the following syntax:
{ $text: { $search: <string>, $language: <string>, $caseSensitive: <boolean>, $diacriticSensitive: <boolean> } }
func Type ¶
Type selects documents where the value of the field is an instance of the specified BSON type(s). Querying by data type is useful when dealing with highly unstructured data where data types are not predictable. A $type expression for a single BSON type has the following syntax: { field: { $type: <BSON type> } } You can specify either the number or alias for the BSON type The $type expression can also accept an array of BSON types and has the following syntax: { field: { $type: [ <BSON type1> , <BSON type2>, ... ] } } The above query will match documents where the field value is any of the listed types. The types specified in the array can be either numeric or string aliases.
func Where ¶
func Where(javaScriptExpression string) whereFilter
Where Use the $where operator to pass either a string containing a JavaScript expression or a full JavaScript function to the query system. The $where provides greater flexibility, but requires that the database processes the JavaScript expression or function for each document in the collection. Reference the document in the JavaScript expression or function using either this or obj . { $where: <string|JavaScript Code> }
Types ¶
type MatchFilter ¶
type MatchFilter interface { Filter logicalFilter | comparisonFilter | arrayFilter | bitwiseFilter | elementFilter | evaluationFilter | emptyFilter }