Add "isKey" property to the HiveField annotation.
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
Currently we have to provide the key explicit on writes if we don't want to use the given index as key.
Example:
var dogId = 5;
var dog = Dog(id: dogId, name: 'Nero');
// 1. Gets "dogId" as key.
await box.put(dogId, dog);
// 2. Gets index as key.
await box.put(dog);
It would be nice if we I in both cases could get the object again using:
Dog myDog = await box.get(dogId);
This could be possible if @HiveField is extended with an isKey property, so Hive could look for that option on the HiveObject before defaulting to use the Index.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the HiveField annotation and the box.put/box.get entry points described in the issue, focusing on how keys currently come from explicit writes or the index. Done means the proposed isKey behavior is defined and objects can be retrieved by the annotated key in both write examples, with coverage for the existing default behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100