Skip to content

Commit

Permalink
Merge pull request #47 from OpenPecha/develop
Browse files Browse the repository at this point in the history
added sort data
  • Loading branch information
CodingWithTashi authored Nov 29, 2024
2 parents 2165a99 + 0932410 commit aff1d7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Binary file modified assets/db/gonpa.db
Binary file not shown.
23 changes: 17 additions & 6 deletions lib/repo/database_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,28 @@ class DatabaseRepository<T> {

Future<List<T>> getAll() async {
final db = await dbHelper.database;
final maps = await db.query(tableName);

final rawQuery = '''
SELECT organization.* FROM categories
JOIN organization ON categories.title = organization.categories
ORDER BY code ASC;
''';

final maps = await db.rawQuery(rawQuery);
return maps.map((map) => fromMap(map)).toList();
}

Future<List<T>> getAllPaginated(int page, int pageSize) async {
final db = await dbHelper.database;
final maps = await db.query(
tableName,
limit: pageSize,
offset: page * pageSize,
);
final rawQuery = '''
SELECT organization.* FROM categories
JOIN organization ON categories.title = organization.categories
ORDER BY code ASC
LIMIT ? OFFSET ?
''';

final maps = await db.rawQuery(rawQuery, [pageSize, page * pageSize]);

return maps.map((map) => fromMap(map)).toList();
}

Expand Down

0 comments on commit aff1d7c

Please sign in to comment.