I am working on a ReactJS web app and it's my first time with it and a NoSQL DB. How can I make a query containing an 'and' and comparing timestamps. An example to the kind of query I need is this: select 'start', 'end' from 'subscriptions' where ('end' between '2020-02-01 00:00' and '2020-03-01 00:00') and 'barcode' = '2803'
.
I have multiple situations in my app where I need to retrieve only certain artibutes and have multiple conditions and I couldn't find anywhere how to do it. I also need to parse the auth token in the request and because of that I gave up the firebase.database()
web approach.
Thank you!
Asked
Active
Viewed 14 times
0

Doug Stevenson
- 297,357
- 32
- 422
- 441

Antoniu Fic
- 39
- 1
- 3
-
Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. In your case that could be a property like `"barcode-end": "2803_2020-02-01 00:00"`. For an example of this and other approaches, see my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase. – Frank van Puffelen Feb 13 '20 at 17:56
-
I'd also recommend watching [Firebase for SQL developers](https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s), and reading [NoSQL data modeling](https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/) as trying to map from SQL to NoSQL like this is not ideal. – Frank van Puffelen Feb 13 '20 at 17:57
-
Finally: Realtime Database always returns complete nodes. it is not possible to just get some properties from each node. – Frank van Puffelen Feb 13 '20 at 17:58
-
Also posted on https://www.reddit.com/r/Firebase/comments/f3drzm/rest_api_and_in_query/ – Frank van Puffelen Feb 14 '20 at 04:29