tabledb work
This commit is contained in:
@@ -25,11 +25,11 @@ abstract class VeilidTableDBTransaction {
|
||||
|
||||
abstract class VeilidTableDB {
|
||||
int getColumnCount();
|
||||
List<Uint8List> getKeys(int col);
|
||||
Future<List<Uint8List>> getKeys(int col);
|
||||
VeilidTableDBTransaction transact();
|
||||
Future<void> store(int col, Uint8List key, Uint8List value);
|
||||
Future<Uint8List?> load(int col, Uint8List key);
|
||||
Future<bool> delete(int col, Uint8List key);
|
||||
Future<Uint8List?> delete(int col, Uint8List key);
|
||||
|
||||
Future<void> storeJson(int col, Uint8List key, Object? object,
|
||||
{Object? Function(Object? nonEncodable)? toEncodable}) {
|
||||
@@ -56,4 +56,18 @@ abstract class VeilidTableDB {
|
||||
{Object? Function(Object? key, Object? value)? reviver}) {
|
||||
return loadJson(col, utf8.encoder.convert(key), reviver: reviver);
|
||||
}
|
||||
|
||||
Future<Object?> deleteJson(int col, Uint8List key,
|
||||
{Object? Function(Object? key, Object? value)? reviver}) async {
|
||||
var s = await delete(col, key);
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
return jsonDecode(utf8.decode(s, allowMalformed: false), reviver: reviver);
|
||||
}
|
||||
|
||||
Future<Object?> deleteStringJson(int col, String key,
|
||||
{Object? Function(Object? key, Object? value)? reviver}) {
|
||||
return deleteJson(col, utf8.encoder.convert(key), reviver: reviver);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user