Model<T extends Model<T>> class
abstract
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)