我在Firebase上有这样的对象列表:
- members
-KkN7J3duEB0Lqz01S7v
|- address: "Chicago Ave, Minneapolis, MN, USA"
|- isDeleted: true
我想查询" isDeleted"是假的,这是我的代码片段:
return this.database.list('/members', {
query: {
limitToLast: (pageNumber * this.pageSize),
equalTo: {
value: false,
key: 'isDeleted'
}
}
})
但是,浏览器控制台会出现此错误:
core.es5.js:1084 ERROR Error: Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).
at Qh (database.js:231)
at U.webpackJsonp../node_modules/firebase/database.js.g.Nd (database.js:240)
at U.webpackJsonp../node_modules/firebase/database.js.g.If (database.js:242)
at MapSubscriber.project (firebase_list_factory.js:31)
at MapSubscriber.webpackJsonp../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:77)
at MapSubscriber.webpackJsonp../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89)
at SafeSubscriber._next (query_observable.js:59)
at SafeSubscriber.webpackJsonp../node_modules/rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.webpackJsonp../node_modules/rxjs/Subscriber.js.SafeSubscriber.next (Subscriber.js:185)
at Subscriber.webpackJsonp../node_modules/rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125)
请指教。谢谢!
答案 0 :(得分:2)
解决方案是:
return this.database.list('/members', {
query: {
orderByChild: 'isDeleted',
equalTo: false,
limitToLast: (pageNumber * this.pageSize)
}
})
答案 1 :(得分:1)
我认为你需要添加orderByChild:' isDeleted'到查询。并确保更新您的数据库规则。