[−][src]Macro mongodm::f
Shorthand for field!
.
Example
use mongodm::mongo::bson::doc; use mongodm::f; use mongodm::operator::*; struct MyModel { foo: i64, bar: i64, lorem: String, } // Statically checked let a = doc! { And: [ { f!(foo in MyModel): { Exists: true } }, { Or: [ { f!(bar in MyModel): { GreaterThan: 100 } }, { f!(lorem in MyModel): "ipsum" } ] } ] }; // Hardcoded strings let b = doc! { "$and": [ { "foo": { "$exists": true } }, { "$or": [ { "bar": { "$gt": 100 } }, { "lorem": "ipsum" } ] } ] }; // Generated document are identicals assert_eq!(a, b);