I have data set up like this:
Tasks:{
Group 1:{
pushid1:{
date: 18921949021,
title: "Do something"
},
pushid2:{
date: 18921949021,
title: "Do something else"
}
},
Group 2:{
pushid3:{
date: 18921949021,
title: "Do another thing"
}
}
}
I reference it by date so I only get the tasks made after a certain time.
var now = Date.now();
var taskRef = new Firebase(FB + "/tasks/" + thisGroup);
taskRef.orderByChild('date').startAt(now).on("child_added", function(snap){
console.log(snap.val());
});
This all works fine, for each group I get a warning message saying something like this:
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "date" at tasks/Group 1 to your security rules for better performance
How do I add that to my security rules? I can't add one for each group a user makes, is there a wild card entry of some type?
Firebase automatically creates API keys for your project when you do any of the following: Create a Firebase project > Browser key auto-created. Create a Firebase Apple App > iOS key auto-created. Create a Firebase Android App > Android key auto-created.
In Firebase Database everything is a node, that follows the pattern key: value. Firebase Database provides us with a simple way to generate unique keys. Unique keys create new items while uploading data to a previously stored key will update.
Cloud Firestore uses two types of indexes: single-field and composite.
I guess you're looking for:
{ ".read": true, ".write": true, "rules": { "Tasks": { "$groupid": { ".indexOn": "date" } } } }
The Firebase documentation is usually a pretty good read. Spending an hour or less in the security guide, will ensure you have a better understanding of this and many other topics.
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