[][src]Function firestore_db_and_auth::documents::list

Important traits for List<'a, T, BEARER>
pub fn list<T, BEARER>(
    auth: &BEARER,
    collection_id: impl Into<String>
) -> List<T, BEARER> where
    BEARER: FirebaseAuthBearer

List all documents of a given collection.

Please note that this API acts as an iterator of same-like documents. This type is not suitable if you want to list documents of different types.

Example:

#[derive(Debug, Serialize, Deserialize)]
struct DemoDTO { a_string: String, an_int: u32, }

use firestore_db_and_auth::documents;

                                        &[include_str!("../../tests/service-account-for-tests.jwks")])?;

let values: documents::List<DemoDTO, _> = documents::list(&session, "tests");
for doc_result in values {
    // The data is wrapped in a Result<> because fetching new data could have failed
    // A tuple is returned on success with the document itself and and metadata
    // with .name, .create_time, .update_time fields.
    let (doc, _metadata) = doc_result?;
    println!("{:?}", doc);
}

Arguments

  • 'auth' The authentication token
  • 'collection_id' The document path / collection; For example "my_collection" or "a/nested/collection"