CSFrequency / react-firebase-hooks

React Hooks for Firebase.
Apache License 2.0
3.55k stars 304 forks source link

Sorting and Filtering in Realtime Database #235

Closed ThibaudMZN closed 2 years ago

ThibaudMZN commented 2 years ago

Hi !

Is there a way to use sorting and filtering in Realtime Database Hooks (useList for example), functions like orderByChild() or limitToFirst() ?

Thanks !

rayoverweij commented 2 years ago

Use query() like you would in a vanilla call to Firebase, i.e. instead of

useList(ref(database, 'list'));

something like

useList(query(ref(database, 'list'), orderByChild('someChild')));

ThibaudMZN commented 2 years ago

Ah that wasn't so hard ! Thanks, maybe that could be somewhere in the docs :)