小编Con*_*ejo的帖子

Firebase 错误 - 向 Query.startAt() 提供了太多参数

我试图弄清楚为什么我会收到此错误

FirebaseError:向 Query.startAt() 提供的参数太多。参数的数量必须小于或等于 Query.orderBy() 子句的数量

用这个代码:

const query = firebase
  .getDatabase()
  .collection("users")
  .where("premium", "==", true) // get premium users
  .where("totalPosts", ">", 0); // that have posted some music


...

return query
    .startAt(0)
    .limit(1)
    .get()
    .then((snapshot) => {
          ...
    );
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在尝试吸引发布了一些音乐的高级用户。我使用的是 where 和 startAt 子句,而不是 orderBy。

我究竟做错了什么?

谢谢!

javascript firebase google-cloud-firestore

8
推荐指数
1
解决办法
6370
查看次数

对同一文档的 Firestore batch.set() 是否算作一个文档写入?

如果我在我的代码中这样做

 function setShards(batch, docRef, numShards) {
    batch.set(docRef, { numShards } , { merge: true });
 }

 const batch = firestore.batch();

 batch.set(docRef, {data});
 
 setShards(docRef, 10);

 batch.commit();
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,在执行 .commit() 之前,我正在对同一文档进行批量设置。那么,这算作一个文档写入还是两个文档写入呢?

谢谢。

firebase google-cloud-platform google-cloud-firestore

1
推荐指数
1
解决办法
1262
查看次数