Update to use pg/v10

This commit is contained in:
Las Zenow 2020-11-30 19:03:31 +00:00
parent 94c75b1d2a
commit 1536d97d8d
13 changed files with 449 additions and 98 deletions

View file

@ -6,7 +6,7 @@ import (
"strings"
"time"
"github.com/go-pg/pg/v9"
"github.com/go-pg/pg/v10"
)
// Book metadata
@ -23,11 +23,10 @@ type Book struct {
Isbn string `pg:"type:varchar(13)"`
FileSize int `pg:"type:integer"`
FileHash []byte
Cover bool `pg:",notnull"`
Active bool `pg:",notnull"`
Cover bool `pg:",use_zero"`
Active bool `pg:",use_zero"`
UploadDate time.Time `pg:"type:timestamp"`
Tsv string `pg:"type:tsvector"`
Visit *Visit
}
// AddBook to the database
@ -37,7 +36,8 @@ func (db *pgDB) AddBook(book Book) error {
book.UploadDate = time.Now()
}
return db.sql.Insert(&book)
_, err := db.sql.Model(&book).Insert()
return err
}
// GetBooks matching query