I am trying to retrieve all the items that have a param with a certain key.
Here is the function that fills an array with the retrieved items:
this.subscription = this.activatedRoute.params.subscribe(
(param: any) => {
let postId = param['id'];
console.log(postId);
this.postsService.subscribePostReplies(postId)
.do(console.log)
.subscribe(posts => { this.posts = posts; this.cdr.detectChanges(); });
});
Here is the method within the service:
subscribePostReplies(postKey: string) {
return this.af.database.list('posts', {
query: {
orderByChild: 'repliedTo',
equalTo: postKey
}
});
}
Problem is the page refreshes when the query happens and I also get alerted with: FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "repliedTo" at /posts to your security rules for better performance
Your warning pretty much spells it out.
WARNING: Using an unspecified index. Consider adding ".indexOn": "repliedTo" at /posts to your security rules for better performance
".indexOn": "repliedTo" @ /posts will looks something like this:
{
"rules": {
".read": true,
".write": true,
"posts": {
".indexOn": "repliedTo"
}
}
}
Remember, this is just a warning and indexOn is not required for development.
Indexes are not required for development unless you are using the REST API. The realtime client libraries can execute ad-hoc queries without specifying indexes. Performance will degrade as the data you query grows, so it is important to add indexes before you launch your app if you anticipate querying a large set of data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With