最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Firebase, query with "a child exists" as a condition? - Stack Overflow

programmeradmin5浏览0评论

I have a database like this (photo attached): Trip has BIDS, and awardedBid. I use awardedBid!=null as a way to determine the trip is still available for bidding. However, I don't know how to query for that condition, so I have to hack by creating another field bidDone so I can use .equalTo, like this

mRootReference.child(CHILD_TRIPS).child(mTripKey).orderByChild(BID_DONE).equalTo(true)

However I feel that's unsafe when I have to use 2 keys to denote just one thing since it's bug-prone (I did create one myself in the attached screenshot where bidDone = false where it should be true).

Is there any cleaner way for that task: query with condition that a string exist?

Thanks

I have a database like this (photo attached): Trip has BIDS, and awardedBid. I use awardedBid!=null as a way to determine the trip is still available for bidding. However, I don't know how to query for that condition, so I have to hack by creating another field bidDone so I can use .equalTo, like this

mRootReference.child(CHILD_TRIPS).child(mTripKey).orderByChild(BID_DONE).equalTo(true)

However I feel that's unsafe when I have to use 2 keys to denote just one thing since it's bug-prone (I did create one myself in the attached screenshot where bidDone = false where it should be true).

Is there any cleaner way for that task: query with condition that a string exist?

Thanks

Share Improve this question edited Jul 19, 2016 at 19:01 Frank van Puffelen 599k85 gold badges888 silver badges858 bronze badges asked Jul 18, 2016 at 15:39 EyeQ TechEyeQ Tech 7,35819 gold badges75 silver badges129 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 24

You can remove your attribute bidDone and using startAt() to get all the child having awardedBid not null:

ref.orderByChild("awardedBid").startAt("")

or this to get only the child without bid

ref.orderByChild("awardedBid").endAt(null)
发布评论

评论列表(0)

  1. 暂无评论