Db class

A class to handle database operations

Constructors

Db({Database? sqfliteDatabase})
An empty database. Has to be initialized with init

Properties

changefeed Stream<DatabaseChangeEvent>
A stream of DatabaseChangeEvent with all the changes that occur in the database
no setter
database → Database?
This Sqflite Database
no setter
file File?
This Sqlite file
no setter
hashCode int
The hash code for this object.
no setterinherited
hasSchema bool
Check the existence of a schema
no setter
isReady bool
This database state
no setter
onReady Future<void>
The on ready callback: fired when the database is ready to operate
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schema DbSchema
This database schema
no setter
sqfliteDatabase → Database?
An Sqlite database:
final

Methods

batchInsert({required String table, required List<Map<String, String>> rows, ConflictAlgorithm conflictAlgorithm = ConflictAlgorithm.rollback, bool verbose = false}) Future<List>
Insert rows in a table
count({required String table, String? where, String columns = "id", bool verbose = false}) Future<int?>
count rows in a table
delete({required String table, required String? where, bool verbose = false}) Future<int>
Delete some datapoints from the database
dispose() → void
Dispose the changefeed stream when finished using
exists({required String table, required String where, bool verbose = false}) Future<bool>
Check if a value exists in the table
init({required String path, bool absolutePath = false, List<String> queries = const <String>[], List<DbTable> schema = const <DbTable>[], bool verbose = false, String? fromAsset, bool debug = false}) Future<void>
Initialize the database
insert({required String table, required Map<String, String?> row, bool verbose = false}) Future<int?>
Insert a row in a table
insertIfNotExists({required String table, required Map<String, String?> row, bool verbose = false}) Future<int?>
Insert a row in a table if it is not present already
insertManageConflict({required String table, required ConflictAlgorithm conflictAlgorithm, required Map<String, dynamic> row, bool verbose = false}) Future<int?>
Insert a row in a table with conflict algorithm
join({required String? table, required String? joinTable, required String? joinOn, String columns = "*", int? offset, int? limit, String? orderBy, String? where, String? groupBy, bool verbose = false}) Future<List<Map<String, dynamic>>?>
A select query with a join
mJoin({required String table, required List<String> joinsTables, required List<String> joinsOn, String columns = "*", int? offset, int? limit, String? orderBy, String? where, String? groupBy, bool verbose = false}) Future<List<Map<String, dynamic>>?>
A select query with a join on multiple tables
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query(String? q, {bool verbose = false}) Future<List<Map<String, dynamic>>?>
Execute a query
select({required String? table, String columns = "*", String? where, String? orderBy, int? limit, int? offset, String? groupBy, bool verbose = false}) Future<List<Map<String, dynamic>>?>
A select query
toString() String
A string representation of this object.
inherited
update({required String table, required Map<String, String?> row, required String where, bool verbose = false}) Future<int>
Update some datapoints in the database
upsert({required String table, required Map<String, String?> row, List<String> preserveColumns = const [], String? indexColumn, bool verbose = false}) Future<void>
Insert a row if it does not exist or update it

Operators

operator ==(Object other) bool
The equality operator.
inherited