[英]If you want to get the conditional number of Childs in a firebase database, how to do it? [closed]
需要注意的是,它们应该是从今天开始的。 由于时间戳根据定义是一个时间点,您还可以使用它们将计数限制为从今天开始的计数。
下面是我想出的,但在var timestampDate
处仍然有错误:(
使用未声明的类型“timeinterval”
概括:
代码:
let uid1 = Auth.auth().currentUser!.uid
var today: Date = Date.init()
let thisUserRef1 = Database.database().reference().child("people").child(uid1)
let myPeopleRef1 = thisUserRef1.child("peopleWhoLike2")
myPeopleRef1.observeSingleEvent(of:DataEventType.value, with: { snapshot in
print(snapshot)
var timestampDate: timeinterval = snapshot
var otherDate: Date = Date.init(timeIntervalSince1970: timestampDate)
let calendar: Calendar = Calendar.current
let result = calendar.dateComponents([.day], from: timestampDate, to: today)
print("result.day")
let thisUserRef = Database.database().reference().child("people").child(uid1)
let myPeopleRef = thisUserRef.child("peopleWhoLike2")
.queryOrderedByValue().queryEqual(toValue:result.day<1 )
myPeopleRef.observeSingleEvent(of:DataEventType.value, with: { snapshot in
print(snapshot.childrenCount, "ooooo")
})
})
不var timestampDate: timeinterval = snapshot
时间间隔需要是TimeInterval
即var timestampDate: TimeInterval = snapshot
TimeInterval 是一种类型,因此您需要用正确的大写字母拼写它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.