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
merged 2 commits into from
Sep 12, 2019
Merged

Conversation

ricardograca
Copy link
Member

Introduction

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.

Motivation

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.

@fl0w
Copy link
Collaborator

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.

@ricardograca
Copy link
Member Author

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

Copy link
Collaborator

@fl0w fl0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ricardograca ricardograca merged commit 681c262 into master Sep 12, 2019
@ricardograca ricardograca deleted the rg-collection-docs branch September 12, 2019 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Understanding custom collections
2 participants