Query class

Annotation for define raw query for access or manipulate data. You have to pass your raw query as a String to query property of this annotation. You have to detect the return type, yourself. You can fetch raw results as List<Map<String, Object?>>? by using RawData class as the return type. Also, you can fetch results as a custom class. In this case you must pass that custom class to the SingularReturnType annotation. For better query, you can have any number of input parameters and you can pass these parameters to query using the colon(:) symbol. Examples:

  @Query("select * from Note")
  Future<List<Note>> all();

  @Query("delete from Note")
  Future<void> deleteAll();

  @Query("select * from Note where id= :id")
  Future<Note?> getById(int id);

  @Query("select count(*) from Note")
  Future<int?> count();

  @Query("select * from Note where isEdited= :isEdited")
  Future<List<Note>> getNotes(bool isEdited);

  @Query("select * from Note where id IN (:ids)")
  Future<List<Note>> getNotesByIds(List<int> ids);

  @Query("select * from Note where lat IN (:lats)")
  Future<List<Note>> getNotesByLatitudes(List<double> lats);

  @Query("select * from Note where text LIKE '%:search%'")
  Future<RawData> search(String search);

  @Query("select lat from Note")
  Future<List<double>> getLatitudes();

  @Query("select id, text, lat, createDate from Note")
  @SingularReturnType(CustomNote)
  Future<List<CustomNote>> getCustomNotes();

  @Query("select id, text, lat, createDate from Note where id= :id")
  @SingularReturnType(CustomNote)
  Future<CustomNote?> getCustomNoteById(int id);

Constructors

Query(String query)
const

Properties

hashCode int
The hash code for this object.
no setterinherited
query String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

fields ↔ _QueryFields
getter/setter pair