Skip to content

Commit ab0ca09

Browse files
authored
[ENH]: (Rust client): add collection.modify() method (#5681)
1 parent a4693b5 commit ab0ca09

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

rust/chroma/src/collection.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ impl ChromaCollection {
6464
self.send::<(), u32>("count", Method::GET, None).await
6565
}
6666

67+
pub async fn modify(
68+
&mut self,
69+
new_name: Option<impl AsRef<str>>,
70+
new_metadata: Option<Metadata>,
71+
) -> Result<(), ChromaClientError> {
72+
self.send::<_, ()>(
73+
"modify",
74+
Method::PUT,
75+
Some(serde_json::json!({
76+
"new_name": new_name.as_ref().map(|s| s.as_ref()),
77+
"new_metadata": new_metadata,
78+
})),
79+
)
80+
.await?;
81+
82+
let mut updated_collection = (*self.collection).clone();
83+
if let Some(name) = new_name {
84+
updated_collection.name = name.as_ref().to_string();
85+
}
86+
if let Some(metadata) = new_metadata {
87+
updated_collection.metadata = Some(metadata);
88+
}
89+
90+
self.collection = Arc::new(updated_collection);
91+
92+
Ok(())
93+
}
94+
6795
pub async fn get(
6896
&self,
6997
ids: Option<Vec<String>>,

0 commit comments

Comments
 (0)