3

I really want to 'push with priority'. But this doesn't exist, so I am planning on doing a push with out parameters, then a setWithPriority with the returned reference. Similar to the example in the docs.

var messageListRef = new Firebase('https://samplechat.firebaseio-demo.com/message_list');
var newMessageRef = messageListRef.push();
newMessageRef.set({ 'user_id': 'fred', 'text': 'Yabba Dabba Doo!' });

but more like

var messageListRef = new Firebase('https://samplechat.firebaseio-demo.com/message_list');
var newMessageRef = messageListRef.push();
newMessageRef.setWithPriority({ 'user_id': 'fred', 'text': 'Yabba Dabba Doo!' },1000);

What I can't find is what happens to validation, call backs on the empty push?

Does it try to create an empty node - firing the validation and call backs etc?

Or does it just return a reference that is (sort of) guaranteed to be unique of all other pushes to that parent? With the 'add child'/validation etc firing only on the 'set'?

Edit

Ok. Having had it confirmed that there is no server side interaction on an parameterless Push - my code now reads:

var ref = window.lastref.child("Offers").push();
ref.setWithPriority(spaceof.data, Firebase.ServerValue.TIMESTAMP,function (data) { $("body").prepend(data); }

The firebase timstamp successfully gives a serverside timestamp as a priority, I intend to use this priority for garbage collection - deleting old 'offers' that have been laying around.

To prevent clientside spoofing I'll be looking to add a validation/security rule that the priority of a new node has to be with in a few seconds of the actual serverside timestamp (if I get stuck, I'll be back!).

3
  • Push simply creates a unique id and returns a reference to it. It is a pure client-side operation, so no server-side validations (e.g. Firebase's security rules) are triggered. Commented Feb 17, 2015 at 14:11
  • Great - thanks Frank - saved me a load of experimenting!
    – pperrin
    Commented Feb 17, 2015 at 14:29
  • Looks like this should be an answer @FrankvanPuffelen
    – Kato
    Commented Feb 18, 2015 at 16:50

1 Answer 1

1

Push simply creates a unique id and returns a reference to it. It is a pure client-side operation, so no server-side validations (e.g. Firebase's security rules) are triggered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.