isar / isar/hive

Using nested Type adapters & Single box

Open
#558 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Question**
I have created a number of Type Adapters for my models, some of these included objects nested as fields in an object.
I can access the data fine and update it. However when starting the app it can take anywhere from 10-30 seconds to open the box on boot.

Should I separate my models out more and just contain Keys to the other objects instead of nesting them?
Should I use a separate box for each model rather than one for the whole app?

**Code sample**
```dart
void main() async {
Stopwatch stopwatch = Stopwatch();
stopwatch.start();
await Hive.initFlutter();
print("Hive Init in ${stopwatch.elapsed}");
Hive
..registerAdapter(GameweekAdapter())
..registerAdapter(DraftTeamAdapter())
..registerAdapter(DraftSquadAdapter())
..registerAdapter(DraftPlayerAdapter())
..registerAdapter(LiveMatchAdapter())
..registerAdapter(LiveStatAdapter())
..registerAdapter(LiveStatsListAdapter())
..registerAdapter(DraftMatchListAdapter())
..registerAdapter(DraftMatchAdapter())
..registerAdapter(PlMatchAdapter())
..registerAdapter(PlMatchListAdapter())
..registerAdapter(PlStatAdapter())
..registerAdapter(PlPlayerAdapter())
..registerAdapter(TeamStandingAdapter())
..registerAdapter(TeamStandingsListAdapter());
print('Hive setup in ${stopwatch.elapsed}');
var dataBox = await Hive.openBox('draftFutbolDB');
print('Hive box open in ${stopwatch.elapsed}');
runApp(MyApp());
}
```

**Version**
- Platform: iOS, Android
- Flutter version: 1.22.6
- Hive version: 1.4.4+1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.