feat: added sorts for DatabaseQueryOptions
This commit is contained in:
parent
432e38c808
commit
a1fe4ae68c
25
src/lib.rs
25
src/lib.rs
|
@ -324,8 +324,28 @@ impl Databases {
|
||||||
|
|
||||||
let mut request = self.http_client.post(url);
|
let mut request = self.http_client.post(url);
|
||||||
|
|
||||||
if let Some(filter) = options.filter {
|
let json = if let Some(filter) = options.filter {
|
||||||
request = request.json(&json!({ "filter": filter }));
|
Some(json!({ "filter": filter }))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let json = if let Some(sorts) = options.sorts {
|
||||||
|
if let Some(mut json) = json {
|
||||||
|
json.as_object_mut()
|
||||||
|
.expect("Some object to be editable")
|
||||||
|
.insert("sorts".to_string(), sorts);
|
||||||
|
|
||||||
|
Some(json)
|
||||||
|
} else {
|
||||||
|
Some(json!({ "sorts": sorts }))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
json
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(json) = json {
|
||||||
|
request = request.json(&json);
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = (self.request_handler)(&mut request).await?;
|
let response = (self.request_handler)(&mut request).await?;
|
||||||
|
@ -387,6 +407,7 @@ pub struct DatabaseQueryOptions<'a> {
|
||||||
pub database_id: &'a str,
|
pub database_id: &'a str,
|
||||||
// TODO: Implement spec for filter?
|
// TODO: Implement spec for filter?
|
||||||
pub filter: Option<Value>,
|
pub filter: Option<Value>,
|
||||||
|
pub sorts: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
Loading…
Reference in a new issue