-
Notifications
You must be signed in to change notification settings - Fork 13
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
Is there a correct way to remove node/relationship properties? #93
Comments
#80 seems to be relevant here. Adding support for |
@themetalfleece do you have some sort of plan for implementing this? If you could provide some sort of spec on how you imagine this might be implemented, I would gladly create a PR. I imagine something like another property on the second update: (data: Partial<Properties>, params?: GenericConfiguration & {
where?: WhereParamsI;
/** defaults to false. Whether to return the properties of the nodes after the update. If it's false, the first entry of the return value of this function will be an empty array */
return?: boolean;
removeProperties?: string[]; // This is new!
}) => Promise<[Instance[], QueryResult]>; Even better if there's some type checking where the This, however, does not provide a way to remove properties from an instance. That could be fixed by creating a new instance method We could just lean on the fact that |
Hey, thanks for offering to create a PR for this! I was thinking that we could add an operator, which would be used like this: user.update({
name: 'Bob',
age: { [Op.remove]: true }
}); What do you think of this? :) I'm also ok with adding proper support for |
I wouldn't have guessed that we can use the operators like that, but that looks even better than my proposal! |
Cheers! Right now the operators are used for "Where" only (for finding), but we can definitely use them (or a new set of operators) for setting/updating values. |
Neo4j does not support
null
as a property value. This also means that the union typeNeo4jSupportedProperties
does not containnull
. However, the model validator acceptsnull
and model TypeScript definitions can be set toproperty?: null | type
.This mostly works and successfully removes the property, excluding some weird edge cases. For example, if the revalidator schema is set to
'type'
instead of['null', 'type']
, then updating the object using the model static will work fine, however, updating usinginstance.property = value
andinstance.save()
will cause a validation error.If this is the intended usage, it would be nice to specify this in the docs and maybe add
null
toNeo4jSupportedProperties
to avoid some TypeScript weirdness when using Neogma TS generics. If not, then it might be useful to add some kind of specific property removing mechanism to modifying methods.The text was updated successfully, but these errors were encountered: