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 badges1 Answer
Reset to default 24You 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)