dchester / epilogue

Create flexible REST endpoints and controllers from Sequelize models in your Express app
846 stars 116 forks source link

Is there a better way to set a null value? #185

Closed richmarr closed 7 years ago

richmarr commented 8 years ago

Great library, thanks for contributing everybody.

I've got some UI that's updating an integer value via epilogue and I'm looking for the idiomatic way to set the value back to null again if the user wants to revert their change, any suggestions? Do I need to use a create.write.before() hook?

mbroadst commented 8 years ago

@richmarr what do you mean if the "user wants to revert their change"? If you mean that from the perspective of a user interaction (e.g. a form where they want to change what they've just done) then that's a separate REST request. If you want to somehow force reversing a change, yes you would probably use milestones to alter the default behavior

richmarr commented 8 years ago

Thanks. Sorry I think mentioning reverting a change was a red herring. That's a likely use case but it occurs over two separate interections.

The core question is how I can set a null value. Sending PUT param=null or PUT param=undefined doesn't seem to have any special case logic

I can add my own special case using a milestone, but setting a null value seems like a more generic problem so I thought I'd ask if there was a more idiomatic approach.

On Monday, 1 August 2016, Matt Broadstone notifications@github.com wrote:

@richmarr https://github.com/richmarr what do you mean if the "user wants to revert their change"? If you mean that from the perspective of a user interaction (e.g. a form where they want to change what they've just done) then that's a separate REST request. If you want to somehow force reversing a change, yes you would probably use milestones to alter the default behavior

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dchester/epilogue/issues/185#issuecomment-236574232, or mute the thread https://github.com/notifications/unsubscribe-auth/AASabZcL4CKeImP8jlDOJu-Bl0KQz9elks5qbe57gaJpZM4JZa49 .

Richard Marr

mbroadst commented 8 years ago

@richmarr ah that does seem like there is a potential for bugs there, at least from my original use cases (and I'm sure the tests), sending data that might have nulls in it was generally done via a JSON request body. Perhaps you could put together a test case showing that passing null for the value in the query string is causing unexpected behavior and we could move forward from there?

richmarr commented 7 years ago

Just revisiting this bug, and using a JSON request body actually seems to work fine for my use case. I'll close this bug, but obviously feel free to re-open if you see value in it. Thanks for your help.