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
Permitted require option for edit, destroy, findOne #9948
Conversation
Yo @kirrg001 I assigned you to this because i'm not 100% this isn't gonna have bad repercussions for the v0.1 api? |
@allouis Could you share why it's hard? And what the use case is? :) |
// in a controller object for new api
query(data, options) {
return SomeModel.destroy(Object.assign({id: data.id}, options}))
} If you DELETE with a non existent id and this runs, you will encounter an error here (Cannot read property destroy of undefined) : https://github.com/TryGhost/Ghost/blob/master/core/server/models/base/index.js#L828 So we look at how posts does it, posts sets the required property to true https://github.com/TryGhost/Ghost/blob/master/core/server/api/v0.1/posts.js#L247 So we change query to: // in a controller object for new api
query(data, options) {
return SomeModel.destroy(Object.assign({id: data.id, require: true}, options}))
} But still doesn't work because it's not a permitted option. We could just add it in the ApiKey model - but it doesn't not seem correct behaviour, it seems to me that destroy should never give an error like cannot read property of undefined |
Other options instead of this:
|
Can't we just force |
Yeah I can do that 👍 |
no-issue With the new framework it is hard to handle 404 errors outside of the serialization layer, this is because we cannot force destroy, edit or findOne to error if the model is missing. This lets us do that.
I've added support for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks klitzeklein
🔸 |
no-issue
With the new framework it is hard to handle 404 errors outside of the
serialization layer, this is because we cannot force deestroy or edit
to error if the model is missing. This lets us do that.