Skip to content

Commit

Permalink
Change Client::create signature
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 4, 2023
1 parent 6318e46 commit 5f2c5f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions rust/crates/web/src/infra/firestore.rs
Expand Up @@ -37,11 +37,12 @@ mod tests {
let input = V {
k1: "v1".to_string(),
};
let created = client.create(&collection_path, input.clone()).await?;
assert!(created
.name()
.path()
.starts_with("projects/demo-project1/databases/(default)/documents/repositories/"),);
let document_path = collection_path.clone().doc("1".to_string());
let created = client.create(&document_path, input.clone()).await?;
assert_eq!(
created.name().path(),
"projects/demo-project1/databases/(default)/documents/repositories/1"
);
assert_eq!(created.clone().data(), input);

// READ (GET)
Expand Down
8 changes: 4 additions & 4 deletions rust/crates/web/src/infra/firestore/client.rs
Expand Up @@ -99,7 +99,7 @@ impl Client {

pub async fn create<T, U>(
&mut self,
collection_path: &CollectionPath,
document_path: &DocumentPath,
fields: T,
) -> Result<Document<U>, Error>
where
Expand All @@ -109,9 +109,9 @@ impl Client {
let response = self
.client
.create_document(CreateDocumentRequest {
parent: collection_path.parent().path(),
collection_id: collection_path.id().to_string(),
document_id: "".to_string(),
parent: document_path.parent().parent().path(),
collection_id: document_path.parent().id().to_string(),
document_id: document_path.id().to_string(),
document: Some(FirestoreDocument {
name: "".to_string(),
fields: {
Expand Down

0 comments on commit 5f2c5f9

Please sign in to comment.