Fetch only publish entries from Directus
This commit is contained in:
parent
320302eba9
commit
c48975bf79
1 changed files with 4 additions and 4 deletions
|
@ -25,7 +25,7 @@ impl DirectusClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_items_in_collection(&self, collection: &str, primary_key: &str) -> Result<Vec<String>> {
|
pub async fn list_items_in_collection(&self, collection: &str, primary_key: &str) -> Result<Vec<String>> {
|
||||||
let response = self.reqwest_client.get(format!("{}/items/{}?fields={}", self.base_url, collection, primary_key))
|
let response = self.reqwest_client.get(format!("{}/items/{}?fields={}&filter[status][_eq]=published", self.base_url, collection, primary_key))
|
||||||
.header("Authorization", format!("Bearer {}", self.access_token))
|
.header("Authorization", format!("Bearer {}", self.access_token))
|
||||||
.send().await?;
|
.send().await?;
|
||||||
let items_json = response.json::<Vec<HashMap<String, String>>>().await?;
|
let items_json = response.json::<Vec<HashMap<String, String>>>().await?;
|
||||||
|
@ -34,7 +34,7 @@ impl DirectusClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_item_json(&self, collection: &str, id: &str) -> Result<serde_json::Value> {
|
pub async fn get_item_json(&self, collection: &str, id: &str) -> Result<serde_json::Value> {
|
||||||
let response = self.reqwest_client.get(format!("{}/items/{}/{}?fields=*,*.*,translations.*", self.base_url, collection, id))
|
let response = self.reqwest_client.get(format!("{}/items/{}/{}?fields=*,*.*,translations.*&filter[status][_eq]=published", self.base_url, collection, id))
|
||||||
.header("Authorization", format!("Bearer {}", self.access_token))
|
.header("Authorization", format!("Bearer {}", self.access_token))
|
||||||
.send().await?;
|
.send().await?;
|
||||||
let json = &response.json::<serde_json::Value>().await?;
|
let json = &response.json::<serde_json::Value>().await?;
|
||||||
|
@ -42,7 +42,7 @@ impl DirectusClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_item<T: for<'a> Deserialize<'a>>(&self, locale: &str, collection: &str, id: &str) -> Result<T> {
|
pub async fn get_item<T: for<'a> Deserialize<'a>>(&self, locale: &str, collection: &str, id: &str) -> Result<T> {
|
||||||
let response = self.reqwest_client.get(format!("{}/items/{}/{}?fields=*,*.*,translations.*", self.base_url, collection, id))
|
let response = self.reqwest_client.get(format!("{}/items/{}/{}?fields=*,*.*,translations.*&filter[status][_eq]=published", self.base_url, collection, id))
|
||||||
.header("Authorization", format!("Bearer {}", self.access_token))
|
.header("Authorization", format!("Bearer {}", self.access_token))
|
||||||
.send().await?;
|
.send().await?;
|
||||||
let json = &response.json::<serde_json::Value>().await?;
|
let json = &response.json::<serde_json::Value>().await?;
|
||||||
|
@ -58,7 +58,7 @@ impl DirectusClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_all_items_in_collection<T: for<'a> Deserialize<'a>>(&self, locale: &str, collection: &str) -> Result<Vec<T>> {
|
pub async fn get_all_items_in_collection<T: for<'a> Deserialize<'a>>(&self, locale: &str, collection: &str) -> Result<Vec<T>> {
|
||||||
let response = self.reqwest_client.get(format!("{}/items/{}?fields=*,*.*,translations.*&sort=-date_created", self.base_url, collection))
|
let response = self.reqwest_client.get(format!("{}/items/{}?fields=*,*.*,translations.*&sort=-date_created&filter[status][_eq]=published", self.base_url, collection))
|
||||||
.header("Authorization", format!("Bearer {}", self.access_token))
|
.header("Authorization", format!("Bearer {}", self.access_token))
|
||||||
.send().await?;
|
.send().await?;
|
||||||
let json = &response.json::<serde_json::Value>().await?;
|
let json = &response.json::<serde_json::Value>().await?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue