Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example of how to use custom collections #2015

merged 2 commits into from Sep 12, 2019


Copy link

@ricardograca ricardograca commented Sep 10, 2019


Document how to use a custom collection for the results of every call to .fetchAll(). This includes calls to .fetchPage() and .related() as well, in case the relation is a one to many. Basically any time a new collection of the Model is created.


Collections are a bit hard to understand. This should help users that want to attach custom behavior to the collections associated with a certain model.

Currently a new anonymous collection is created when trying to compose the results of a .fetchAll(), but it's sometimes useful to add extra behavior to this collection in a predictable way.

Fixes #1466.

Copy link

@fl0w fl0w commented Sep 10, 2019

Let me know if you need anything, I feel pretty versed at this point regarding collections and the inner workings of bookshelf.

Copy link
Member Author

@ricardograca ricardograca commented Sep 11, 2019

Thanks. Can you take a look at the changes here and see if the new documentation is good enough?

fl0w approved these changes Sep 11, 2019
Copy link

@fl0w fl0w left a comment

Nice! This looks good IMO. Small addition if it's to taste.
I haven't tried master with registry promoted to core yet though.

lib/collection.js Show resolved Hide resolved
@ricardograca ricardograca merged commit 681c262 into master Sep 12, 2019
2 checks passed
@ricardograca ricardograca deleted the rg-collection-docs branch Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants