not equalがない
firestoreにはnot equalがないようです。
whereでlessthanとgraterthanを組み合わせればいけると書いてあったのですが
文字列の場合だといけなかった。。。のでfilterを使って対処
struct UserData{
let uuid:String
let userName:String
let nowLatitude: Double
let nowLongitude: Double
let updatedAt: Timestamp
init(uuid:String,userName:String,nowLatitude: Double, nowLongitude: Double, updatedAt: Timestamp) {
self.uuid = uuid
self.userName = userName
self.nowLatitude = nowLatitude
self.nowLongitude = nowLongitude
self.updatedAt = updatedAt
}
init(document: [String: Any]) {
uuid = document["uuid"] as? String ?? ""
userName = document["user_name"] as? String ?? ""
nowLatitude = document["now_latitude"] as? Double ?? 0
nowLongitude = document["now_longitude"] as? Double ?? 0
updatedAt = document["updated_at"] as? Timestamp ?? Timestamp()
}
}
てなかんじで辞書を作っていれば
以下のようにフィルターをかけてあげればできる
db.collection("users")
.addSnapshotListener { querySnapshot, error in
guard let documents = querySnapshot?.documents else {
print("Error fetching documents: \(error!)")
return
}
print("userDateReload")
self.usersList = documents
.filter{UserData(document:$0.data()).uuid != self.AppDelegateDatas.UUID }
.map { UserData(document: $0.data()) }
print(self.usersList)
}