df/bff/db/sqlc/tx_create_person.go
itsscb 91903b9a2e ft/adds additional endpoints and refactors others
New:
- GetAccount
- ListAccounts
- CreatePerson

Refactored:
- CreateAccount
- RefreshToken
- UpdateAccount
2023-10-06 00:18:53 +02:00

38 lines
850 B
Go

package db
import (
"context"
"time"
)
type CreatePersonTxParams struct {
AccountID int64 `json:"account_id"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Birthday time.Time `json:"birthday"`
City string `json:"city"`
Zip string `json:"zip"`
Street string `json:"street"`
Country string `json:"country"`
Creator string `json:"creator"`
Changer string `json:"changer"`
}
type CreatePersonTxResult struct {
Person Person `json:"person"`
}
func (store *SQLStore) CreatePersonTx(ctx context.Context, arg CreatePersonTxParams) (Person, error) {
var result CreatePersonTxResult
err := store.execTx(ctx, func(q *Queries) error {
var err error
result.Person, err = q.CreatePerson(ctx, CreatePersonParams(arg))
return err
})
return result.Person, err
}