title: Filter/some on list of objects in a Firestore security rule
body: <p>In a Firestore security rule, I'm trying to check if the user attempting to create/delete a document in one collection is also the owner of that object, as marked in another collection. Basically, my data looks something like this:</p>
  <ul>
  <li>In the <code>users</code> collection, each user has a document like this:</li>
  </ul>
  <pre><code>{
      name: 'john',
      userItems: [
          {
              id: 'random-id',
              ...
          }, 
          ...
      ],
      ...
  }
  </code></pre>
  <ul>
  <li>In the <code>items</code> collection (which I am writing the rule for), all of the items from all of the users of the platform are there, and have Firestore IDs which correspond to the <code>id</code> keys in the elements of the <code>items</code> list of their owners. So if <code>john</code> created an item with the id <code>random-id</code>, his user document would look like the above, and there would be a new document in the <code>items</code> collection with the Firestore ID of <code>random-id</code>.</li>
  </ul>
  <p>What I am trying to achieve is to create a security rule wherein a document in the <code>items</code> collection can only be updated if the user document of the currently authed user, which I can access with <code>get(/databases/$(database)/documents/users/$(request.auth.uid))</code>, has an element in their <code>userItems</code> list which has the <code>id</code> key equal to <code>request.resource.id</code>. If this were normal JS, I'd probably do something like:</p>
  <pre class="lang-js prettyprint-override"><code>match /items/{item} {
      allow write: if get(/databases/$(database)/documents/users/$(request.auth.uid))
          .data
          .userItems
          .some(userItem =&gt;
              userItem.id === request.resource.id
          )
  }
  </code></pre>
  <p>However, the Firestore <a href="https://firebase.google.com/docs/reference/rules/rules.List" rel="nofollow noreferrer">List interface</a> is very lacklustre, and doesn't support fancy operations like <code>.some</code>, or even basic/manual looping (as far as I'm aware). I've been trying to come up with some clever way around this, but even <code>.join</code>ing the list and <code>.match</code>ing the resulting string with some fancy RegExp wouldn't work, since I'm pretty sure that maps would parse as <code>'[object Object]'</code> instead of stringifying properly.</p>
  <p>Is there any way to do this using standard Firestore rules, without reconfiguring my DB structure?</p>