C2FO / patio

Idiomatic database toolkit

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filter Association

ebasley opened this issue · comments

we can define a filter witin an association at definition time like :

patio.addModel("father").oneToMany("children", {query : {age : {gt : 10}}})

but how can we do it when we use it, ex:

var Father = patio.addModel("father").oneToMany("children")
Father.first().then(function(f){
f.children.filter( {age : {gt : 10} }).then ....
});

this means association call should be able to return a query rather than a promise

Every association added to a model will have a {{associationName}}Dataset property added to it.

   f.childrenDataset.filter({age : {gt : 10}}).then()

Hope this helps!