I am using the latest version of Coldbox ORM. I am trying to build a query using the restrictions functionality. The problem is how do you create a restrictions query when you want to query on one of the fields that is a relationship?
var r = ormService.getRestrictions();
prc.customers = ormService.newCriteria("Customer").and( r.eq("City","#prc.customerSearch.getCity()#")
).list();
The above works just fine as “City” is a string property on the Customer model object. I have another property that is a relationship (i.e. points to another CFC). How can I use that type of relationship field in a restrictions style query if that makes sense?
Ideal psuedo code would look like:
var r = ormService.getRestrictions();
prc.customers = ormService.newCriteria(“Customer”).and( r.eq("#getProject().getProjectTitle()","#prc.customerSearch.getKeywords()#")
).list();
“project” being a relationship property (one-to-one fieldtype) on the Customer model object.