admin管理员组文章数量:1323225
I am trying to figurate why am I getting this error
FirebaseError: Too many arguments provided to Query.startAt(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses
with this code:
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) => {
...
);
As you can see, I am trying to get premium users that have posted some music. I am using the where and startAt clause, and not the orderBy.
What am I doing wrong?
Thanks!
I am trying to figurate why am I getting this error
FirebaseError: Too many arguments provided to Query.startAt(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses
with this code:
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) => {
...
);
As you can see, I am trying to get premium users that have posted some music. I am using the where and startAt clause, and not the orderBy.
What am I doing wrong?
Thanks!
Share Improve this question asked Oct 4, 2020 at 19:33 Conchi BermejoConchi Bermejo 3532 silver badges16 bronze badges1 Answer
Reset to default 8Read the error message carefully:
The number of arguments must be less than or equal to the number of Query.orderBy() clauses
Your code doesn't show any orderBy clauses at all, so the number in this case is 0. But you provide 1 argument to startAt()
. You should actually provide an orderBy clause, to be specific. It must match the field of your range query:
const query = firebase
.getDatabase()
.collection("users")
.where("premium", "==", true) // get premium users
.where("totalPosts", ">", 0) // that have posted some music
.orderBy("totalPosts")
Then, your pagination should repeat the exact same query, only this time with startAt to tell it where to pick up:
return query.startAt(0);
本文标签: javascriptFirebase ErrorToo many arguments provided to QuerystartAt()Stack Overflow
版权声明:本文标题:javascript - Firebase Error - Too many arguments provided to Query.startAt() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742078509a2419552.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论