Add new API /api/tag

This commit is contained in:
2023-08-27 22:20:21 +08:00
parent 8b31fe104e
commit 4ee6cc38c7
4 changed files with 86 additions and 20 deletions

14
db.ts
View File

@@ -1007,6 +1007,20 @@ export class EhDb {
);
return s.length ? s[0] : undefined;
}
get_tag(id: number) {
const s = this.db.queryEntries<Tag>(
"SELECT * FROM tag WHERE id = ?;",
[id],
);
return s.length ? s[0] : undefined;
}
get_tag_by_tag(tag: string) {
const s = this.db.queryEntries<Tag>(
"SELECT * FROM tag WHERE tag = ?;",
[tag],
);
return s.length ? s[0] : undefined;
}
async get_task(id: number) {
const s = await this.transaction(() =>
this.db.queryEntries<Task>("SELECT * FROM task WHERE id = ?;", [id])