BaseDao<T extends BaseDbModel> class abstract

@date 27/4/22 describe: @author:Barry

Inheritance

Constructors

BaseDao(String tableName, String primaryKey)

Properties

db → Database
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
table String
no setter

Methods

addColumn(String field) → void
add the new column for table, the filed just like 'name Text'
override
clear([String? tableName]) Future<void>
清空表所有数据
override
composeIds(List<Object?>? datas) String
组装Ids
override
delete(T? t, [String? tableName]) Future<int>
删除数据
override
deleteMulti(List<Object?>? datas, [String? tableName]) Future<int>
删除多个Id
override
drop([String? tableName]) Future<void>
删除表所有数据
override
execute(String sql, [List<Object?>? arguments]) Future<void>
执行sql语句
override
fromJson(Map json) → T
inherited
insert(T? t, [String? tableName]) Future<int>
插入单个model
override
insertAll(List<T?> t, {String? tableName, String? nullColumnHack, ConflictAlgorithm? conflictAlgorithm = ConflictAlgorithm.replace}) Future<int>
插入所有model
override
insertMap(Map<String, dynamic> t, [String? tableName]) Future<int>
插入map
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onUpgrade(int oldVersion, int newVersion) FutureOr<void>
增加表更新的方法,这里只是回调到每个dao类中,一个dao类一个表,针对当前表进行更新
query({String? tableName, bool? distinct, List<String>? columns, String? where, List<Object?>? whereArgs, String? groupBy, String? having, String? orderBy, int? limit, int? offset}) Future<List<T>>
调用sqflite 封装好的查询
override
queryAll([String? tableName]) Future<List<T>>
查询该表的所有数据
override
queryCount([String? tableName]) Future<int>
查询该表的总数
override
queryMultiIds(List<Object?>? datas, [String? tableName]) Future<List<T>>
查询多个ids
override
queryOne(Object arg, [String? tableName]) Future<T?>
根据id,查询一个
override
random([String? tableName]) Future<T?>
随机获取一个数据
override
randoms(int count, [String? tableName]) Future<List<T>>
随机查询一组数据
override
rawQuery(String sql, [List<Object?>? arguments]) Future<List<T>>
调用sql语句执行
override
toString() String
A string representation of this object.
inherited
update(T? t, [String? tableName]) Future<int>
更新map
override
updateAll(List<T>? t, {String? tableName, ConflictAlgorithm? conflictAlgorithm = ConflictAlgorithm.replace}) Future<int>
更新所有数据库
override

Operators

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