Can I Orderbychildren Or Orderbyvalue Substracting 1 Child To Another? (or Any Other Mean To Use A Computed Var)
Is there a way to do this ? Or with oderByValue ? Any other mean ? fb.orderByChild('upvotes - downvotes').startAt(_start).endAt(_end).limitToLast(_n).on('child_added', function
Solution 1:
No, orderByChild
does exactly what its name says. Currently, there is no way to define such "computed" nodes neither in the data model, nor in query criteria.
Therefore, you should store the difference directly in the database, set an index on it using security rules, and use that for your query. Updating the vote counts with a transaction should help a lot to implement it in a clean way.
Post a Comment for "Can I Orderbychildren Or Orderbyvalue Substracting 1 Child To Another? (or Any Other Mean To Use A Computed Var)"