orm_adapter
orm_adapter copied to clipboard
Added find_collection in Base class
Added some lazy loading for ActiveRecord and Mongoid through find_collection method.
Thanks @kuldeepaggarwal. I find this troubling because the returned result changes per adapter, as each implementation is going to return a different proxy that returns to different methods. Can you provide some use cases of why you need something like find_collection
?
I am working on an application which uses Ckeditor to render lot of assets on a page. Internally, Ckeditor is using "#find_all" method of orm_adapter/activerecord which fetches all records at once. So I need a way to paginate on the large no. of assets and preferably the Database one. And i think it would be helpful to add a method like find_collection which will support pagination and scope chaining.
I can try other alternatives for the same.
Hi Kuldeep, José
To me it seems that pagination and chaining are two very different concerns.
Adding pagination (limit/offset) would be a consistent addition to #find_all IMO.
Ideally, chaining should be implemented as a orm_adapter class by itself, that is adapter agnostic, and which translates the chain scope into orm_adapter/base methods. That way any orm_adapter conforming to the base interface can use the lazy/chained interface. I realise this is a pretty heavyweight option though.
Cheers, Ian
On 30 Sep 2013, at 12:52, Kuldeep Aggarwal [email protected] wrote:
I am working on an application which uses Ckeditor to render lot of assets on a page. Internally, Ckeditor is using "#find_all" method of orm_adapter/activerecord which fetches all records at once. So I need a way to paginate on the large no. of assets and preferably the Database one. And i think it would be helpful to add a method like find_collection which will support pagination and scope chaining.
I can try other alternatives for the same.
— Reply to this email directly or view it on GitHub.
After writing the above, I remembered that limit/offset is already in #find_all.