传递给equalTo()的第一个参数不能是对象

时间:2016-05-05 12:07:01

标签: firebase firebase-realtime-database

我尝试使用此代码来获取其startdate等于“Today”的事件:

`var ref = new Firebase("https://event-application.firebaseio.com/event");
$scope.evt=$firebaseArray(ref.child('event'));
var a= new Date(); 
ref.orderByChild("startdate").equalTo(a).on("child_added",function(snapshot){
console.log(snapshot.val() ) 
})` 

但是我收到了这个错误:

First argument passed to equalTo() cannot be an object

1 个答案:

答案 0 :(得分:2)

这是因为您正在使用Date对象。

检查documentation

  

equalTo()equalTo(value,[key])

     

参数

     

value String,Number,Null,Boolean

     

要匹配的值。参数类型取决于此查询中使用的orderBy *()函数。指定与orderBy *()类型匹配的值。与orderByKey()结合使用时,该值必须是字符串。