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>
count() 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 Delete this model
find(dynamic id) Future<T?>
Find by ID Find by ID
fromMap(Map map) → T
Convert DB map into a model instance
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query() → QueryBuilder
Custom query builder
refresh([dynamic id]) Future<T?>
Refresh the model from DB
save() Future<T?>
Save model (create or update)
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) Future<List<T>>
Where clause
whereIn(String field, List values) Future<List<T>>
Find records with custom conditions

Operators

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