0
votes

Firestore Security Rules: Is there a way to "chain" a get and an exists ? I would like to call exists() but I need to get() the docID first. Something like: exists(/databases/$(database)/documents/Collection2/ ** here I should do a get(/...) to obtain the desired docID ** );

I tried to make all in one line, 2 functions, ... I couldn't get anything to work.

function f1(entryParam) {
  return get(/..).data.myDocId;
}

function f2(docID) {
  returns exists(/databases/$(database)/documents/collection2/$(docID));
}

and then:

match /col3/{doc3ID} {
  allow xx: if f2(f1(doc3ID));
}

None of what I tried worked. Do I really have to have the needed data "by hand", i.e., within one query distance?

Thanks in advance for your help / answers. Philippe

1

1 Answers

0
votes

I found the solution (RTFM!) the trick is to use the path object: rules.Path documentation