1

Is it possible to check how many posts a user already have associated to them, and if that count exceeds a certain limit, then invalidate the request to create a new post?

I was thinking about having some basic settings at: /settings/limits/posts = 5.

And in the rules have something like:

".write": "root.child('settings/limits/posts').val() <= root.child('users/' + auth.id + 'posts').numChildren()"

That doesn't work, because numChildren isn't available. So how do you do such a check?

The only solution I've come up with, is to have a external server to do a count of a user's existing posts and only allow the server to write new posts.

Anybody else got any suggestions?

hhorn
  • 101
  • 1
  • 7
  • Possible duplicate of [Limit number of records that can be written to a path (reference other paths in security rules)](http://stackoverflow.com/questions/22644202/limit-number-of-records-that-can-be-written-to-a-path-reference-other-paths-in) – Niels Jul 14 '16 at 08:31
  • You can't as you already discovered. See here for some proposed work-arounds: http://stackoverflow.com/a/22646143/6155664 – Niels Jul 14 '16 at 08:33

0 Answers0