putUtf8Auto method
Stores a UTF-8 string with automatic transaction management.
Perfect for simple string storage operations where manual transaction control isn't needed.
The key is used as UTF-8 encoded database key.
The value string will be UTF-8 encoded before storage.
The optional dbName parameter specifies a named database.
If not provided, the default database will be used.
The optional flags parameter allows setting specific LMDB flags for this operation.
This method handles the transaction automatically, including commit and abort in case of errors.
Example:
// Simple string storage
await db.putUtf8Auto('greeting', 'Hello, World!');
// Store JSON data
final userData = {'name': 'John', 'age': 30};
await db.putUtf8Auto('user_123', jsonEncode(userData));
Throws StateError if the database is closed. Throws LMDBException if the operation fails.
Implementation
Future<void> putUtf8Auto(
String key,
String value, {
String? dbName,
LMDBFlagSet? flags,
}) async {
return _withTransaction((txn) async {
return putUtf8(txn, key, value, dbName: dbName, flags: flags);
});
}