firebase hasChildren working in simulator but not angularFire -
i learning firebase have following simple rule set up:
{ "rules": { ".read": "auth != null", "messages": { ".read": "true", "$conversation_id": { ".write": "newdata.haschildren(['receiver_id','sender_id','timestamp'])" } } } }
in simulator write rule passes with:
{ "receiver_id":123, "sender_id":"test", "timestamp":123 }
using angularfire permission denied (uid defined):
var dat = { sender_id:uid, receiver_id: uid, timestamp: firebase.database.servervalue.timestamp }; database.ref('messages/mymessageid').push(dat);
if remove haschildren check message gets added database proper values populated. gives?
firebase.push()
automatically creates new unique id (similar array index), structure should let angularfire take care of using database.ref('messages').push(dat)
// fail because /mymessageid not contain child sender_id database.ref('messages/mymessageid').push(dat); { messages: { mymessageid: { uid: { sender_id: 1, ... } } } } // work database.ref('messages').push(dat); { messages: { uid: { sender_id: 1, ... } } }
Comments
Post a Comment