-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
import '../model/name.dart'; | ||
|
||
@dao | ||
abstract class NameDao { | ||
@Query('SELECT * FROM names ORDER BY name ASC') | ||
Future<List<Name>> findAllNames(); | ||
|
||
@Query('SELECT * FROM names ORDER BY name ASC') | ||
Stream<List<Name>> findAllNamesAsStream(); | ||
|
||
@Query('SELECT * FROM names WHERE name = :name') | ||
Future<Name> findExactName(String name); | ||
|
||
@Query('SELECT * FROM names WHERE name = :name') | ||
Stream<Name> findExactNameAsStream(int id); | ||
|
||
@Query('SELECT * FROM names WHERE name LIKE :suffix ORDER BY name ASC') | ||
Future<List<Name>> findNamesLike(String suffix); | ||
|
||
@Query('SELECT * FROM names WHERE name LIKE :suffix') | ||
Stream<List<Name>> findNamesLikeAsStream(String suffix); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:floor/floor.dart'; | ||
|
||
@DatabaseView( | ||
'SELECT custom_name as name FROM person UNION SELECT name from dog', | ||
viewName: 'names') | ||
class Name { | ||
final String name; | ||
|
||
Name(this.name); | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is Name && runtimeType == other.runtimeType && name == other.name; | ||
|
||
@override | ||
int get hashCode => name.hashCode; | ||
|
||
@override | ||
String toString() { | ||
return 'Name{name: $name}'; | ||
} | ||
} |