Module operator

Source
Expand description

Static operators for queries to prevent invalid queries due to typos.

See mongo manual for query operators and update operators.

If an operator is missing, you can easily add it yourself (also, PR are welcomed) or use the hardcoded string like you would in a mongo shell.

use mongodm::mongo::bson::doc;
use mongodm::operator::*;

// Using static operators
let a = doc! {
    And: [
        { "foo": { Exists: true } },
        {
            Or: [
                { "bar": { GreaterThan: 100 } },
                { "lorem": "ipsum" }
            ]
        }
    ]
};

// Using hardcoded strings
let b = doc! {
    "$and": [
        { "foo": { "$exists": true } },
        {
            "$or": [
                { "bar": { "$gt": 100 } },
                { "lorem": "ipsum" }
            ]
        }
    ]
};

// Generated document are identicals
assert_eq!(a, b);

Structsยง

Abs
Arithmetic Expression Operators operator $abs
Acos
Trigonometry Expression Operators operator $acos
Acosh
Trigonometry Expression Operators operator $acosh
Add
Arithmetic Expression Operators operator $add
AddFields
Aggregation pipeline stages operator $addFields
AddToSet
Array (update) operator $addToSet
All
Array (query) operator $all
AllElementsTrue
Set Expression Operators operator $allElementsTrue
And
Logical operator $and
AnyElementTrue
Set Expression Operators operator $anyElementTrue
ArrayElemAt
Array Expression Operators operator $arrayElemAt
ArrayToObject
Array Expression Operators operator $arrayToObject
Asin
Trigonometry Expression Operators operator $asin
Asinh
Trigonometry Expression Operators operator $asinh
Atan
Trigonometry Expression Operators operator $atan
Atan2
Trigonometry Expression Operators operator $atan2
Atanh
Trigonometry Expression Operators operator $atanh
Average
Accumulators ($group) operator $avg
Bit
Bitwise (update) operator $bit
BitsAllClear
Bitwise (query) operator $bitsAllClear
BitsAllSet
Bitwise (query) operator $bitsAllSet
BitsAnyClear
Bitwise (query) operator $bitsAnyClear
BitsAnySet
Bitwise (query) operator $bitsAnySet
BsonType
Type Expression Operators operator $type
Bucket
Aggregation pipeline stages operator $bucket
BucketAuto
Aggregation pipeline stages operator $bucketAuto
Ceil
Arithmetic Expression Operators operator $ceil
CollStats
Aggregation pipeline stages operator $collStatus
Comment
Comments operator $comment
Compare
Array Expression Operators operator $cmp
Concat
String Expression Operators operator $concat
ConcatArrays
Array Expression Operators operator $concatArrays
Cond
Conditional Operators operator $cond
Convert
Type Expression Operators operator $convert
Cos
Trigonometry Expression Operators operator $cos
Count
Aggregation pipeline stages operator $count
CurrentDate
Fields operator $currentDate
CurrentOp
Aggregation pipeline stages operator $currentOp
DateFromParts
Date Expression Operators operator $dateFromParts
DateFromString
Date Expression Operators operator $dateFromString
DateToParts
Date Expression Operators operator $dateToParts
DateToString
Date Expression Operators operator $dateToString
DayOfMonth
Date Expression Operators operator $dayOfMonth
DayOfWeek
Date Expression Operators operator $dayOfWeek
DayOfYear
Date Expression Operators operator $dayOfYear
DegreesToRadians
Trigonometry Expression Operators operator $degreesToRadians
Divide
Arithmetic Expression Operators operator $divide
Each
Modifiers operator $each
ElemMatch
Array (query) operator $elemMatch
Equal
Comparison operator $eq
Exists
Element operator $exists
Exp
Arithmetic Expression Operators operator $exp
Expr
Evaluation operator $expr
Facet
Aggregation pipeline stages operator $facet
Filter
Array Expression Operators operator $filter
FindAndModify
Aggregation pipeline stages operator $findAndModify
First
Accumulators ($group) operator $first
Floor
Arithmetic Expression Operators operator $floor
GeoIntersects
Geospatial operator $geoIntersects
GeoNear
Aggregation pipeline stages operator $geoNear
GeoWithin
Geospatial operator $geoWithin
GraphLookup
Aggregation pipeline stages operator $graphLookup
GreaterThan
Comparison operator $gt
GreaterThanEqual
Comparison operator $gte
Group
Aggregation pipeline stages operator $group
Hour
Date Expression Operators operator $hour
IfNull
Conditional Expression Operators operator $ifNull
In
Comparison operator $in
Inc
Fields operator $inc
IndexOfArray
Array Expression Operators operator $indexOfArray
IndexOfBytes
String Expression Operators operator $indexOfBytes
IndexOfCp
String Expression Operators operator $indexOfCP
IndexStats
Aggregation pipeline stages operator $indexStats
IsArray
Array Expression Operators operator $isArray
IsoDayOfWeek
Date Expression Operators operator $isoDayOfWeek
IsoWeek
Date Expression Operators operator $isoWeek
IsoWeekYear
Date Expression Operators operator $isoWeekYear
JsonSchema
Evaluation operator $jsonSchema
Last
Accumulators ($group) operator $last
LeftTrim
String Expression Operators operator $ltrim
LesserThan
Comparison operator $lt
LesserThanEqual
Comparison operator $lte
Let
Variable Expression Operators operator $let
Limit
Aggregation pipeline stages operator $limit
ListLocalSessions
Aggregation pipeline stages operator $listLocalSessions
ListSessions
Aggregation pipeline stages operator $listSessions
Literal
Literal Expression Operator operator $literal
Ln
Arithmetic Expression Operators operator $ln
Log
Arithmetic Expression Operators operator $log
Log10
Arithmetic Expression Operators operator $log10
Lookup
Lookup Operator operator $lookup
LookupPipeline
Lookup Operator operator $lookup
Map
Array Map Operator operator $map
Match
Aggregation pipeline stages operator $match
Max
Fields operator $max
Merge
Aggregation pipeline stages operator $merge
MergeObjects
Object Expression Operators operator $mergeObjects
Meta
Projection operator $meta
Millisecond
Date Expression Operators operator $millisecond
Min
Fields operator $min
Minute
Date Expression Operators operator $minute
Mod
Evaluation operator $mod
Modulo
Evaluation operator $mod
Month
Date Expression Operators operator $month
Mul
Fields operator $mul
Multiply
Arithmetic Expression Operators operator $multiply
Near
Geospatial operator $near
NearSphere
Geospatial operator $nearSphere
NoneIn
Comparison operator $nin
Nor
Logical operator $nor
Not
Logical operator $not
NotEqual
Comparison operator $ne
ObjectToArray
Array Expression Operators operator $objectToArray
Or
Logical operator $or
Out
Aggregation pipeline stages operator $out
PlanCacheStats
Aggregation pipeline stages operator $planCacheStatus
Pop
Array (update) operator $pop
Position
Modifiers operator $position
Pow
Arithmetic Expression Operators operator $pow
Power
Arithmetic Expression Operators operator $pow
Project
Aggregation pipeline stages operator $project
ProjectFirst
Projection operator $
Pull
Array (update) operator $pull
PullAll
Array (update) operator $pullAll
Push
Array (update) operator $push
RadiansToDegrees
Trigonometry Expression Operators operator $radiansToDegrees
Range
Array Expression Operators operator $range
Redact
Aggregation pipeline stages operator $redact
Reduce
Array Expression Operators operator $reduce
Regex
Evaluation operator $regex
RegexFind
String Expression Operators operator $regexFind
RegexFindAll
String Expression Operators operator $regexFindAll
RegexMatch
String Expression Operators operator $regexMatch
Rename
Fields operator $rename
ReplaceAll
String Expression Operators operator $replaceAll
ReplaceOne
String Expression Operators operator $replaceOne
ReplaceRoot
ReplaceRoot Operator operator $replaceRoot
ReplaceWith
Aggregation pipeline stages operator $replaceWith
ReverseArray
Array Expression Operators operator $reverseArray
RightTrim
String Expression Operators operator $rtrim
Round
Arithmetic Expression Operators operator $round
Sample
Aggregation pipeline stages operator $sample
Second
Date Expression Operators operator $second
Set
Fields operator $set
SetDifference
Set Expression Operators operator $setDifference
SetEquals
Set Expression Operators operator $setEquals
SetIntersection
Set Expression Operators operator $setIntersection
SetIsSubset
Set Expression Operators operator $setIsSubset
SetOnInsert
Fields operator $setOnInsert
SetUnion
Set Expression Operators operator $setUnion
Sin
Trigonometry Expression Operators operator $sin
Size
Array (query) operator $size
Skip
Aggregation pipeline stages operator $skip
Slice
Projection operator $slice
Sort
Modifiers operator $sort
SortByCount
Aggregation pipeline stages operator $sortByCount
Split
String Expression Operators operator $split
Sqrt
Arithmetic Expression Operators operator $sqrt
SquareRoot
Arithmetic Expression Operators operator $sqrt
StdDevPop
Accumulators ($group) operator $stdDevPop
StdDevSamp
Accumulators ($group) operator $stdDevSamp
StrCaseCmp
String Expression Operators operator $strcasecmp
StrLenBytes
String Expression Operators operator $strLenBytes
Substr
String Expression Operators operator $substr
SubstrBytes
String Expression Operators operator $substrBytes
SubstrCp
String Expression Operators operator $substrCP
Subtract
Arithmetic Expression Operators operator $subtract
Sum
Accumulators ($group) operator $sum
Switch
Conditional Expression Operators operator $switch
Tan
Trigonometry Expression Operators operator $tan
Text
Evaluation operator $text
ToBool
Type Expression Operators operator $toBool
ToDate
Date Expression Operators operator $toDate
ToDecimal
Type Expression Operators operator $toDecimal
ToDouble
Type Expression Operators operator $toDouble
ToInt
Type Expression Operators operator $toInt
ToLong
Type Expression Operators operator $toLong
ToLower
String Expression Operators operator $toLower
ToObjectId
Type Expression Operators operator $toObjectId
ToString
String Expression Operators operator $toString
ToUpper
String Expression Operators operator $toUpper
Trim
String Expression Operators operator $trim
Trunc
Arithmetic Expression Operators operator $trunc
Truncate
Arithmetic Expression Operators operator $truncate
Type
Element operator $type
Unset
Fields operator $unset
Unwind
Aggregation pipeline stages operator $unwind
Update
Aggregation pipeline stages operator $update
UpdateAllDocuments
Array (update) operator $[]
UpdateFirstDocument
Array (update) operator $
Week
Date Expression Operators operator $week
Where
Evaluation operator $where
Year
Date Expression Operators operator $year
Zip
Array Expression Operators operator $zip