2020-12-29 13:46:58 +01:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2021-01-03 18:21:42 +01:00
|
|
|
"time"
|
|
|
|
|
2023-02-20 23:54:02 +01:00
|
|
|
"gitea.larvit.se/pwrpln/go_log"
|
2020-12-29 13:46:58 +01:00
|
|
|
"github.com/google/uuid"
|
2021-01-02 11:56:24 +01:00
|
|
|
"github.com/jackc/pgx/v4/pgxpool"
|
2020-12-29 13:46:58 +01:00
|
|
|
)
|
|
|
|
|
2021-01-03 18:21:42 +01:00
|
|
|
// Account is an account as represented in the database
|
|
|
|
type Account struct {
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
Fields map[string][]string `json:"fields"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Password string `json:"-"`
|
|
|
|
}
|
|
|
|
|
2021-01-02 12:09:16 +01:00
|
|
|
// CreatedAccount is a newly created account in the system
|
|
|
|
type CreatedAccount struct {
|
2021-01-03 18:21:42 +01:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
APIKey string `json:"apiKey"`
|
2021-01-02 11:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// AccountCreateInputFields yes
|
|
|
|
type AccountCreateInputFields struct {
|
|
|
|
Name string
|
|
|
|
Values []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// AccountCreateInput is used as input struct for database creation of account
|
|
|
|
type AccountCreateInput struct {
|
2021-01-03 18:21:42 +01:00
|
|
|
ID uuid.UUID
|
|
|
|
Name string
|
|
|
|
APIKey string
|
|
|
|
Fields []AccountCreateInputFields
|
|
|
|
Password string
|
2021-01-02 11:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Db struct
|
|
|
|
type Db struct {
|
|
|
|
DbPool *pgxpool.Pool
|
2023-02-20 23:54:02 +01:00
|
|
|
Log go_log.Log
|
2020-12-29 13:46:58 +01:00
|
|
|
}
|