Rules to avoid repeated data on Firebase -
i need create validation rule in firebase don't have repeated data primary key in relational db. here code trying:
"roles": { ".read": "auth.uid != null", "$rol_id": { ".write": "auth.uid != null", ".validate": "newdata.haschildren(['description', 'state'])", "description": { ".validate": "newdata.isstring() && newdata.val().matches(/[a-za-z]$/i) && root.child('roles').child('$rol_id').child('description').val() != root.child('roles').child('$rol_id').child('description').exists()" }, "state": { ".validate":"newdata.isboolean()" } } },
the problem can't enter in $rol_id
unless give constant value need evaluate in each object.
this structure roles in firebase:
"roles" : { "-kmohjag6djjebiq3oiv" : { "creationdate" : 1468689365795, "description" : "administrador", "id" : "-kmohjag6djjebiq3oiv", "permissions" : { "inputs" : true, "kardex" : true, "outputs" : true, "persons" : true, "product" : false, "rol" : true, "sales" : true, "supplier" : true, "user" : true }, "state" : true }, }
Comments
Post a Comment