Hi
I am looking over a get(/databases/) call I recently made within my Firestore security rules to try and understand why what I wrote did not offer the result I expected, and in this close look, I'd like to understand how the call works so that in future the expected result can be the result.
The call I wrote was:
match /users/{docId}/userA/{docId2}/exclusiveA/{docId3} {
// allow read if user: (1) has a uid, (2) has creditcard = false
allow get: if request.auth.uid != null && get(/databases/$(database)/documents/exclusiveB/$(request.auth.uid)).data.creditCard == false;
}
In this call, I have imagined that the '/databases/$(database)/documents' aspect is a mandatory feature of the call, however, more recently I noticed a get(/databases/) call that did not feature this aspect, and instead the get call was expressed as get(/collectionName/ ...).
A question I have is, when is it acceptable by Firestore for the get(/databases/) call to omit the '/databases/$(database)/documents' aspect and begin with the relevant collection's name?
I have understood the '/users/$(request.auth.uid)' aspect of the call I made, to be incorrect, because in my case, the 'users' collection was an empty collection, and so the $(request.auth.uid) tag was being expressed across a collection where no field or value could confirm a reference to the current user.
A question I have is, what does the $(request.auth.uid) tag within the get(/databases/) call mean? For example, it is set to match the document-id of the relevant collection. So, is it seeking a document with the same iD as the current user? And if "yes", then under what circumstances would Firestore create a document-id with exactly the same iD as a user?
A question I have is, if the $(request.auth.uid) tag within a get(/databases/) call is not seeking a document-id with the same iD as the current user, then, is the tag seeking a field or a field-value that is equal to the identity of the current user? In which case, the collection to which the $(request.auth.uid) tag refers needs to have a field or a field value that is equal to user identities before a match is possible, right?
A question I have is, in the Firestore documentation, the term 'fully specified path' is stated as being a requirement for get(/databases/) calls. What is meant by 'fully specified path' and is there an example of a 'fully specified path' that is illustrated with a photographic reference to Firestore? For example, how would the 'fully specified path' within the get(/databases/) call differ where a sub-collection is relevant from when a sub-collection is not relevant? (When the relevant data is within a sub-collection versus when the relevant data is within a parent collection)
The '.data' aspect of the get(/databases/) call seems to mean that the preceding aspect of the call has referred to a specific document, so that the '.data' aspect then taps into a map of every field concerning that specific document, where the value of a field can then be accessed.
A question I have is, is my interpretation of the '.data' aspect of the get(/databases/) call accurate, and how would you explain its meaning if "no" please?
With thanks.