Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 275 Vote(s) - 3.65 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Firebase - 'pushWithPriority' - and validation

#1
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!).
Reply

#2
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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through