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

feature: Be able to update different attributes and relationships of a node with a dict #272

Open
BeArchiTek opened this issue Feb 12, 2025 · 0 comments
Labels
type/feature New feature or request

Comments

@BeArchiTek
Copy link
Contributor

Component

Python SDK

Describe the Feature Request

Right now, we can provide a dict when we create a new node, as a user I would like to have a similar function to be able to update an existing node.

Describe the Use Case

It will allow to update node in a cleaner manner in integrations

Additional Information

I currently have something like this to do it :

            for attr_name in data:
                if attr_name in tmp_obj._schema.attribute_names:
                    attr_schema = next(attr for attr in tmp_obj._schema.attributes if attr.name == attr_name)
                    attr_data = data.get(attr_name)
                    new_attr = Attribute(name=attr_name, schema=attr_schema, data=attr_data)
                    setattr(tmp_obj, attr_name, new_attr)
                elif attr_name in tmp_obj._schema.relationship_names:
                    rel_schema = next(rel for rel in self._schema.relationships if rel.name == attr_name)
                    rel_data = data.get(attr_name)
                    if rel_schema.cardinality == RelationshipCardinality.ONE:
                        setattr(tmp_obj, f"_{attr_name}", None)
                        setattr(
                            tmp_obj,
                            attr_name,
                            generate_relationship_property(name=attr_name, node=tmp_obj),
                        )
                    elif rel_schema.cardinality == RelationshipCardinality.MANY:
                        setattr(
                            tmp_obj,
                            attr_name,
                            RelationshipManagerSync(
                                name=attr_name,
                                client=tmp_obj._client,
                                node=tmp_obj,
                                branch=tmp_obj._branch,
                                schema=rel_schema,
                                data=rel_data,
                            ),
                        )
@BeArchiTek BeArchiTek added the type/feature New feature or request label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant