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

Ability to pass ID to Box creation #680

Open
1 task done
gryznar opened this issue Oct 13, 2024 · 3 comments
Open
1 task done

Ability to pass ID to Box creation #680

gryznar opened this issue Oct 13, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@gryznar
Copy link

gryznar commented Oct 13, 2024

Is there an existing issue?

Use case

I have one entity used for dynamically created data categories. Each of these categories is independent and handled by a separate isolate.

Proposed solution

Allow an optional identifier to be passed to the Box object when it is created:

final fooBox = store.box<CommonEntity>(id: 'foo')
final barBox = store.box<CommonEntity>(id: 'bar')

Describe alternatives you've considered

  1. One Box for all categories. This has few big downsides:

    • concurrent access via separate Isolates (or threads in future Dart version) is not efficient and performant due to need of lock mechanism / transactions
    • data size is larger (every entry would have to have an additional parameter, assigning it to a separate category)
    • accessing data from single category unnecessary complicates the query (this additional param have to be included).
      This also slows down read, because whole data from different categories is kept in one place
  2. Separate store for each category. This is overkill to have one store-one box setup

  3. Create separate entity for each category. This is not possible, because amount of categories and categories themselves are dynamic

Additional context

Hive supports that:
image

@gryznar gryznar added the enhancement New feature or request label Oct 13, 2024
@greenrobot-team
Copy link
Member

Thanks for reporting! ObjectBox does not really work well with a dynamic data model as its main purpose is to map a fixed data model to Dart classes.

Anyhow, option 1 is also what I would recommend on first thought. Obviously, there are up- and downsides which you seem to have analyzed pretty well (though I'm not sure how valid the concurrent access issue is). Based on that you will have to make a decision if this data model or even ObjectBox works for your use case.

Note: I labeled this issue with "more info required" so it will auto-close in a few days if there are no follow-up comments.

@greenrobot-team greenrobot-team self-assigned this Oct 14, 2024
@greenrobot-team greenrobot-team added the more info required Needs more info to become actionable. Auto-closed if no response. label Oct 14, 2024
@gryznar
Copy link
Author

gryznar commented Oct 14, 2024

As far as I understand, implementing such feature does not work well with fixed-data design?

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Oct 15, 2024
@greenrobot-team
Copy link
Member

Yes, that's basically the summary of what I said and why it is unlikely ObjectBox will ever support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants