cursorCount method
Helper method to count entries using a cursor
Parameters:
txn- Active transactiondbName- Optional named database
Returns the number of entries in the database
Example:
final count = await db.cursorCount();
print('Database contains $count entries');
Implementation
Future<int> cursorCount(
Pointer<MDB_txn> txn, {
String? dbName,
}) async {
final cursor = await cursorOpen(txn, dbName: dbName);
try {
var count = 0;
var entry = await cursorGet(cursor, null, CursorOp.first);
while (entry != null) {
count++;
entry = await cursorGet(cursor, null, CursorOp.next);
}
return count;
} finally {
cursorClose(cursor);
}
}