'How to get a Fieldvalue only if other fieldvalues in the same document are true
How to: If I want to retrieve a FieldValue (String) only if in the same document there is another field (boolean) which is true. For Example: If I have a Document in Firestore which contains a Field: {name: "Some Name", active: true} and I only want the name to be retrieved if the field "active" is true. Is this possible? Does this question make sense? Sorry, I'm a self-taught developer and I have difficulties to explain stuff as a coder. But I hope you guys can still understand what I want to achieve.
Solution 1:[1]
You can run query to filter out the documents you don't want. like:
query(collection(db, "users"), where("active", "==", true));
But if you want retrieve a single fieldvalue like "name" and filter out other value in same document like "active" is impossible. firestore only retrieve whole document.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | flutroid |
