涉及.getPriority()的Firebase安全规则的问题

时间:2013-11-27 23:37:19

标签: firebase angularfire

我试图让用户使用“ref.setPriority(priority);”设置项目的优先级。但我也想确保他们不能将它设置为小于“current_priority -10”。

但是这个表达:

".write": "data.getPriority() - newData.getPriority() > 10"

给我一​​个错误“表达式:左操作数不是数字”。

然而:

data.getPriority().length - newData.getPriority().length >=1

工作类型(保存时没有错误,但当我尝试设置优先级时,我会拒绝''权限)

Firebase是否认为优先级不是数字?如果是这样,有办法解决这个问题吗?

编辑:我将从Firebase添加一个项目的实际JSON:

"http_www_latimes_com_local_lanow_la_me_ln_two_police_officers_shot_in_inglewood_20131127_0_1591070_story_track_rss" : {
  ".priority" : 4458.0,
  "date" : 1385616825,
  "url" : "http://www.latimes.com/local/lanow/la-me-ln-two-police-officers-shot-in-inglewood-20131127,0,1591070.story",
  "discuss" : "http://www.reddit.com/r/news/comments/1rlmzy/two_inglewood_police_officers_shot_active_shooter/",
  "small_image" : "http://i.embed.ly/1/display/resize?height=168.75&width=300&url=http%3A%2F%2Fwww.trbimg.com%2Fimg-529660a6%2Fturbine%2Fla-me-ln-two-police-officers-shot-in-inglewood-20131127%2F400%2F16x9&key=6b62489a749d11e1b62e4040d3dc5c07",
  "title" : "Two Inglewood police officers shot; active shooter in area",
  "height" : 168.75,
  "desc" : "Two Inglewood police officers were shot Wednesday afternoon and taken to a local hospital, Inglewood police officials said.",
  "width" : 300,
  "id" : "http_www_latimes_com_local_lanow_la_me_ln_two_police_officers_shot_in_inglewood_20131127_0_1591070_story_track_rss"
},

所以也许它应该是'root.getPriority()',我不确定。

1 个答案:

答案 0 :(得分:1)

看起来我们的规则验证中存在错误。您尝试过的表达式(“data.getPriority() - newData.getPriority()> 10”)应该是合法的,并按照您的意愿行事,但它目前被错误地拒绝了。我们已经做了修复,但直到下周的某个时候它才会投入生产。很抱歉给您带来不便!