dhumphreys / cfrel

ColdFusion Relational Algebra Framework
16 stars 5 forks source link

Add scoped finders to relations #21

Closed dhumphreys closed 13 years ago

dhumphreys commented 13 years ago

Should allow standard finding methods, or at least findByKey on relation objects. This should allow for scoped finding, such as rel.where("createdAt > ?", ["2011-06-01"]).findByKey(433). This method would return a model object, not a relation. This should allow for scoping at the model level. Dynamic finders may be possible at some point.

CFWheels example:

<cfscript>
  // assuming findAll returned as a relation
  model("order").findAll(where="status='complete'").findByKey(424);

  // or using a relation
  model("order").where(status="complete").findByKey(424);

  // or with some sort of named scope plugin
  model("order").completed().findByKey(424);

  // assuming association is returned as a relation
  model("user").orders().findByKey(435);
</cfscript>