mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-18 10:04:20 +01:00
download some codes
This commit is contained in:
@@ -2,7 +2,7 @@ import 'package:nostr_sdk/utils/db_util.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
class DB {
|
||||
static const _VERSION = 2;
|
||||
static const _VERSION = 3;
|
||||
|
||||
static const _dbName = "nowser.db";
|
||||
|
||||
@@ -41,14 +41,22 @@ class DB {
|
||||
"create table bookmark(id integer not null constraint bookmark_pk primary key autoincrement,title text,url text not null,favicon text,weight integer,added_to_index integer, added_to_qa integer,created_at integer);");
|
||||
db.execute(
|
||||
"create table browser_history(id integer not null constraint browser_history_pk primary key autoincrement,title text,url text not null,favicon text,created_at integer);");
|
||||
|
||||
db.execute(
|
||||
"create table download_log(id integer constraint download_log_pk primary key autoincrement,url text,file_path text,file_name TEXT,file_size integer,created_at integer);");
|
||||
}
|
||||
|
||||
static Future<void> _onUpgrade(
|
||||
Database db, int oldVersion, int newVersion) async {
|
||||
if (oldVersion == 1 && newVersion == 2) {
|
||||
if (oldVersion == 1) {
|
||||
db.execute(
|
||||
"alter table bookmark add added_to_qa integer after added_to_index");
|
||||
}
|
||||
|
||||
if (oldVersion <= 2) {
|
||||
db.execute(
|
||||
"create table download_log(id integer constraint download_log_pk primary key autoincrement,url text,file_path text,file_name TEXT,file_size integer,created_at integer);");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Database> getCurrentDatabase() async {
|
||||
@@ -69,4 +77,17 @@ class DB {
|
||||
_database?.close();
|
||||
_database = null;
|
||||
}
|
||||
|
||||
static Future<void> deleteByIds(String tableName, List<int> ids,
|
||||
{DatabaseExecutor? db}) async {
|
||||
var sql = "delete from $tableName where id in(";
|
||||
for (var id in ids) {
|
||||
sql += "?,";
|
||||
}
|
||||
sql = sql.substring(0, sql.length - 1);
|
||||
sql += ")";
|
||||
|
||||
db = await DB.getDB(db);
|
||||
await db.execute(sql, ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user