Quick ORM with aggregate and group by columns

Hi,

I’m new to quick orm. Have a fairly simple query to get the expected result but reading the results from the return queryBuilder instance would have been a nightmare.

Example: Let say I have a Account (pkid, accountNumber, createDate, createBy, …) table and Spendings(pkid, accountId, amount, …). I have created the entity models for both tables with the associations written.

Now if I run the following:
getInstance(“entity.Spendings”)
.select( [ “accountId” ] )
.selectRaw( [ “sum(amount) as totalSpendings” ] )
.groupBy( [“accountId”] )
.get();

Now I’m expected to get the results in array like:
[ { “accountId”: 100, “totalSpendings”: 2000 }, { “accountId”: 101, “totalSpendings”: 3000 } ]

But I am not able to get the expected results I have tried wirteDump in coldfusion to see the returned results. I can see the expected values under the _data property. But not sure and found no way to grab the results.

Any help or direction would highly be appreciated here. Thanks for your time.

I have found a solution but not sure if it is a hack or solution. Implement a method like:

struct funtion data(){
return variables._data;
}

In the entity and as get() return new collection, iteration on the array and calling arrayItem.data(); will return struct.

Would appreciate views on this one as well please.