mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
mobile: migrate to sqlite
This commit is contained in:
committed by
Abdullah Atta
parent
2168609577
commit
5bfad0149b
@@ -137,7 +137,6 @@ class Database {
|
||||
transaction = (
|
||||
executor: (tr: Transaction<DatabaseSchema>) => void | Promise<void>
|
||||
) => {
|
||||
console.time("transaction");
|
||||
return this.transactionMutex.runExclusive(() =>
|
||||
this.sql()
|
||||
.transaction()
|
||||
@@ -147,7 +146,6 @@ class Database {
|
||||
this._transaction = undefined;
|
||||
})
|
||||
.finally(() => {
|
||||
console.timeEnd("transaction");
|
||||
this._transaction = undefined;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -314,7 +314,7 @@ export class Attachments implements ICollection {
|
||||
});
|
||||
}
|
||||
|
||||
markAsFailed(id: string, reason: string) {
|
||||
markAsFailed(id: string, reason?: string) {
|
||||
return this.collection.update([id], {
|
||||
dateUploaded: null,
|
||||
failed: reason
|
||||
|
||||
@@ -294,6 +294,19 @@ class RelationsArray<TType extends keyof RelatableTable> {
|
||||
return result.count > 0;
|
||||
}
|
||||
|
||||
async hasAll(...ids: string[]) {
|
||||
const result = await this.db
|
||||
.sql()
|
||||
.selectFrom("relations")
|
||||
.$call(this.buildRelationsQuery())
|
||||
.clearSelect()
|
||||
.where(this.direction === "from" ? "toId" : "fromId", "in", ids)
|
||||
.select((b) => b.fn.count<number>("id").as("count"))
|
||||
.executeTakeFirst();
|
||||
if (!result) return false;
|
||||
return result.count === ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an optimized query for obtaining relations based on the given
|
||||
* parameters. The resulting query uses a covering index (the most
|
||||
|
||||
Reference in New Issue
Block a user