Explain usages of .memory() in docs

This commit is contained in:
Simon Binder 2021-10-30 16:29:37 +02:00
parent 0501e61f59
commit 23c912d6aa
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 5 additions and 0 deletions

View File

@ -18,10 +18,13 @@ targets:
options:
generate_connect_constructor: true
```
Next, re-run the build. You can now add another constructor to the generated database class:
```dart
@DriftDatabase(...)
class TodoDb extends _$TodoDb {
// Your existing constructor, whatever it may be...
TodoDb() : super(NativeDatabase.memory());
// this is the new constructor

View File

@ -24,6 +24,8 @@ part 'database.g.dart';
include: {'tables.drift'},
)
class MyDb extends _$MyDb {
// This example creates a simple in-memory database (without actual persistence).
// To actually store data, see the database setups from other "Getting started" guides.
MyDb() : super(NativeDatabase.memory());
@override