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

How to handle optional keys #14

Open
jhnns opened this issue Mar 20, 2014 · 2 comments
Open

How to handle optional keys #14

jhnns opened this issue Mar 20, 2014 · 2 comments
Assignees

Comments

@jhnns
Copy link
Member

jhnns commented Mar 20, 2014

I dont know if this an issue for alamid-schema but how can we handle an update request to delete an optional key. Alamid-schema doesnt know about requests, but maybe there should be a method to apply a diff. Or maybe this should be done by the model?

@jhnns jhnns self-assigned this Mar 20, 2014
@jhnns
Copy link
Member Author

jhnns commented Mar 20, 2014

I think alamid schema should provide a convenient method that applies all keys to another object. And normalize should then strip away all undefined/null Valses that are optional.

This means that optional values cant be null or undefined.

@jhnns
Copy link
Member Author

jhnns commented Mar 21, 2014

Two things to remember in this context:

  • mongoose will remove all properties in the db that have been set to undefined explicitly (not via delete).
  • JSON.stringify() removes all values that are undefined. This means that we can't send explicit undefined values over the wire.

We need to discuss what null, explicit undefined and actual undefined means in the context of alamid-schema.

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

No branches or pull requests

1 participant