Skip to content

Commit

Permalink
Improve DocumentName doc
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 20, 2023
1 parent 97df82e commit c22c77c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/document_name.rs
Expand Up @@ -16,7 +16,8 @@ use crate::{
/// ```rust
/// # fn main() -> anyhow::Result<()> {
/// use firestore_path::DocumentName;
/// use std::str::FromStr;
/// # use firestore_path::{CollectionId,CollectionName,DatabaseName,DocumentId};
/// # use std::str::FromStr;
///
/// let document_name = DocumentName::from_str(
/// "projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
Expand All @@ -25,6 +26,24 @@ use crate::{
/// document_name.to_string(),
/// "projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
/// );
///
/// assert_eq!(
/// document_name.clone().collection("messages")?,
/// CollectionName::from_str(
/// "projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
/// )?
/// );
/// assert_eq!(document_name.collection_id(), &CollectionId::from_str("chatrooms")?);
/// assert_eq!(
/// document_name.database_name(),
/// &DatabaseName::from_str("projects/my-project/databases/my-database/documents")?
/// );
/// assert_eq!(document_name.document_id(), &DocumentId::from_str("chatroom1")?);
/// assert_eq!(
/// document_name.clone().parent(),
/// CollectionName::from_str("projects/my-project/databases/my-database/documents/chatrooms")?
/// );
///
/// # Ok(())
/// # }
/// ```
Expand Down

0 comments on commit c22c77c

Please sign in to comment.