Skip to content

Conversation

@kuldeepaggarwal
Copy link

Added some lazy loading for ActiveRecord and Mongoid through find_collection method.

@josevalim
Copy link
Contributor

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?

@kuldeepaggarwal
Copy link
Author

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.

@ianwhite
Copy link
Owner

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.

@ianwhite
Copy link
Owner

After writing the above, I remembered that limit/offset is already in #find_all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants