model call returns query or object - should be standardized ?

29 views
Skip to first unread message

Mike Henke

unread,
Jul 24, 2009, 2:54:35 PM7/24/09
to ColdFusion on Wheels
This might have been discussed before. I haven't had any issues yet
with findall() or findby() when calling a mode but these functions be
standardized and return a structure instead of object.

I am thinking as conventions guy and newbie to CFWheels. Seems odd
since CFWheels is about making our lives easier with conventions and
assumptions.

Just something to think about.

I read about "returnAs" argument on the findAll . Does this do
something like I am suggesting.

http://groups.google.com/group/cfwheels/browse_thread/thread/9dc86536bb434d8c/121ae54b82989ca1?lnk=gst&q=query+object+mode#121ae54b82989ca1

Thanks

Per Djurner

unread,
Jul 24, 2009, 6:21:49 PM7/24/09
to cfwh...@googlegroups.com
The convention is that when you are fetching a single record from the database (using findOne, findByKey etc) you will get an object back.
When you are fetching multiple records you will get a query result set back.
The "returnAs" argument is a way to override this convention (and it will be improved a little more before we release 1.0).

The reasoning behind the convention is that when you are asking the database for multiple records it is likely that you intend to display them (rather than edit/delete them).
In this case objects are overkill (and even more so because of the poor performance of object creation in ColdFusion).

/ Per

Mike Henke

unread,
Jul 24, 2009, 8:27:28 PM7/24/09
to ColdFusion on Wheels
That is very interesting and great reasoning. Thanks for clarifying
that.

On Jul 24, 6:21 pm, Per Djurner <per.djur...@gmail.com> wrote:
> The convention is that when you are fetching a single record from the
> database (using findOne, findByKey etc) you will get an object back.When you
> are fetching multiple records you will get a query result set back.
> The "returnAs" argument is a way to override this convention (and it will be
> improved a little more before we release 1.0).
>
> The reasoning behind the convention is that when you are asking the database
> for multiple records it is likely that you intend to display them (rather
> than edit/delete them).
> In this case objects are overkill (and even more so because of the poor
> performance of object creation in ColdFusion).
>
> / Per
>
> On Fri, Jul 24, 2009 at 8:54 PM, Mike Henke <henkem...@gmail.com> wrote:
>
> > This might have been discussed before.  I haven't had any issues yet
> > with findall() or findby() when calling a mode but these functions be
> > standardized and return a structure instead of object.
>
> > I am thinking as conventions guy and newbie to CFWheels.  Seems odd
> > since CFWheels is about making our lives easier with conventions and
> > assumptions.
>
> > Just something to think about.
>
> > I read about "returnAs" argument on the findAll .  Does this do
> > something like I am suggesting.
>
> >http://groups.google.com/group/cfwheels/browse_thread/thread/9dc86536...
>
> > Thanks

Chris Peters

unread,
Jul 25, 2009, 8:15:01 AM7/25/09
to cfwh...@googlegroups.com
By the way, we understand that it's kind of annoying that we can't return arrays of objects by default. But this is a choice that had to be made in order to use ColdFusion for what it's good at, not just blindly trying to make it match Ruby on Rails line-by-line.
Reply all
Reply to author
Forward
0 new messages