firebase/reactfire — pull request #20 by OlavHN (2014-10-21 20:35:02+00:00)
Title: Suggetion: Add bind methods with "foreign keys"

Hi!

I love the simplicity of reactfire. In fact I've tried to use react with firebase as a replacement for the whole react flux thing a couple of times, but I end up lacking this one feature.

A very normal pattern for firebase apps is flattening the structure and creating per user indexes of what data to sync. That doesn't map very well to reactfire.

I would like to see something like this:

this.bindForeignAsObject(refToMyListOfObjects, refToAllObjects, 'myObjects')

e.g.:

var friendsRef = ref.child('users').child(uid).child('friends')
var usersRef = ref.child('users')
this.bindForeignAsObject(friendsRef, usersRef, 'friends')

and then have state.myObjects have all objects in refToAllObjects that are also in refToMyListOfObjects synced. I've attached a proof of concept. Would be happy to make it prettier if it makes sense.