firebase^2.2.9
Firebase node looks like that:
{
articles: {
"-KcNAv56MZQAr8a_kJYh": {
topic: 'a',
text: 'lorem...'
},
"-KcNAv5Dd33KE2qfWVFa": {
topic: 'a',
text: 'lorem...'
},
"-KcNAv5IjjTnmXBCeGFi": {
topic: 'b',
text: 'lorem...'
},
}
}
Keys generated by firebase push
command.
I want to retrieve last (chronologically) 20 articles with topic "a". And then paginate.
firebase.root.child('articles')
.orderByChild('topic')
.equalTo('a')
.startAt(offset)
.limitToLast(20)
.once('value', snapshot => {...})
There is no way to order by two params (topic
and key
), so i assume i need to create an index in firebase control panel, which will order articles by topic
and by key
. So, how do i make it to be ordered by key
?
{
"rules": {
"articles": {
".indexOn": ["topic", ???]
}
}
}