Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I query and filter Firebase Realtime Database [duplicate]

I would like to get all persons from the database where first name and last name is given by user input.

So far this is my code:

admin.database().ref('persons').orderByChild('Firstname').equalTo(firstName).limitToLast(1).once("value").then(function(snapshot) {
}

This code works filtering only Firstname, but I cant find any way of adding another Where Clause for Last name. I tried to add another orderBy but it does not seem working. Does the Realtime Database has to be this hard to make a simple query?

like image 205
Mizlul Avatar asked Dec 30 '17 20:12

Mizlul


People also ask

How do you filter data in Firebase Realtime Database?

We can filter data in one of three ways: by child key, by key, or by value. A query starts with one of these parameters, and then must be combined with one or more of the following parameters: startAt , endAt , limitToFirst , limitToLast , or equalTo .

Can we use SQL queries in Firebase?

FireSQL is a library built on top of the official Firebase SDK that allows you to query Cloud Firestore using SQL syntax. It's smart enough to issue the minimum amount of queries necessary to the Firestore servers in order to get the data that you request.

How do I check my Firebase Realtime Database?

To see your current Realtime Database connections and data usage, check the Usage tab in the Firebase console. You can check usage over the current billing period, the last 30 days, or the last 24 hours.


1 Answers

The short answer: you can't. The long answer: use Google's new Firestore database or perform the filtering on the client manually. See this answer for other options.

like image 80
SUPERCILEX Avatar answered Sep 20 '22 22:09

SUPERCILEX