Skip to content

Firebase Advanced Dictionary Search #229

@saeedhei

Description

@saeedhei

I Know here is not good place to ask this question, but this is a pro question and I asked from Stackoverflow too , But someone Said: I can't do this with Firebase, I just want to know is there any way to solve this problem with Firebase?

I have many Telegram Keyboards in my Firebase, and I Want to Search Childs of Keyboards that the user entered,
Forexample user entered rock, I want to get each Keyboards contain rock, 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? (only with this Data Structure).

Structure:
jsonn

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);
    });
});

I have problem with my code and rules.
I Started a +100 bounty in Stackoverflow too: Link

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions