UseDao typedef
- @moorDeprecated
Annotation to use on classes that implement DatabaseAccessor. It specifies which tables should be made available in this dao.
To write a dao, you'll first have to write a database class. See
DriftDatabase
for instructions on how to do that. Then, create an empty
class that is annotated with DriftAccessor
and extends DatabaseAccessor.
For instance, if you have a class called MyDatabase
, this could look like
this:
@DriftAccessor()
class MyDao extends DatabaseAccessor<MyDatabase> {
MyDao(MyDatabase db) : super(db);
}
After having run the build step once more, moor will have generated a mixin
called _$MyDaoMixin
. Change your class definition to
class MyDao extends DatabaseAccessor<MyDatabase> with _$MyDaoMixin
and
you're ready to make queries inside your dao. You can obtain an instance of
that dao by using the getter that will be generated inside your database
class.
See also:
Implementation
@pragma('moor2drift', 'DriftAccessor')
@moorDeprecated
typedef UseDao = DriftAccessor;