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

Update README.md #382

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions sembast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ Follow the [guide](https://github.com/tekartik/sembast.dart/blob/master/sembast/

A database is a single file represented by a path in the file system

#### Flutter

On flutter you need to find a proper location for the database. One solution is to use the `path_provider` package get
a directory in which you want to create the database.

```dart
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sembast/sembast_io.dart';

// get the application documents directory
final dir = await getApplicationDocumentsDirectory();
// make sure it exists
await dir.create(recursive: true);
// build the database path
final dbPath = join(dir.path, 'my_database.db');
// open the database
final db = await databaseFactoryIo.openDatabase(dbPath);
```

#### Dart

```dart
// File path to a file in the current directory
String dbPath = 'sample.db';
Expand Down