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

Add Read.getObjectType #11

Merged
merged 1 commit into from
Jan 11, 2024
Merged

Add Read.getObjectType #11

merged 1 commit into from
Jan 11, 2024

Conversation

alexjg
Copy link
Collaborator

@alexjg alexjg commented Jan 11, 2024

Problem: sometimes you have an object ID but need to know what type of object the ID points at in order to determine what to do with it but there is no way of getting this information from automerge.

Solution: add Read.getObjectType which returns the type of the object ID, or Optional.empty if the object is not in the document.

Fixes #5

Problem: sometimes you have an object ID but need to know what type of
object the ID points at in order to determine what to do with it but
there is no way of getting this information from automerge.

Solution: add Read.getObjectType which returns the type of the object
ID, or `Optional.empty` if the object is not in the document.
@alexjg
Copy link
Collaborator Author

alexjg commented Jan 11, 2024

@eneroth does the API exposed here look useful for you?

@eneroth
Copy link

eneroth commented Jan 11, 2024

Optional returning a type. I think this looks good.

The primary use case I have in mind is to a) conditionally create fields if they are missing, and b) to make assertions about the presence and type of fields, for example in tests. This looks suitable for both.

@alexjg alexjg merged commit 28addf7 into main Jan 11, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

Add a way to get the type of an object from an object ID
2 participants