Skip to content

Commit

Permalink
Add RootPath::database_name
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 3, 2023
1 parent f79e58b commit 4f6454f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rust/crates/web/src/infra/firestore/path.rs
Expand Up @@ -173,6 +173,13 @@ impl RootPath {
self.database_id.as_str()
}

pub fn database_name(&self) -> String {
format!(
"projects/{}/databases/{}",
self.project_id, self.database_id
)
}

pub fn path(&self) -> String {
format!(
"projects/{}/databases/{}/documents",
Expand Down Expand Up @@ -348,6 +355,10 @@ mod tests {
project_id: "demo-project1".to_string(),
};
assert_eq!(root_path.database_id(), "(default)");
assert_eq!(
root_path.database_name(),
"projects/demo-project1/databases/(default)"
);
assert_eq!(
root_path.path(),
"projects/demo-project1/databases/(default)/documents"
Expand Down

0 comments on commit 4f6454f

Please sign in to comment.