Module mongodm::operator [−][src]
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);