-
Notifications
You must be signed in to change notification settings - Fork 75
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
Not possible to delete a child state object #179
Comments
Hi there, any idea about how to remove a child from an object? |
Hi there, any thoughts about this issue? |
Sorry for the late response. You cannot unset a child as it's not a property, but an instance that belongs to the parent. and you could also try: If nothing works, could you add a failing test as a PR so that we may work a solution out? I feel that allowing to unset or empty a child should be allowed someway. |
@e2jk Did my comment help you solve your problem? |
Assume an object's model defined as such:
After an object has been saved with a child, at some point I want to remove that child. I would assume
model.unset
should do the job, but it results in an error (see below).I have tried various strategies, none of which were succesful. What is the proper way to delete/remove a child item from a state object?
These were my intents, and the error message/code location where it failed:
Starting with the one I assumed would work (but apparently only works for actual properties and not children):
Results in
TypeError: def is undefined
at theif (def.required)
line in theunset
function, sincethis._definition
only hold the real properties and not the children (is that on purpose?)Then trying to replicate what the
unset
function does when a property is not required (but without using theassign
part because I was too lazy to figure out how torequire
lodash properly):That one doens't log any error, but going to that object's page (and properly refreshing) the child is still defined on the object.
Just trying to delete the object's property:
Results in
TypeError: this[key] is undefined
at the third line in theserialize
function:Another intent:
Results in
TypeError: this[key].serialize is not a function
on the same line as the previous error.Last intent:
Results in the same error as the previous intent.
The text was updated successfully, but these errors were encountered: