Merging data after select

I have the following situation:

table foo has some basic meta info.
table bar is of the form “field” => “value” and is intended to display custom data. It contains foo_id from table foo. Foo has many bars.

I would like to select foo, but add results of bar into the record.

$conn->render_table(‘foo’, ‘foo_id’,…);
#then maybe create another connector $opt
$opt->render_table(‘bar’, ‘bar_id’, ‘foo_id,name,value’);
#now attach event
$opt->attach(‘beforeRender’, ‘merge_options_in’);

function merge_options_in($item){
# get the right item from $opt
$bar = $opt->some_api_call($item->id); #or something
$item->set($bar->get(‘name’), $bar->get(‘value’));

What is the proper code for the above?

Unfortunately there is no way to use connectors with tables linked in such way.
Till the next week we will release update for the connectors, which will add ability to load data from raw data arrays, so you will be able to use any custom code to fetch data from db, and provide the pre-build array of data objects for connector.