firebase-search | Index your Firebase collections to Elasticsearch and/or | Authentication library
kandi X-RAY | firebase-search Summary
kandi X-RAY | firebase-search Summary
Index your Firebase collections to Elasticsearch and/or Algolia
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Build a new Firebase search .
- Add new data to the added child of the batch .
- Wraps a log ref to a logger
- Handle added updates .
firebase-search Key Features
firebase-search Examples and Code Snippets
Community Discussions
Trending Discussions on firebase-search
QUESTION
I have looked at a couple of StackOverflow posts on how to get a data value by equating a child value that is few nodes deep.
In Firebase Database - How to perform a prefix wildcard query the structure of database is:
and the query ref.child("user_id").orderByChild("name").equalTo("objective-c")
works in pulling out child with particular uid.
In Firebase search by child value, the database structure is:
and the query ref.child('users').orderByChild('name').equalTo('John Doe')
is able to pull out the appropriate child.
In both these cases, the sorting and equating is on the grandchild. In my case, however, the database structure is a bit different. I want to index by a child property that is a few layers deep. The structure is:
So I tried running the following query: authenticatedUsersReference.queryOrdered(byChild: fcmTokenKey).queryEqual(toValue: fcmToken).observeSingleEvent(of: .value)
, and my snapshot returned nil
. But when I ran authenticatedUsersReference.queryOrdered(byChild: fcmTokenKey).observe(.value)
, I saw that the snapshot values were ordered by the fcmTokens. authenticatedUsersReference
points to Database.database().reference().child("people/authenticated")
. I have also updated my rules to do indexing on the server side. As far as I can tell the concept should remain the same even if the depth changes, so what am I missing that is causing my query to return nil
?
ANSWER
Answered 2021-Feb-04 at 14:05You're defining an index on $userName
for fcmToken
. This allows you to query a specific $userName
node for its fcmToken
property.
But your code instead queries across all users for their fcmToken
property, for which no index exists. So the first fix is that you'll need to define the index on the location you want to query, so on authenticated
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install firebase-search
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page