mirror of
https://github.com/acaloiaro/frm
synced 2026-07-21 18:29:12 +00:00
134 lines
3.5 KiB
Go
134 lines
3.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
|
|
package internal
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/acaloiaro/frm/types"
|
|
)
|
|
|
|
type FormStatus string
|
|
|
|
const (
|
|
FormStatusPublished FormStatus = "published"
|
|
FormStatusDraft FormStatus = "draft"
|
|
)
|
|
|
|
func (e *FormStatus) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = FormStatus(s)
|
|
case string:
|
|
*e = FormStatus(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for FormStatus: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type NullFormStatus struct {
|
|
FormStatus FormStatus `json:"form_status"`
|
|
Valid bool `json:"valid"` // Valid is true if FormStatus is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *NullFormStatus) Scan(value interface{}) error {
|
|
if value == nil {
|
|
ns.FormStatus, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.FormStatus.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns NullFormStatus) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.FormStatus), nil
|
|
}
|
|
|
|
type SubmissionStatus string
|
|
|
|
const (
|
|
SubmissionStatusComplete SubmissionStatus = "complete"
|
|
SubmissionStatusPartial SubmissionStatus = "partial"
|
|
)
|
|
|
|
func (e *SubmissionStatus) Scan(src interface{}) error {
|
|
switch s := src.(type) {
|
|
case []byte:
|
|
*e = SubmissionStatus(s)
|
|
case string:
|
|
*e = SubmissionStatus(s)
|
|
default:
|
|
return fmt.Errorf("unsupported scan type for SubmissionStatus: %T", src)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type NullSubmissionStatus struct {
|
|
SubmissionStatus SubmissionStatus `json:"submission_status"`
|
|
Valid bool `json:"valid"` // Valid is true if SubmissionStatus is not NULL
|
|
}
|
|
|
|
// Scan implements the Scanner interface.
|
|
func (ns *NullSubmissionStatus) Scan(value interface{}) error {
|
|
if value == nil {
|
|
ns.SubmissionStatus, ns.Valid = "", false
|
|
return nil
|
|
}
|
|
ns.Valid = true
|
|
return ns.SubmissionStatus.Scan(value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (ns NullSubmissionStatus) Value() (driver.Value, error) {
|
|
if !ns.Valid {
|
|
return nil, nil
|
|
}
|
|
return string(ns.SubmissionStatus), nil
|
|
}
|
|
|
|
// Form contains all the data necesary to render a form
|
|
type Form struct {
|
|
ID int64 `json:"id"`
|
|
FormID *int64 `json:"form_id"`
|
|
// a namespace for the form
|
|
WorkspaceID string `json:"workspace_id"`
|
|
Name string `json:"name"`
|
|
// all form fields are serialized to JSON, see types.FormFields for structure details
|
|
Fields types.FormFields `json:"fields"`
|
|
Status FormStatus `json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// Respondants submit forms/fields to the collector as form_submissions
|
|
type FormSubmission struct {
|
|
ID int64 `json:"id"`
|
|
FormID *int64 `json:"form_id"`
|
|
WorkspaceID string `json:"workspace_id"`
|
|
// all form submissions are serialized to JSON, see types.FormFieldValue for structure details
|
|
Fields types.FormFieldValues `json:"fields"`
|
|
Status SubmissionStatus `json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// Short codes are short codes/names for URLs that identify the subject submitting a form
|
|
type ShortCode struct {
|
|
ID int64 `json:"id"`
|
|
WorkspaceID string `json:"workspace_id"`
|
|
FormID *int64 `json:"form_id"`
|
|
ShortCode string `json:"short_code"`
|
|
SubjectID string `json:"subject_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|