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

Provide an easy way to check whether a cuds object has certain connections #612

Open
yoavnash opened this issue Apr 22, 2021 · 6 comments
Open
Labels
API details 🌱 new feature Solving the issue involves the incorporation of a new feature.

Comments

@yoavnash
Copy link
Member

When a user wants to check if a cuds object is connected to another, then he has to use get or item with an additional condition to make the check. get is also inefficient if it results in bringing cuds objects from the backend that are not used.
Could be useful to have a more intuitive method for this. For example, count with filter options.

@yoavnash
Copy link
Member Author

Related to #418

@pablo-de-andres
Copy link
Member

Do you want to check if two instances are connected, or if one instance is connected to instances of a certain type?

@yoavnash
Copy link
Member Author

For this we have the get_relationships_between method.
I was thinking of something like cuds.is_connected(rel=..., oclass=...)

@pablo-de-andres
Copy link
Member

Then I could rename the issue, since you are not looking for connection to another cuds object specifically
But I agree it would most definitely be useful.

@yoavnash yoavnash changed the title Provide an easy way to check whether two cuds objects are connected Provide an easy way to check whether a cuds object has certain connections Apr 22, 2021
@pablo-de-andres
Copy link
Member

I think some relevant methods would be (naming of the methods as a draft):

cuds_object.is_connected(rel=..., oclass=...)  # Check whether cuds_object is connected given the filters
cuds_object.count_connections(rel=..., oclass=...)  # Count the connections from cuds_object given the filters
cuds_object.get_unique(rel=..., oclass=...)  # Returns one object when only one matches the filters, exception otherwise

@yoavnash
Copy link
Member Author

We may want to add a depth parameter to those functions

@kysrpex kysrpex added 🌱 new feature Solving the issue involves the incorporation of a new feature. and removed 💡 feature request labels Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API details 🌱 new feature Solving the issue involves the incorporation of a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants