I have many Telegram Keyboards in my Firebase, and I Want to Have an Advance Dictionery Search for Childs of Keyboards
, I Mean in Secend Level Deep, that the user entered,
Forexample user entered rock
, I want to get each Keyboards contain rock at the begin or middle or at the end, in This Example I have 3 Keyboards: morning
, rock
and rocky
.
const ref = db.ref('Keyboards/rock'); //keyboard 1
const ref = db.ref('Keyboards/morning'); //keyboard 2
const ref = db.ref('Keyboards/rocky'); //keyboard 3
How Can I get and console.log
: rock
and rocky
when user typed rock
?
My Problem 90% Solved By @rymdmaskin But Advance Dictionery Search Still is Open.
equalTo
and startAt
and endAt
Not Work, I need Something like contain
, Someone Said to use Elastic Search (https://firebase.googleblog.com/2014/01/queries-part-2-advanced-searches-with.html)
Rules:
{
"rules": {
".read": true,
".write": true,
"Keyboards" : {
".indexOn": "Keyboards"
}
}
}
Code:
const ref = db.ref('/');
ref.child('/').orderByChild('Keyboards').equalTo('rock').on("value", function(snapshot) {
console.log(snapshot.val());
key = snapshot.forEach(function(data) {
console.log(data.key);
});
});