我正在尝试查询帖子集。每个帖子都有一个“监视的部分”,如果监视的部分包含用户,则查询应返回该值。但是,当我运行查询时:
$paymentResults = NewYorkTimesService.makePayment(paymentJSON); //this does http stuff too.
$paymentResults.subscribe(() => /*I guess it was successful */ , (error)=> /*it failed */);
我收到错误 let postsReference = Firestore.firestore().collection("posts")
let watchingQuery = postsReference.order(by: "watchedBy/\(UID!)").start(at: [""])
watchingQuery.addSnapshotListener { querySnapshot, error in
guard let snapshot = querySnapshot else {
print("Error fetching snapshots: \(error!)")
return
}
snapshot.documentChanges.forEach { diff in
if (diff.type == .added) {
}
if (diff.type == .modified) {
}
if (diff.type == .removed) {
}
}
。等效的firebase查询工作正常:
Invalid field path (watchedBy/BmVoasdfa34fdtiucWSb8XPPM42). Paths must not contain '~', '*', '/', '[', or ']''
我尝试将代码更改为 let watchedByQuery = postReference.queryOrdered(byChild: "/watchedBy/" + UID!).queryStarting(atValue: "")
。该查询有效,但是FireStore没有任何返回。
编辑:
尝试过:
let watchingQuery = postsReference.order(by: "watchedBy.\(UID!)").start(at: [""])
但仍然返回空值。
答案 0 :(得分:0)
最后,我的发布方法仍然与进行乘法更新的firebase方法相同。因此,发布机制将发布到错误的路径。