diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart index 0cb36daef..b9f7328e5 100644 --- a/mobile/lib/db/files_db.dart +++ b/mobile/lib/db/files_db.dart @@ -660,13 +660,12 @@ class FilesDB { } Future> getAllFilesCollection(int collectionID) async { - final db = await instance.database; + final db = await instance.sqliteAsyncDB; const String whereClause = '$columnCollectionID = ?'; final List whereArgs = [collectionID]; - final results = await db.query( - filesTable, - where: whereClause, - whereArgs: whereArgs, + final results = await db.getAll( + 'SELECT * FROM $filesTable WHERE $whereClause', + whereArgs, ); final files = convertToFiles(results); return files; @@ -676,14 +675,13 @@ class FilesDB { int collectionID, int addedTime, ) async { - final db = await instance.database; + final db = await instance.sqliteAsyncDB; const String whereClause = '$columnCollectionID = ? AND $columnAddedTime > ?'; final List whereArgs = [collectionID, addedTime]; - final results = await db.query( - filesTable, - where: whereClause, - whereArgs: whereArgs, + final results = await db.getAll( + 'SELECT * FROM $filesTable WHERE $whereClause', + whereArgs, ); final files = convertToFiles(results); return files; @@ -705,20 +703,22 @@ class FilesDB { inParam += "'" + id.toString() + "',"; } inParam = inParam.substring(0, inParam.length - 1); - final db = await instance.database; + final db = await instance.sqliteAsyncDB; final order = (asc ?? false ? 'ASC' : 'DESC'); final String whereClause = '$columnCollectionID IN ($inParam) AND $columnCreationTime >= ? AND ' '$columnCreationTime <= ? AND $columnOwnerID = ?'; final List whereArgs = [startTime, endTime, userID]; - final results = await db.query( - filesTable, - where: whereClause, - whereArgs: whereArgs, - orderBy: - '$columnCreationTime ' + order + ', $columnModificationTime ' + order, - limit: limit, + String query = 'SELECT * FROM $filesTable WHERE $whereClause ORDER BY ' + '$columnCreationTime $order, $columnModificationTime $order'; + if (limit != null) { + query += ' LIMIT ?'; + whereArgs.add(limit); + } + final results = await db.getAll( + query, + whereArgs, ); final files = convertToFiles(results); final dedupeResult =