Permissions with where clause on data field

I want the capacity for a user to read and delete records on Firebase created by someone they invited to create records.

Created records have a field ‘resource.data.ownerUid’, with ownerId being the uid for the user that invited others to create records.

If I try something like:

allow read, delete: if request.auth.uid == resource.data.ownerUid;

But I get permission refused at the ‘get’ step of:

firestore.collection('screeningResponses')
  .where('screeningId', '==', screeningId)
  .get()

results in

FirebaseError: Missing or insufficient permissions.

At that point I was planning on iterating through the QuerySnapshot and deleting the records, but can’t get that far. Any suggestions?

166 thoughts on “Permissions with where clause on data field”

  1. Firebase security rules don’t filter data on their own. Instead they merely check whether the read operation is allowed according to the rules.

    For this reason your query will have to replicate what the rules require. Since your rules require that the user is the owner of the data they read, the query must do the same:

    firestore.collection('screeningResponses')
      .where('ownerUid', '==', firebase.auth().currentUser.uid) // 👈 this is new
      .where('screeningId', '==', screeningId)
      .get()
    
    Reply
  2. Pingback: 10mg cialis online
  3. It’s appropriate time to make some plans for the long run and
    it’s time to be happy. I’ve learn this post and if I could I wish to counsel you some attention-grabbing issues or advice.

    Maybe you can write next articles referring to this article.
    I wish to read even more issues about it!

    Reply
  4. It’s appropriate time to make some plans for the future
    and it is time to be happy. I’ve learn this post and if I could I wish
    to suggest you some interesting things or advice. Maybe you could write next articles regarding
    this article. I want to learn more things about it!

    Reply
  5. It’s the best time to make some plans for the future and it’s time to be happy.
    I’ve read this post and if I could I want to suggest you some interesting things or advice.
    Perhaps you can write next articles referring to this
    article. I want to read even more things about it!

    Reply
  6. I’ve been browsing online more than three hours today, yet I never
    found any interesting article like yours. It
    is pretty worth enough for me. Personally, if all site
    owners and bloggers made good content as you did, the net will be much more useful than ever before.

    Reply
  7. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my opinion, if all
    website owners and bloggers made good content as you did, the net will
    be much more useful than ever before.

    Reply
  8. I and also my guys came reviewing the best points located on your site and so at once I had an awful feeling I never expressed respect to the web blog owner for those secrets. These ladies were definitely certainly joyful to see all of them and now have honestly been having fun with these things. We appreciate you simply being considerably helpful and then for having some fantastic issues millions of individuals are really desperate to be aware of. My sincere apologies for not saying thanks to earlier.

    Reply
  9. It is the best time to make a few plans for the future and it’s time to be happy.
    I have learn this submit and if I may I want to suggest you some attention-grabbing issues or tips.
    Maybe you could write next articles referring to this article.

    I want to read even more issues approximately it!

    Reply
  10. I’ll immediately grasp your rss as I can’t find your e-mail
    subscription link or newsletter service. Do you have any? Please allow
    me understand so that I may just subscribe.

    Thanks.

    Reply
  11. Pingback: celebrex ad
  12. Pingback: cymbalta for grief
  13. Hello, i read your blog from time to time and i own a similar one and i was just wondering if you
    get a lot of spam feedback? If so how do you reduce it, any plugin or anything you can recommend?
    I get so much lately it’s driving me mad so any assistance is
    very much appreciated.

    Reply
  14. I’ve been surfing online greater than three hours nowadays,
    but I by no means found any attention-grabbing article like yours.
    It is lovely price enough for me. In my opinion, if all website owners and bloggers made good content as you probably did, the web might be a lot more useful than ever before.

    Reply
  15. Its such as you learn my thoughts! You seem to understand so much about this, like you wrote the guide in it or something.
    I feel that you could do with a few percent to drive the message house a bit, however instead of that, this is fantastic blog.
    An excellent read. I will certainly be back.

    Reply
  16. Pingback: sildenafil cost uk
  17. Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year
    old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

    Reply
  18. I’ll right away snatch your rss feed as I can not find your
    e-mail subscription link or e-newsletter service.
    Do you’ve any? Please allow me recognize so
    that I may subscribe. Thanks.

    Reply
  19. Hi, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of
    spam comments? If so how do you protect against it,
    any plugin or anything you can recommend? I get so much lately it’s driving me mad so any
    assistance is very much appreciated.

    Reply
  20. I’ll right away grab your rss feed as I can not in finding your
    e-mail subscription hyperlink or newsletter service.
    Do you have any? Please permit me recognise in order that I
    could subscribe. Thanks.

    Reply
  21. I will right away grasp your rss feed as I can not in finding your e-mail subscription hyperlink or newsletter service.
    Do you have any? Please allow me recognize so that I may just
    subscribe. Thanks.

    Reply
  22. Greetings from Florida! I’m bored at work
    so I decided to check out your site on my iphone during lunch break.
    I enjoy the information you provide here and can’t wait to take
    a look when I get home. I’m surprised at how quick your blog loaded on my
    phone .. I’m not even using WIFI, just 3G .. Anyhow, superb blog!

    Reply
  23. I will right away clutch your rss feed as I can not in finding your
    email subscription hyperlink or newsletter service.
    Do you’ve any? Please let me recognise in order that I may just subscribe.
    Thanks.

    Reply
  24. Greetings! I’ve been following your weblog for a while
    now and finally got the bravery to go ahead and give you a shout out from Porter Tx!

    Just wanted to say keep up the fantastic job!

    Reply
  25. I have been browsing online more than 3 hours lately,
    yet I by no means found any fascinating article like yours.
    It is lovely price sufficient for me. In my opinion, if all
    website owners and bloggers made just right content as you probably did, the web might
    be much more helpful than ever before.

    Reply
  26. Hmm is anyone else encountering problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.|

    Reply
  27. Hi there, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam responses?

    If so how do you protect against it, any plugin or anything you can suggest?

    I get so much lately it’s driving me insane so any support is very
    much appreciated.

    Reply
  28. Pingback: cialis otc date
  29. I have been browsing on-line more than 3 hours as of late, but I never discovered any attention-grabbing article like yours.
    It’s lovely price sufficient for me. In my view, if all site
    owners and bloggers made excellent content as you probably did, the web might be a lot more useful than ever before.

    Reply
  30. Howdy! This post couldn’t be written any better!
    Going through this post reminds me of my previous roommate!

    He always kept talking about this. I will forward this post to him.

    Pretty sure he’s going to have a good read.
    Many thanks for sharing!

    Reply
  31. Thanks for this excellent article. One more thing to mention is that nearly all digital cameras come equipped with any zoom lens that permits more or less of the scene to get included by simply ‘zooming’ in and out. These kind of changes in the aim length are reflected from the viewfinder and on huge display screen right on the back of the camera.

    Reply
  32. Greetings! I’ve been following your web site for a while now and finally got the bravery to go
    ahead and give you a shout out from Lubbock Tx! Just wanted to mention keep up the great job!

    Reply
  33. What i don’t understood is in fact how you’re not
    really much more well-favored than you may be now.
    You’re so intelligent. You recognize thus significantly in the case of this matter, made me in my opinion consider it from so many numerous angles.
    Its like women and men aren’t interested unless it is one thing to do with Lady gaga!
    Your personal stuffs nice. At all times take care of it up!

    Reply

Leave a Comment