Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
144
rated 0 times [  151] [ 7]  / answers: 1 / hits: 19004  / 9 Years ago, mon, october 19, 2015, 12:00:00

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?


More From » firebase

 Answers
15

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.


[#64690] Thursday, October 15, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lucianod

Total Points: 667
Total Questions: 106
Total Answers: 92

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
lucianod questions
;