drift_sounds_database 0.1.0 copy "drift_sounds_database: ^0.1.0" to clipboard
drift_sounds_database: ^0.1.0 copied to clipboard

The database layer for `drift_sounds`. This package is only the database layer and can be used for anything.

example/drift_sounds_database_example.dart

// ignore_for_file: avoid_print

import 'dart:io';

import 'package:drift/native.dart';
import 'package:drift_sounds_database/drift_sounds_database.dart';
import 'package:path/path.dart' as path;

Future<void> main() async {
  /// Load the database.
  final database = DriftSoundsDatabase.fromLoader(NativeDatabase.memory);
  print('Loaded in-memory database.');
  final directory = Directory.current;
  for (final file in directory.listSync(recursive: true).whereType<File>()) {
    final name = path.relative(file.path, from: directory.path);
    final row = await database.managers.soundDatas.createReturning(
      (final o) => o(bytes: file.readAsBytesSync()),
    );
    print('Loaded $name as #${row.id}.');
  }
  print('Closing database.');
  await database.close();
  print('Done.');
}
0
likes
160
points
159
downloads

Publisher

verified publisherbackstreets.site

Weekly Downloads

The database layer for `drift_sounds`. This package is only the database layer and can be used for anything.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Unlicense (license)

Dependencies

drift

More

Packages that depend on drift_sounds_database