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

Fetching a model by id when model is dynamic #13

Open
sabymike opened this issue Oct 15, 2014 · 2 comments
Open

Fetching a model by id when model is dynamic #13

sabymike opened this issue Oct 15, 2014 · 2 comments
Labels

Comments

@sabymike
Copy link

I have a particular collection that has a function for determining which model should be created instead of a model object as described in the documentation. However, I've run into an issue when fetchById is called for a model in that collection.

In the ampersand-collection-rest-mixins.js method fetchById() the line:

idObj[this.model.prototype.idAttribute] = id;

seems to assume that the model property will not be a generic function but instead some type of Ampersand-Model object. Has anyone run into this use case and if so what did they do to solve it?

@brianberlin
Copy link

I believe you are looking for ampersand-registry which allows you to lookup a model by type and id.

@bear bear added the question label Nov 1, 2014
@bernharduw
Copy link

I ran into the same problem (AmpersandJS/ampersand-collection-rest-mixin#14). I think the best workaround will be to use the collection's mainIndex as a fallback in this line. I will issue a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants