C2FO / patio

Idiomatic database toolkit

Home Page:http://c2fo.github.io/patio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FeatureRequest: include associations

ebasley opened this issue · comments

Is there a solution to include associations in a query on a model , like with :include within Activerecord in rails ?

Ex :

var A = patio.addModel('a');
var B = patio.addModel(''b').oneToOne(''a');

B.filter({id: [1,2,3,4,5]}).include(['a']).all(function(b){b.a)})

should produce :

select * from b where id in (1,2,3,4,5)
select * from a where b_id in (b_id1, b_id2, b_id3, ...)

eager load is close to the point but will produce many requests (5 here)

Any existing solution or help to dev it ?

thanks for your very good job