Skip to content

Commit 6affdfe

Browse files
committed
Merge branch 'master' into version-1.2.0-dev
2 parents 12eb538 + 9b5bd1d commit 6affdfe

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

database/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ recycler.setAdapter(mAdapter);
284284
Like before, we get a custom RecyclerView populated with data from Firebase by setting the properties to the correct fields.
285285

286286
## Using FirebaseUI with indexed data
287+
287288
If your data is [properly indexed](https://firebase.google.com/docs/database/android/structure-data#best_practices_for_data_structure), change your adapter initalization like so:
288289

289290
For a `RecyclerView`, use `FirebaseIndexRecyclerAdapter` instead of `FirebaseRecyclerAdapter`:
@@ -301,3 +302,30 @@ new FirebaseIndexListAdapter<Chat>(this, Chat.class, android.R.layout.two_line_l
301302
```
302303

303304
`keyRef` is the location of your keys, and `dataRef` is the location of your data.
305+
306+
### A note on ordering
307+
308+
The order in which your receive your data depends on the order from `keyRef`, not `dataRef`:
309+
```javascript
310+
{
311+
"data": {
312+
// This order doesn't matter, the order is taken from keys/(user1 or user2).
313+
"3": true,
314+
"1": "some data",
315+
"2": 5
316+
},
317+
"keys": {
318+
// These two users have different orders for their data thanks to key side ordering.
319+
"user1": {
320+
"1": true,
321+
"2": true,
322+
"3": true
323+
},
324+
"user2": {
325+
"3": true,
326+
"2": true,
327+
"1": true
328+
}
329+
}
330+
}
331+
```

0 commit comments

Comments
 (0)