I want to get all users from a Firebase realtime database and sort them by a score property. I've got this to work using the variable
users: FirebaseListObservable<any[]>;
but I get the errors:
Type 'Observable<any[]>' is not assignable to type 'FirebaseListObservable<any[]>'.
Property '_ref' is missing in type 'Observable<any[]>'.
If I change the variable to
users: Observable<any[]>;
then the errors go away, but then I can't use the Angularfire methods like .push()
and .update()
.
My fetching and sorting code (which works) looks like:
this.users = this.af.database.list('/users')
.map(items => items.sort((a, b) => b.score - a.score));
I would appreciate any advice on how this should be done to avoid the errors, or any preferred way, thank you!