Unspecified Index When Searching Data With Firebase Cloud Function On Nested Object Running Nested Query
Solution 1:
You are getting the wrong reference for reading the user. You need to do the following to get correct reference: snap.ref.parent.parent.parent
(ref now will be at /users). You query is trying to read the users node under following.
The warning is that you need to write the firebase rule which enables the indexing based on userId, otherwise the operation will be bandwidth expensive.
here is the rule which will add indexing:
"users": {
"$uid" : {
".indexOn" : ["userId"]
}
}
Here is the resource for more information on Database rules : https://firebase.google.com/docs/database/security/
This is a simple tool by firebase to write rules easily: https://github.com/firebase/bolt
P.S: you are returning two promises your last promise for sending notification will not work. Nest or chain it with the firebase query. Also make your query single value event with changing on('child_changed')
to once('value')
.
Post a Comment for "Unspecified Index When Searching Data With Firebase Cloud Function On Nested Object Running Nested Query"