objectbox / objectbox/objectbox-dart

Ability to pass ID to Box creation

Open
#680 3 comments 0 reactions 1 assignee View on GitHub

@greenrobot-team is already working on this.

Since Oct 14, 2024.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.