summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/models/organisations.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/models/organisations.go b/internal/models/organisations.go
index 7a8898c..291562b 100644
--- a/internal/models/organisations.go
+++ b/internal/models/organisations.go
@@ -16,7 +16,19 @@ type OrganisationModel struct {
}
func (m *OrganisationModel) Insert(name string) (int, error) {
- return 0, nil
+ stmt := `INSERT INTO organisations (name, created)
+ VALUEs (?, UTC_TIMESTAMP())`
+
+ result, err := m.DB.Exec(stmt, name)
+ if err != nil {
+ return 0, err
+ }
+
+ id, err := result.LastInsertId()
+ if err != nil {
+ return 0, err
+ }
+ return int(id), nil
}
func (m *OrganisationModel) Get(id int) (Organisation, error) {