[−][src]Function firestore_db_and_auth::documents::query
pub fn query(
auth: &impl FirebaseAuthBearer,
collection_id: &str,
value: Value,
operator: FieldOperator,
field: &str
) -> Result<Query>
Queries the database for specific documents, for example all documents in a collection of 'type' == "car".
Example:
#[derive(Debug, Serialize, Deserialize)] struct DemoDTO { a_string: String, an_int: u32, } use firestore_db_and_auth::{documents, dto}; &[include_str!("../../tests/service-account-for-tests.jwks")])?; let values: documents::Query = documents::query(&session, "tests", "Sam Weiss".into(), dto::FieldOperator::EQUAL, "id")?; for metadata in values { println!("id: {}, created: {}, updated: {}", metadata.name.as_ref().unwrap(), metadata.create_time.as_ref().unwrap(), metadata.update_time.as_ref().unwrap()); // Fetch the actual document // The data is wrapped in a Result<> because fetching new data could have failed let doc : DemoDTO = documents::read_by_name(&session, metadata.name.as_ref().unwrap())?; println!("{:?}", doc); }
Arguments
- 'auth' The authentication token
- 'collectionid' The collection id; "my_collection" or "a/nested/collection"
- 'value' The query / filter value. For example "car".
- 'operator' The query operator. For example "EQUAL".
- 'field' The query / filter field. For example "type".