Setup photos and folders to use separate DBs for simplicity
This commit is contained in:
parent
266c13fe05
commit
fd8d1a3e99
2 changed files with 10 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart';
|
||||
|
@ -6,7 +7,8 @@ import 'package:sqflite/sqflite.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class FolderDB {
|
||||
static final _databaseName = "ente.db";
|
||||
// TODO: Use different tables within the same database
|
||||
static final _databaseName = "ente.folder.db";
|
||||
static final _databaseVersion = 1;
|
||||
|
||||
static final table = 'folders';
|
||||
|
@ -87,7 +89,7 @@ class FolderDB {
|
|||
row[columnName] = folder.name;
|
||||
row[columnOwner] = folder.owner;
|
||||
row[columnDeviceFolder] = folder.deviceFolder;
|
||||
row[columnSharedWith] = folder.sharedWith.toString();
|
||||
row[columnSharedWith] = jsonEncode(folder.sharedWith.toList());
|
||||
row[columnUpdateTimestamp] = folder.updateTimestamp;
|
||||
return row;
|
||||
}
|
||||
|
@ -98,7 +100,9 @@ class FolderDB {
|
|||
row[columnName],
|
||||
row[columnOwner],
|
||||
row[columnDeviceFolder],
|
||||
Set<String>.from(row[columnSharedWith]),
|
||||
(jsonDecode(row[columnSharedWith]) as List<dynamic>)
|
||||
.cast<String>()
|
||||
.toSet(),
|
||||
row[columnUpdateTimestamp],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import 'package:sqflite/sqflite.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class PhotoDB {
|
||||
static final _databaseName = "ente.db";
|
||||
// TODO: Use different tables within the same database
|
||||
static final _databaseName = "ente.photos.db";
|
||||
static final _databaseVersion = 1;
|
||||
|
||||
static final table = 'photos';
|
||||
|
@ -85,7 +86,7 @@ class PhotoDB {
|
|||
final db = await instance.database;
|
||||
final results = await db.query(
|
||||
table,
|
||||
where: '$columnIsDeleted = 0',
|
||||
where: '$columnLocalId IS NOT NULL AND $columnIsDeleted = 0',
|
||||
orderBy: '$columnCreateTimestamp DESC',
|
||||
);
|
||||
return _convertToPhotos(results);
|
||||
|
|
Loading…
Add table
Reference in a new issue