Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
127 views
in Technique[技术] by (71.8m points)

javascript - Query Firebase Database with two between conditions

I'm wondering if it's possible to return a list of values from my Firebase database where each element satisfies two conditions.

For example, if my database looked like this:

MYAPP
|_______________items
|                   |_____OshwYF72Jhd9bUw56W7d
|                   |                   |
|                   |                   |__item_name:"plank_5"
|                   |                   |__length:"120"            
|                   |                   |__width:"50"             
|                   |                            
|                   |_____KbHy4293dYgVtT9pdoW
|                   |_____PS8tgw53SnO892Jhweh
|                   |_____Gicuwy8r23ndoijdakr
|
|___customers

And I want to query the database for the item_name of every item that has a length of between 100-150 and a width of between 30-70, is there a way for me to do this with a Firebase query?

I've read the answers here: Query based on multiple where clauses in firebase but that doesn't deal with multiple between/range clauses, which is what I would need in the above scenario.

I saw this plugin in another answer: https://github.com/davideast/Querybase but the where clause doesn't seem to take a range of values. For example:

const queriedDbRef = querybaseRef
  .where({
    length: (between 100-150),
    width: (between 30-70)
  });

Is such a query even possible? Or will I have to get all items matching one condition, and then apply the second condition client-side, using Javascript?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...