Keyword query and date order

I have a database with a lot of "lists" structured like this:

Listings

I want to get 10 lists starting or ending with a certain priority value, with the size of the value (child node) in the range from 9 to 10.5 and ordering the result by date.

I looked through a lot of SO posts and Firebase examples, but I can't seem to find any solution.

Is it really impossible in Firebase? As far as I know, this is a fairly common use case.

Is there any solution to this? If not, how would you get around this?

+9
source share
1 answer

You can view complex queries in the Firebase documentation.

Look at the range of queries. startAt() and endAt() allow you to search for shoes of a certain size by setting start and end points for your queries.

For example, if we want to find all shoes between 9 and 10.5 , combine orderByChild() , startAt and endAt . Sort of:

 var ref = new Firebase(URL); ref.orderByChild("timestamp").startAt("9").endAt("10.5").on("child_added", function(snapshot) { console.log(snapshot.key()); }); 

If you could provide sample code, then it would be easier to pinpoint the solution. You may need to tweak the data model if you want to sort a query by multiple keys.

+6
source

Source: https://habr.com/ru/post/983456/


All Articles