-
Notifications
You must be signed in to change notification settings - Fork 568
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
Parse() not applying to fetchAll. Only seems to work with fetch(). #962
Comments
Why aren't you defining |
So I can stay DRY. I'm simply following the recommendation from this issue: If that's the problem, why does it work when doing fetch(), but not fetchAll()? |
You seem to be causing some chaos with that approach and it's not exactly what it says on the issue you linked to. If you want to have a base model from which all others inherit from, take a closer look at what the example is actually doing. It's nothing like what you have here. Also, you need the registry plugin, so make sure it's being loaded before doing anything else. Tip: right click on the date link on a comment to get a link to the actual comment. |
I'm not extending the model as a plugin--I'm just including it in my bookshelf.js config file and exporting bookshelf. So the Model class is already extended before anything actually uses it. I don't see the difference between doing this and doing it as a plugin...am I incorrect in that thought? If so, how? Again, the parse method works fine with .fetch(), so the extended Model appears to be replicating properly. It just fails with fetchAll(). What can explain this? Can you be more specific into what you think is wrong with my implementation? |
I don't know since I'm not seeing you're entire code, and I'm not that knowledgeable in how Bookshelf works internally, but you're approach doesn't seem right. My guess is that |
If that's the case, I wouldn't expect it to work at all. But it works for fetch() just fine... |
So I did it the way the docs recommended by moving my extension of the Model class to a separate file and registering it as a plugin. Exact same behavior. |
That wasn't the problem. The problem was setting |
Haha yeah, I went ahead and did that before your comment just now. That resolved it. Thanks for your help! |
No problem. Now we know that |
So when I run a .fetch({id: x}), the result has the columns in the camelCase I want. But when I do a fetchAll, they are in snake_case.
Here's my extension of the Model class:
Is this supposed to work with fetchAll too, or is it meant to ignore fetchAll? Any suggestions on how to work around this or extend the Model class so it works?
The text was updated successfully, but these errors were encountered: