Model<T extends Model<T>> class abstract

Constructors

Model()

Properties

conceal List<String>
Concealed fields that should not appear in toMap()
no setter
createdAt DateTime?
no setter
hashCode int
The hash code for this object.
no setterinherited
id → dynamic
no setter
primaryKey String
Primary key column
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
table Table
Table schema definition
no setter
updatedAt DateTime?
no setter

Methods

all() Future<List<T>>
Get all records
asMap() Map<String, dynamic>
avg(String column) Future<double?>
Get average value
count([String column = '*']) Future<int>
Count results
countAll() Future<int>
Count all records
countWhere(String field, dynamic value) Future<int>
Count records with condition
create([Map<String, dynamic>? data]) Future<T?>
Insert new record (works for both PostgreSQL and MySQL)
delete([dynamic id]) Future<bool>
Delete this model
find(dynamic id) Future<T?>
Find by ID
first() Future<T?>
Get first result
fromMap(Map map) → T
Convert DB map into a model instance
get() Future<List<T>>
Execute the query and get results
groupBy(String field) → T
GROUP BY clause - chainable
limit(int value) → T
LIMIT clause - chainable
max(String column) Future
Get max value
min(String column) Future
Get min value
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int value) → T
OFFSET clause - chainable
orderBy(String field, [String direction = 'ASC']) → T
ORDER BY clause - chainable
orWhere(String field, dynamic value) → T
OR WHERE clause - chainable
paginate(int page, [int perPage = 15]) Future<Map<String, dynamic>>
Paginate results
query() QueryBuilder
Custom query builder - starts a new chain
refresh([dynamic id]) Future<T?>
Refresh the model from DB
save() Future<T?>
Save model (create or update)
select(List<String> fields) → T
SELECT specific fields - chainable
sum(String column) Future<double?>
Get sum value
toMap() Map<String, dynamic>
Base map of model fields (user implements this) Returns the safe map including concealed filter and timestamps
toString() String
A string representation of this object.
inherited
truncate() Future<void>
Truncate table
update([dynamic id, Map<String, dynamic>? data]) Future<T?>
Update existing record using the helper method
where(String field, dynamic value) → T
WHERE clause - chainable
whereIn(String field, List values) → T
WHERE IN clause - chainable
whereInSimple(String field, List values) Future<List<T>>
Simple where IN clause (non-chainable)
whereNotIn(String field, List values) → T
WHERE NOT IN clause - chainable
whereNotNull(String field) → T
WHERE NOT NULL clause - chainable
whereNull(String field) → T
WHERE NULL clause - chainable
whereOperator(String field, String operator, dynamic value) → T
WHERE with custom operator - chainable
whereSimple(String field, dynamic value) Future<List<T>>
Simple where clause (non-chainable)

Operators

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