Skip to content

Instantly share code, notes, and snippets.

View ayalma's full-sized avatar
😐
I may be slow to respond.

Ali Mohammadi ayalma

😐
I may be slow to respond.
View GitHub Profile
@ayalma
ayalma / article_dao.dart
Created September 27, 2021 12:18 — forked from ForceTower/article_dao.dart
Fetch relations using floor
@Query('SELECT * FROM article ORDER BY publishedAt DESC')
Stream<List<Article>> getAllArticles();
@Query('SELECT Author.*, _junction.articleId as articleId FROM ArticleAuthor AS _junction inner join Author ON (_junction.authorId = Author.id) WHERE _junction.articleId IN (:ids)')
Future<List<AuthorArticleId>> getAuthorsFromArticles(List<int> ids);
Stream<List<ArticleWithAuthor>> getAllArticlesWithAuthors() {
final stream = getAllArticles();
final controller = StreamController<List<ArticleWithAuthor>>.broadcast();