putAuto method

Future<void> putAuto(
  1. String key,
  2. List<int> value, {
  3. String? dbName,
  4. LMDBFlagSet? flags,
})

Convenience methods with automatic transaction management Stores a raw byte value with automatic transaction management.

This is a convenience method that handles transaction creation, commit, and error handling automatically.

Parameters:

  • key - Key under which to store the value
  • value - Raw bytes to store
  • dbName - Optional named database
  • flags - Optional operation flags

Example:

// Simple storage without manual transaction handling
await db.putAuto('key', [1, 2, 3, 4]);

Throws StateError if database is closed Throws LMDBException if operation fails

Implementation

/// Stores a raw byte value with automatic transaction management.
///
/// This is a convenience method that handles transaction creation,
/// commit, and error handling automatically.
///
/// Parameters:
/// * [key] - Key under which to store the value
/// * [value] - Raw bytes to store
/// * [dbName] - Optional named database
/// * [flags] - Optional operation flags
///
/// Example:
/// ```dart
/// // Simple storage without manual transaction handling
/// await db.putAuto('key', [1, 2, 3, 4]);
/// ```
///
/// Throws [StateError] if database is closed
/// Throws [LMDBException] if operation fails
Future<void> putAuto(
  String key,
  List<int> value, {
  String? dbName,
  LMDBFlagSet? flags,
}) async {
  return _withTransaction(
    (txn) async => put(txn, key, value, dbName: dbName, flags: flags),
  );
}