1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use google_api_proto::google::firestore::v1::structured_query;

use crate::FieldPath;

pub trait FieldPathOrderExt {
    fn ascending(&self) -> structured_query::Order;
    fn descending(&self) -> structured_query::Order;
}

impl FieldPathOrderExt for FieldPath {
    fn ascending(&self) -> structured_query::Order {
        structured_query::Order {
            field: Some(self.to_field_reference()),
            direction: structured_query::Direction::Ascending as i32,
        }
    }

    fn descending(&self) -> structured_query::Order {
        structured_query::Order {
            field: Some(self.to_field_reference()),
            direction: structured_query::Direction::Descending as i32,
        }
    }
}