pub fn list<T, AUTH>(
auth: &AUTH,
collection_id: impl Into<String>,
) -> Pin<Box<dyn Stream<Item = Result<(T, Document)>> + Send>>where
for<'b> T: Deserialize<'b> + 'static,
AUTH: FirebaseAuthBearer + Clone + Send + Sync + 'static,
Expand description
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:
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize)]
struct DemoDTO { a_string: String, an_int: u32, }
use firestore_db_and_auth::documents;
let mut stream = documents::list(&session, "tests");
while let Some(Ok(doc_result)) = stream.next().await {
// 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;
let doc: DemoDTO = doc;
println!("{:?}", doc);
}
§Arguments
- ‘auth’ The authentication token
- ‘collection_id’ The document path / collection; For example “my_collection” or “a/nested/collection”