我在数据对象中使用ServerTimeStamp,现在我只想检索当前数据。
var happycount = admin.database().ref(`/tariq-road/happy`)
.orderByChild('timeStamp')
.equalTo(Date.now())
.once('value', (snapshot) => {
var data = snapshot.numChildren()
console.log('data: ', data)
})
如何获取今天的数据?
答案 0 :(得分:1)
var start = new Date();
start.setHours(0,0,0,0);
var end = new Date();
end.setHours(23,59,59,999);
var happycount = admin.database().ref(`/tariq-road/happy`)
.orderByChild('timeStamp')
.startAt(start.valueOf())
.endAt(end.valueOf())
.once('value', (snapshot) => {
var data = snapshot.numChildren()
console.log('data: ', data)
})