0

I am using firebase.server.TIMESTAMP as a priority (as pre previous question Firebase - 'pushWithPriority' - and validation )

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

This appears to work, setting the priority correctly.

However, I am adding a rule to ensure the timestamp is not set to a future time. Using this code:-

,"Offers" : {
        ".read" : "true"
        ,"$offerid" : {
          ".write" : "now >= newData.getPriority()"

This always fails. I have tried

".write": "true" // this works

and

".write" : "newData.getPriority()>=0" // this fails

and

".write" : "newData.getPriority()<0" // this fails

So I am starting to suspect the priority hasn't been resolved from the placeholder to a number yet?

Any suggestions??

Community
  • 1
  • 1
pperrin
  • 1,487
  • 15
  • 33
  • So what is the value of the priority? What do you get when you use `typeof` on it? Is it a number or a string? My guess is that it's `null` – Kato Feb 18 '15 at 17:19
  • Once written to the database the priority is a number - miliseconds since the Unix Epoch. What it is at the time the rule is evaluated - I have no idea. Is there a mechanism to show/return a 'typeof' value from a rule execution? – pperrin Feb 19 '15 at 00:51

0 Answers0