aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/data/update.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2025-08-05 12:40:15 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2025-08-05 12:40:15 -0400
commit10d5e4db7ad9fe9855a19977f7bc037b058bfead (patch)
tree478789f87c32d0b9f04f5887acae90b44dfe3da7 /pkg/data/update.go
parent62aeb1a0fb0a239f6193b7cb872787578480082c (diff)
Add headings to db serializer and deserializer
Diffstat (limited to 'pkg/data/update.go')
-rw-r--r--pkg/data/update.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/pkg/data/update.go b/pkg/data/update.go
index 1a50563..6aecb41 100644
--- a/pkg/data/update.go
+++ b/pkg/data/update.go
@@ -129,18 +129,20 @@ func (u *Update) document() (bool, error) {
title := sql.NullString{String: u.Doc.Title, Valid: u.Doc.Title != ""}
date := sql.NullInt64{Int64: u.Doc.Date.Unix(), Valid: !u.Doc.Date.IsZero()}
+ headings := sql.NullString{String: u.Doc.Headings, Valid: u.Doc.Headings != ""}
meta := sql.NullString{String: u.Doc.OtherMeta, Valid: u.Doc.OtherMeta != ""}
_, err := u.tx.Exec(`
- INSERT INTO Documents(path, title, date, fileTime, meta)
- VALUES (?,?,?,?,?)
+ INSERT INTO Documents(path, title, date, fileTime, headings, meta)
+ VALUES (?,?,?,?,?,?)
ON CONFLICT(path)
DO UPDATE SET
title=excluded.title,
date=excluded.date,
fileTime=excluded.fileTime,
+ headings=excluded.headings,
meta=excluded.meta
- `, u.Doc.Path, title, date, filetime, meta)
+ `, u.Doc.Path, title, date, filetime, headings, meta)
if err != nil {
return true, err
}
@@ -160,6 +162,7 @@ func (u *UpdateMany) documents() (bool, error) {
title TEXT,
date INT,
fileTime INT,
+ headings TEXT,
meta BLOB
)`)
if err != nil {
@@ -167,7 +170,7 @@ func (u *UpdateMany) documents() (bool, error) {
}
defer u.tx.Exec("DROP TABLE temp.updateDocs")
- tempInsertStmt, err := u.tx.Prepare("INSERT INTO temp.updateDocs VALUES (?,?,?,?,?)")
+ tempInsertStmt, err := u.tx.Prepare("INSERT INTO temp.updateDocs VALUES (?,?,?,?,?,?)")
if err != nil {
return false, err
}
@@ -186,11 +189,15 @@ func (u *UpdateMany) documents() (bool, error) {
Int64: doc.Date.Unix(),
Valid: !doc.Date.IsZero(),
}
+ headings := sql.NullString{
+ String: doc.Headings,
+ Valid: doc.Headings != "",
+ }
meta := sql.NullString{
String: doc.OtherMeta,
Valid: doc.OtherMeta != "",
}
- if _, err := tempInsertStmt.Exec(path, title, date, filetime, meta); err != nil {
+ if _, err := tempInsertStmt.Exec(path, title, date, filetime, headings, meta); err != nil {
return false, err
}
}
@@ -206,12 +213,13 @@ func (u *UpdateMany) documents() (bool, error) {
}
_, err = u.tx.Exec(`
- INSERT INTO Documents (path, title, date, fileTime, meta)
+ INSERT INTO Documents (path, title, date, fileTime, headings, meta)
SELECT * FROM updateDocs WHERE TRUE
ON CONFLICT(path) DO UPDATE SET
title=excluded.title,
date=excluded.date,
fileTime=excluded.fileTime,
+ headings=excluded.headings,
meta=excluded.meta
WHERE excluded.fileTime > Documents.fileTime
`)