Compare commits
2 Commits
39d66e5280
...
05c59937e9
Author | SHA1 | Date | |
---|---|---|---|
|
05c59937e9 | ||
|
67466b4968 |
@ -88,12 +88,14 @@ class SqliteDocumentAccessor implements DocumentAccessor {
|
|||||||
.executeTakeFirst() as { id: number };
|
.executeTakeFirst() as { id: number };
|
||||||
const id = id_lst.id;
|
const id = id_lst.id;
|
||||||
|
|
||||||
// add tags
|
if (tags.length > 0){
|
||||||
await trx.insertInto("tags")
|
// add tags
|
||||||
.values(tags.map((x) => ({ name: x })))
|
await trx.insertInto("tags")
|
||||||
// on conflict is supported in sqlite and postgresql.
|
.values(tags.map((x) => ({ name: x })))
|
||||||
.onConflict((oc) => oc.doNothing())
|
// on conflict is supported in sqlite and postgresql.
|
||||||
.execute();
|
.onConflict((oc) => oc.doNothing())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
|
||||||
if (tags.length > 0) {
|
if (tags.length > 0) {
|
||||||
await trx.insertInto("doc_tag_relation")
|
await trx.insertInto("doc_tag_relation")
|
||||||
@ -310,10 +312,12 @@ class SqliteDocumentAccessor implements DocumentAccessor {
|
|||||||
.where("doc_id", "=", c.id)
|
.where("doc_id", "=", c.id)
|
||||||
.execute();
|
.execute();
|
||||||
// update tags and doc_tag_relation
|
// update tags and doc_tag_relation
|
||||||
await trx.insertInto("tags")
|
if (tags.length > 0) {
|
||||||
.values(tags.map((x) => ({ name: x })))
|
await trx.insertInto("tags")
|
||||||
.onConflict((oc) => oc.doNothing())
|
.values(tags.map((x) => ({ name: x })))
|
||||||
.execute();
|
.onConflict((oc) => oc.doNothing())
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
await trx.insertInto("doc_tag_relation")
|
await trx.insertInto("doc_tag_relation")
|
||||||
.values(tags.map((x) => ({ tag_name: x, doc_id: c.id }))
|
.values(tags.map((x) => ({ tag_name: x, doc_id: c.id }))
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,17 @@ export function getKysely() {
|
|||||||
kysely = new Kysely<DB>({
|
kysely = new Kysely<DB>({
|
||||||
dialect: createSqliteDialect(),
|
dialect: createSqliteDialect(),
|
||||||
// plugins: [new ParseJSONResultsPlugin()],
|
// plugins: [new ParseJSONResultsPlugin()],
|
||||||
|
log: (event) => {
|
||||||
|
if (event.level === "error") {
|
||||||
|
console.error("Query failed : ", {
|
||||||
|
durationMs: event.queryDurationMillis,
|
||||||
|
error: event.error,
|
||||||
|
sql: event.query.sql,
|
||||||
|
params: event.query.parameters,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return kysely;
|
return kysely;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user