Skip to content

Commit

Permalink
Add DocumentName::collection_id
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 19, 2023
1 parent 168181c commit d078d8c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/document_name.rs
Expand Up @@ -96,6 +96,29 @@ impl DocumentName {
))
}

/// Returns the `CollectionId` of this `DocumentName`.
///
/// # Examples
///
/// ```rust
/// # fn main() -> anyhow::Result<()> {
/// use firestore_path::{CollectionId,DocumentName};
/// use std::str::FromStr;
///
/// let document_name = DocumentName::from_str(
/// "projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
/// )?;
/// assert_eq!(
/// document_name.collection_id(),
/// &CollectionId::from_str("chatrooms")?
/// );
/// # Ok(())
/// # }
/// ```
pub fn collection_id(&self) -> &CollectionId {
self.document_path.collection_id()
}

/// Returns the `DatabaseName` of this `DocumentName`.
///
/// # Examples
Expand Down

0 comments on commit d078d8c

Please sign in to comment.