[Coldbox 6.x] CBORM - Restrictions Query and Relationships

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()#")

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()#")

“project” being a relationship property (one-to-one fieldtype) on the Customer model object.

@West Relationships are navigated the same way you navigate in HQL, using . dot notation. You can navigate many-to-one very easily without a need to use a join syntax in the relationships. However, if you have other relationships you will have to use the joinTo() or createAlias() methods Associations - ColdBox ORM Module

In yoru example you have a 1-1 so you can do something like this:

	.isEq( "city", prc.customerSearch.getCity() )
	.isEq( "project.projectTitle", prc.customerSearch.getKeywords() )

Thanks for the help and the link to the associations info @lmajano . I ended up needing to use the “joinTo” syntax as the relationship was not many-to-one. It worked well, thank you for showing me something new.