Skip to content

Provide a way to force a refresh of the cached ToOne target #1002

Open
@NeoSkye

Description

@NeoSkye

When the target entity of a ToOne relationship is changed after it's resolved and cached, there is no way to force the target to refresh from the database.

Describe the solution you'd like
Provide a function that can be called that forces a new "get" from the box, caches the new entity, and returns it. This can be used when the app knows that the entity has been updated but wants those changes reflected in the related object.

Describe alternatives you've considered
As a workaround/alternative, the app can find the correct box, get an updated entity using the getTargetId(), then set the ToOne target entity to the updated entity. This works but requires a lot of extra code for something it feels like objectbox should be able to handle (especially since the ToOne relationship already knows the correct box for the get operation).

Additional context
Currently using this on Kotlin/Android.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions