01a692ab5b
Added tests for the word filter store. Added qgen.NewAcc() to reduce the amount of boilerplate needed for creating an accumulator. Exposed the RecordError method on the accumulator. Added an Add method to PluginList and removed AddPlugin() in favour of that. More panel buttons on Nox should be styled now. Added the panel_update_button_text phrase for future use. More errors might be caught in the thumbnailer now. Removed ls from .travis.yml, it was there for debugging Code Climate.
30 lines
842 B
Go
30 lines
842 B
Go
package common
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"../query_gen/lib"
|
|
)
|
|
|
|
var Attachments AttachmentStore
|
|
|
|
type AttachmentStore interface {
|
|
Add(sectionID int, sectionTable string, originID int, originTable string, uploadedBy int, path string) error
|
|
}
|
|
|
|
type DefaultAttachmentStore struct {
|
|
add *sql.Stmt
|
|
}
|
|
|
|
func NewDefaultAttachmentStore() (*DefaultAttachmentStore, error) {
|
|
acc := qgen.NewAcc()
|
|
return &DefaultAttachmentStore{
|
|
add: acc.Insert("attachments").Columns("sectionID, sectionTable, originID, originTable, uploadedBy, path").Fields("?,?,?,?,?,?").Prepare(),
|
|
}, acc.FirstError()
|
|
}
|
|
|
|
func (store *DefaultAttachmentStore) Add(sectionID int, sectionTable string, originID int, originTable string, uploadedBy int, path string) error {
|
|
_, err := store.add.Exec(sectionID, sectionTable, originID, originTable, uploadedBy, path)
|
|
return err
|
|
}
|