0

enter image description here

I want to add rule so that no duplicate rdate is added in database. I am beginner to firebase and i don't know how to create rules for stopping duplicate.

Colthurling
  • 75
  • 1
  • 1
  • 7

1 Answers1

1

This isn't possible with security rules, because rules don't have a way of performing queries for other nodes. The only way you can access other nodes in the database is using val() at the specific location you're interested in knowing about, but you have to know the full path to that specific location.

Your alternative is to make a request through a backend you control (such as Cloud Functions), and have that backend perform the query to check if there is a conflict.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • what if we know the full path like here `".write":"root.child('NEWSCROW').child('news_item').child('navbharttimes').child('$').child('rdate').val()===newData.child('rdate').val()"` – Colthurling Jan 02 '20 at 10:35