From 9e8ad7707c850cba42d27e9883e74250c349a918 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 9 Jan 2026 20:11:57 +0000
Subject: [PATCH 0001/1453] Bump vendor hash
---
default.nix | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/default.nix b/default.nix
index 43f460e0..bdfcb5c6 100644
--- a/default.nix
+++ b/default.nix
@@ -9,5 +9,5 @@ pkgs.buildGoModule rec {
subPackages = [];
version = "0.0.11";
# Needs to be updated after every modification of go.mod/go.sum
- vendorHash = "sha256-5E5gQJh2cr/XwDg+XRQEdXW7mkObZMoyqQnfToVuZ10=";
+ vendorHash = "sha256-fU0FPvuDC3rwQ4ygQYA3sH48o8PaK5VqqowwdUsVNaA=";
}
From f6127af058cbdb850b689736966d049c8d30db18 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 9 Jan 2026 20:25:13 +0000
Subject: [PATCH 0002/1453] Correctly copy uploaded files
---
public-report/photo-upload.go | 5 -----
1 file changed, 5 deletions(-)
diff --git a/public-report/photo-upload.go b/public-report/photo-upload.go
index 58846e09..6d40946f 100644
--- a/public-report/photo-upload.go
+++ b/public-report/photo-upload.go
@@ -3,7 +3,6 @@ package publicreport
import (
"bytes"
"fmt"
- "io"
"net/http"
"github.com/Gleipnir-Technology/nidus-sync/userfile"
@@ -40,10 +39,6 @@ func extractPhotoUploads(r *http.Request) (uploads []PhotoUpload, err error) {
return uploads, fmt.Errorf("Failed to read file: %v", err)
}
file.Seek(0, 0)
- contentBuf := bytes.NewBuffer(nil)
- if _, err := io.Copy(contentBuf, file); err != nil {
- return uploads, fmt.Errorf("Failed to save file: %v", err)
- }
log.Info().Int64("size", fileSize).Str("filename", headers.Filename).Str("content-type", contentType).Msg("Got an uploaded file")
u, err := uuid.NewUUID()
if err != nil {
From 4303534396e2ff8de60d0a09aedd479a8c2418b0 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 9 Jan 2026 21:02:30 +0000
Subject: [PATCH 0003/1453] Add logic for searching for a report and getting
the status.
---
db/sql/publicreport_publicid_table.bob.go | 112 +++++++++
db/sql/publicreport_publicid_table.bob.sql | 25 ++
db/sql/publicreport_publicid_table.sql | 22 ++
public-report/status.go | 266 +++++++++++++--------
public-report/template/status.html | 50 +++-
5 files changed, 376 insertions(+), 99 deletions(-)
create mode 100644 db/sql/publicreport_publicid_table.bob.go
create mode 100644 db/sql/publicreport_publicid_table.bob.sql
create mode 100644 db/sql/publicreport_publicid_table.sql
diff --git a/db/sql/publicreport_publicid_table.bob.go b/db/sql/publicreport_publicid_table.bob.go
new file mode 100644
index 00000000..9883cb40
--- /dev/null
+++ b/db/sql/publicreport_publicid_table.bob.go
@@ -0,0 +1,112 @@
+// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package sql
+
+import (
+ "context"
+ _ "embed"
+ "io"
+ "iter"
+
+ "github.com/lib/pq"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/scan"
+)
+
+//go:embed publicreport_publicid_table.bob.sql
+var formattedQueries_publicreport_publicid_table string
+
+var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[192:659]
+
+type PublicreportIDTableQuery = orm.ModQuery[*dialect.SelectQuery, publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer]
+
+func PublicreportIDTable(PublicID string) *PublicreportIDTableQuery {
+ var expressionTypArgs publicreportIDTable
+
+ expressionTypArgs.PublicID = psql.Arg(PublicID)
+
+ return &PublicreportIDTableQuery{
+ Query: orm.Query[publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer]{
+ ExecQuery: orm.ExecQuery[publicreportIDTable]{
+ BaseQuery: bob.BaseQuery[publicreportIDTable]{
+ Expression: expressionTypArgs,
+ Dialect: dialect.Dialect,
+ QueryType: bob.QueryTypeSelect,
+ },
+ },
+ Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (PublicreportIDTableRow, error)) {
+ return func(row *scan.Row) (any, error) {
+ var t PublicreportIDTableRow
+ row.ScheduleScanByIndex(0, &t.ExistsSomewhere)
+ row.ScheduleScanByIndex(1, &t.FoundInTables)
+ return &t, nil
+ }, func(v any) (PublicreportIDTableRow, error) {
+ return *(v.(*PublicreportIDTableRow)), nil
+ }
+ },
+ },
+ Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
+ q.AppendCTE(expressionTypArgs.subExpr(5, 335))
+ q.AppendSelect(expressionTypArgs.subExpr(348, 449))
+ q.SetTable(expressionTypArgs.subExpr(455, 467))
+ }),
+ }
+}
+
+type PublicreportIDTableRow = struct {
+ ExistsSomewhere bool `db:"exists_somewhere"`
+ FoundInTables pq.StringArray `db:"found_in_tables"`
+}
+
+type publicreportIDTableTransformer = bob.SliceTransformer[PublicreportIDTableRow, []PublicreportIDTableRow]
+
+type publicreportIDTable struct {
+ PublicID bob.Expression
+}
+
+func (o publicreportIDTable) args() iter.Seq[orm.ArgWithPosition] {
+ return func(yield func(arg orm.ArgWithPosition) bool) {
+ if !yield(orm.ArgWithPosition{
+ Name: "publicID",
+ Start: 112,
+ Stop: 114,
+ Expression: o.PublicID,
+ }) {
+ return
+ }
+
+ if !yield(orm.ArgWithPosition{
+ Name: "publicID",
+ Start: 221,
+ Stop: 223,
+ Expression: o.PublicID,
+ }) {
+ return
+ }
+
+ if !yield(orm.ArgWithPosition{
+ Name: "publicID",
+ Start: 331,
+ Stop: 333,
+ Expression: o.PublicID,
+ }) {
+ return
+ }
+ }
+}
+
+func (o publicreportIDTable) raw(from, to int) string {
+ return publicreportIDTableSQL[from:to]
+}
+
+func (o publicreportIDTable) subExpr(from, to int) bob.Expression {
+ return orm.ArgsToExpression(publicreportIDTableSQL, from, to, o.args())
+}
+
+func (o publicreportIDTable) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.subExpr(0, len(publicreportIDTableSQL)).WriteSQL(ctx, w, d, start)
+}
diff --git a/db/sql/publicreport_publicid_table.bob.sql b/db/sql/publicreport_publicid_table.bob.sql
new file mode 100644
index 00000000..8a6381d9
--- /dev/null
+++ b/db/sql/publicreport_publicid_table.bob.sql
@@ -0,0 +1,25 @@
+-- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- This file is meant to be re-generated in place and/or deleted at any time.
+
+-- PublicreportIDTable
+WITH found_tables AS (
+ SELECT 'nuisance' as table_name
+ FROM publicreport.nuisance
+ WHERE public_id = $1
+
+ UNION ALL
+
+ SELECT 'pool' as table_name
+ FROM publicreport.pool
+ WHERE public_id = $2
+
+ UNION ALL
+
+ SELECT 'quick' as table_name
+ FROM publicreport.quick
+ WHERE public_id = $3
+)
+SELECT
+ EXISTS (SELECT 1 FROM found_tables) as exists_somewhere,
+ array_agg(table_name) as found_in_tables
+FROM found_tables;
diff --git a/db/sql/publicreport_publicid_table.sql b/db/sql/publicreport_publicid_table.sql
new file mode 100644
index 00000000..6bf74029
--- /dev/null
+++ b/db/sql/publicreport_publicid_table.sql
@@ -0,0 +1,22 @@
+-- PublicreportIDTable
+WITH found_tables AS (
+ SELECT 'nuisance' as table_name
+ FROM publicreport.nuisance
+ WHERE public_id = $1
+
+ UNION ALL
+
+ SELECT 'pool' as table_name
+ FROM publicreport.pool
+ WHERE public_id = $1
+
+ UNION ALL
+
+ SELECT 'quick' as table_name
+ FROM publicreport.quick
+ WHERE public_id = $1
+)
+SELECT
+ EXISTS (SELECT 1 FROM found_tables) as exists_somewhere,
+ array_agg(table_name) as found_in_tables
+FROM found_tables;
diff --git a/public-report/status.go b/public-report/status.go
index 7b14a371..d00a8fc6 100644
--- a/public-report/status.go
+++ b/public-report/status.go
@@ -1,30 +1,36 @@
package publicreport
import (
+ "fmt"
"net/http"
+ "strings"
+ "github.com/Gleipnir-Technology/nidus-sync/db"
+ "github.com/Gleipnir-Technology/nidus-sync/db/sql"
"github.com/Gleipnir-Technology/nidus-sync/htmlpage"
"github.com/go-chi/chi/v5"
+ "github.com/rs/zerolog/log"
/*
- "fmt"
- "strconv"
- "time"
+ "strconv"
+ "time"
- "github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
- "github.com/Gleipnir-Technology/nidus-sync/h3utils"
- "github.com/aarondl/opt/omit"
- "github.com/aarondl/opt/omitnull"
- "github.com/rs/zerolog/log"
- "github.com/stephenafamo/bob/dialect/psql"
- "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/Gleipnir-Technology/nidus-sync/db"
+ "github.com/Gleipnir-Technology/nidus-sync/h3utils"
+ "github.com/aarondl/opt/omit"
+ "github.com/aarondl/opt/omitnull"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/um"
*/)
type Report struct {
ID string
}
-type ContextStatus struct{}
+type ContextStatus struct {
+ Error string
+ ReportID string
+}
type ContextStatusByID struct {
Report Report
}
@@ -34,11 +40,69 @@ var (
StatusByID = buildTemplate("status-by-id", "base")
)
+func formatReportID(s string) string {
+ // truncate down if too long
+ if len(s) > 12 {
+ s = s[:12]
+ }
+
+ // If less than 4 characters, return as is
+ if len(s) < 4 {
+ return s
+ }
+
+ // If at least 8 characters, add hyphens at positions 4 and 8
+ if len(s) >= 8 {
+ return s[0:4] + "-" + s[4:8] + "-" + s[8:]
+ }
+
+ // If at least 4 characters but less than 8, add hyphen only at position 4
+ return s[0:4] + "-" + s[4:]
+}
+
func getStatus(w http.ResponseWriter, r *http.Request) {
+ report_id_str := r.URL.Query().Get("report")
+ if report_id_str == "" {
+ htmlpage.RenderOrError(
+ w,
+ Status,
+ ContextStatus{
+ Error: "",
+ ReportID: "",
+ },
+ )
+ return
+ }
+ report_id := sanitizeReportID(report_id_str)
+ report_id_str = formatReportID(report_id)
+ results, err := sql.PublicreportIDTable(report_id).All(r.Context(), db.PGInstance.BobDB)
+ if err != nil {
+ respondError(w, "Failed to query for report", err, http.StatusInternalServerError)
+ return
+ }
+ if len(results) != 1 {
+ log.Error().Int("count", len(results)).Str("report_id", report_id_str).Msg("Got too many results for report id. This is a programmer error.")
+ htmlpage.RenderOrError(
+ w,
+ Status,
+ ContextStatus{
+ Error: "Sorry, server's confused",
+ ReportID: report_id_str,
+ },
+ )
+ }
+ result := results[0]
+ if result.ExistsSomewhere {
+ http.Redirect(w, r, fmt.Sprintf("/status/%s", report_id), http.StatusFound)
+ return
+ }
htmlpage.RenderOrError(
w,
Status,
- ContextStatus{},
+ ContextStatus{
+ Error: "Sorry, we can't find that report",
+ ReportID: report_id_str,
+ },
)
}
func getStatusByID(w http.ResponseWriter, r *http.Request) {
@@ -55,91 +119,103 @@ func getStatusByID(w http.ResponseWriter, r *http.Request) {
}
/*
-func getQuick(w http.ResponseWriter, r *http.Request) {
- htmlpage.RenderOrError(
- w,
- Quick,
- ContextQuick{},
- )
-}
-func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) {
- report := r.URL.Query().Get("report")
- htmlpage.RenderOrError(
- w,
- QuickSubmitComplete,
- ContextQuickSubmitComplete{
- ReportID: report,
- },
- )
-}
-func postQuick(w http.ResponseWriter, r *http.Request) {
- err := r.ParseMultipartForm(32 << 10) // 32 MB buffer
- if err != nil {
- respondError(w, "Failed to parse form", err, http.StatusBadRequest)
- return
+ func getQuick(w http.ResponseWriter, r *http.Request) {
+ htmlpage.RenderOrError(
+ w,
+ Quick,
+ ContextQuick{},
+ )
}
- lat := r.FormValue("latitude")
- lng := r.FormValue("longitude")
- comments := r.FormValue("comments")
- //photos := r.FormValue("photos")
- latitude, err := strconv.ParseFloat(lat, 64)
- if err != nil {
- respondError(w, "Failed to create parse latitude", err, http.StatusBadRequest)
- return
+ func getQuickSubmitComplete(w http.ResponseWriter, r *http.Request) {
+ report := r.URL.Query().Get("report")
+ htmlpage.RenderOrError(
+ w,
+ QuickSubmitComplete,
+ ContextQuickSubmitComplete{
+ ReportID: report,
+ },
+ )
}
- longitude, err := strconv.ParseFloat(lng, 64)
- if err != nil {
- respondError(w, "Failed to create parse longitude", err, http.StatusBadRequest)
- return
+
+ func postQuick(w http.ResponseWriter, r *http.Request) {
+ err := r.ParseMultipartForm(32 << 10) // 32 MB buffer
+ if err != nil {
+ respondError(w, "Failed to parse form", err, http.StatusBadRequest)
+ return
+ }
+ lat := r.FormValue("latitude")
+ lng := r.FormValue("longitude")
+ comments := r.FormValue("comments")
+ //photos := r.FormValue("photos")
+
+ latitude, err := strconv.ParseFloat(lat, 64)
+ if err != nil {
+ respondError(w, "Failed to create parse latitude", err, http.StatusBadRequest)
+ return
+ }
+ longitude, err := strconv.ParseFloat(lng, 64)
+ if err != nil {
+ respondError(w, "Failed to create parse longitude", err, http.StatusBadRequest)
+ return
+ }
+ u, err := GenerateReportID()
+ if err != nil {
+ respondError(w, "Failed to create quick report public ID", err, http.StatusInternalServerError)
+ return
+ }
+ c, err := h3utils.GetCell(longitude, latitude, 15)
+ setter := models.PublicreportQuickSetter{
+ Created: omit.From(time.Now()),
+ Comments: omit.From(comments),
+ //Location: omitnull.From(fmt.Sprintf("ST_GeometryFromText(Point(%s %s))", longitude, latitude)),
+ H3cell: omitnull.From(c.String()),
+ PublicID: omit.From(u),
+ ReporterEmail: omit.From(""),
+ ReporterPhone: omit.From(""),
+ }
+ quick, err := models.PublicreportQuicks.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
+ if err != nil {
+ respondError(w, "Failed to create database record", err, http.StatusInternalServerError)
+ return
+ }
+ _, err = psql.Update(
+ um.Table("publicreport.quick"),
+ um.SetCol("location").To(fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", longitude, latitude)),
+ um.Where(psql.Quote("id").EQ(psql.Arg(quick.ID))),
+ ).Exec(r.Context(), db.PGInstance.BobDB)
+ if err != nil {
+ respondError(w, "Failed to insert publicreport", err, http.StatusInternalServerError)
+ return
+ }
+ log.Info().Float64("latitude", latitude).Float64("longitude", longitude).Msg("Got upload")
+ photoSetters := make([]*models.PublicreportQuickPhotoSetter, 0)
+ uploads, err := extractPhotoUploads(r)
+ if err != nil {
+ respondError(w, "Failed to extract photo uploads", err, http.StatusInternalServerError)
+ return
+ }
+ for _, u := range uploads {
+ photoSetters = append(photoSetters, &models.PublicreportQuickPhotoSetter{
+ Filename: omit.From(u.Filename),
+ Size: omit.From(u.Size),
+ UUID: omit.From(u.UUID),
+ })
+ }
+ err = quick.InsertQuickPhotos(r.Context(), db.PGInstance.BobDB, photoSetters...)
+ if err != nil {
+ respondError(w, "Failed to create photo records", err, http.StatusInternalServerError)
+ return
+ }
+ http.Redirect(w, r, fmt.Sprintf("/quick-submit-complete?report=%s", u), http.StatusFound)
}
- u, err := GenerateReportID()
- if err != nil {
- respondError(w, "Failed to create quick report public ID", err, http.StatusInternalServerError)
- return
+*/
+func sanitizeReportID(r string) string {
+ result := ""
+ for _, char := range r {
+ if char != '-' {
+ result += string(char)
+ }
}
- c, err := h3utils.GetCell(longitude, latitude, 15)
- setter := models.PublicreportQuickSetter{
- Created: omit.From(time.Now()),
- Comments: omit.From(comments),
- //Location: omitnull.From(fmt.Sprintf("ST_GeometryFromText(Point(%s %s))", longitude, latitude)),
- H3cell: omitnull.From(c.String()),
- PublicID: omit.From(u),
- ReporterEmail: omit.From(""),
- ReporterPhone: omit.From(""),
- }
- quick, err := models.PublicreportQuicks.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
- if err != nil {
- respondError(w, "Failed to create database record", err, http.StatusInternalServerError)
- return
- }
- _, err = psql.Update(
- um.Table("publicreport.quick"),
- um.SetCol("location").To(fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", longitude, latitude)),
- um.Where(psql.Quote("id").EQ(psql.Arg(quick.ID))),
- ).Exec(r.Context(), db.PGInstance.BobDB)
- if err != nil {
- respondError(w, "Failed to insert publicreport", err, http.StatusInternalServerError)
- return
- }
- log.Info().Float64("latitude", latitude).Float64("longitude", longitude).Msg("Got upload")
- photoSetters := make([]*models.PublicreportQuickPhotoSetter, 0)
- uploads, err := extractPhotoUploads(r)
- if err != nil {
- respondError(w, "Failed to extract photo uploads", err, http.StatusInternalServerError)
- return
- }
- for _, u := range uploads {
- photoSetters = append(photoSetters, &models.PublicreportQuickPhotoSetter{
- Filename: omit.From(u.Filename),
- Size: omit.From(u.Size),
- UUID: omit.From(u.UUID),
- })
- }
- err = quick.InsertQuickPhotos(r.Context(), db.PGInstance.BobDB, photoSetters...)
- if err != nil {
- respondError(w, "Failed to create photo records", err, http.StatusInternalServerError)
- return
- }
- http.Redirect(w, r, fmt.Sprintf("/quick-submit-complete?report=%s", u), http.StatusFound)
-}*/
+ return strings.ToUpper(result)
+}
diff --git a/public-report/template/status.html b/public-report/template/status.html
index 8e8a0b52..b1dfcf18 100644
--- a/public-report/template/status.html
+++ b/public-report/template/status.html
@@ -35,6 +35,43 @@
}
}
+
{{end}}
{{define "content"}}
@@ -72,14 +109,19 @@
If you have a report ID from a previous request, enter it below to view the details and current status.
-
From 75454834f470619986bd9d2c6139c7e70cc04880 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 9 Jan 2026 21:31:45 +0000
Subject: [PATCH 0004/1453] Add mock of report search page
---
public-report/routes.go | 1 +
public-report/search.go | 21 +++
public-report/template/search.html | 190 +++++++++++++++++++++++
public-report/template/status-by-id.html | 162 +++++++++----------
public-report/template/status.html | 4 +-
5 files changed, 296 insertions(+), 82 deletions(-)
create mode 100644 public-report/search.go
create mode 100644 public-report/template/search.html
diff --git a/public-report/routes.go b/public-report/routes.go
index a0a55bb6..cb46b135 100644
--- a/public-report/routes.go
+++ b/public-report/routes.go
@@ -21,6 +21,7 @@ func Router() chi.Router {
r.Get("/quick-submit-complete", getQuickSubmitComplete)
r.Post("/register-notifications", postRegisterNotifications)
r.Get("/register-notifications-complete", getRegisterNotificationsComplete)
+ r.Get("/search", getSearch)
r.Get("/status", getStatus)
r.Get("/status/{report_id}", getStatusByID)
localFS := http.Dir("./static")
diff --git a/public-report/search.go b/public-report/search.go
new file mode 100644
index 00000000..ad8497f3
--- /dev/null
+++ b/public-report/search.go
@@ -0,0 +1,21 @@
+package publicreport
+
+import (
+ "net/http"
+
+ "github.com/Gleipnir-Technology/nidus-sync/htmlpage"
+)
+
+type ContextSearch struct{}
+
+var (
+ Search = buildTemplate("search", "base")
+)
+
+func getSearch(w http.ResponseWriter, r *http.Request) {
+ htmlpage.RenderOrError(
+ w,
+ Search,
+ ContextSearch{},
+ )
+}
diff --git a/public-report/template/search.html b/public-report/template/search.html
new file mode 100644
index 00000000..825ad946
--- /dev/null
+++ b/public-report/template/search.html
@@ -0,0 +1,190 @@
+{{template "base.html" .}}
+
+{{define "title"}}Status{{end}}
+{{define "extraheader"}}
+
+
+{{end}}
+{{define "content"}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Report ID
+ Reported
+ Type
+ Address
+ Status
+
+
+
+
+
+ #12345
+ 2 days ago
+ Mosquito Nuisance
+ 456 Elm Street, Anytown, USA
+ Scheduled
+
+
+ #12346
+ 3 days ago
+ Green Pool
+ 789 Oak Avenue, Anytown, USA
+ Treated
+
+
+ #12347
+ 1 week ago
+ Mosquito Nuisance
+ 123 Pine Road, Anytown, USA
+ Visited
+
+
+ #12348
+ 1 day ago
+ Quick Report
+ 567 Maple Lane, Anytown, USA
+ In Review
+
+
+ #12349
+ 2 weeks ago
+ Green Pool
+ 890 Cedar Court, Anytown, USA
+ Treated
+
+
+ #12350
+ 5 days ago
+ Mosquito Nuisance
+ 234 Birch Blvd, Anytown, USA
+ Scheduled
+
+
+ #12351
+ 3 hours ago
+ Quick Report
+ 678 Spruce Street, Anytown, USA
+ In Review
+
+
+
+
+
+
+
+
+
+
+
+ Create New Report
+
+
+
+
+
+
+ Create New Report
+
+
+
+{{end}}
diff --git a/public-report/template/status-by-id.html b/public-report/template/status-by-id.html
index 73bf8dac..d42d65cd 100644
--- a/public-report/template/status-by-id.html
+++ b/public-report/template/status-by-id.html
@@ -40,98 +40,100 @@
{{end}}
{{define "content"}}
-
-
-
-
-
-
- Created:
- July 15, 2023 - 9:30 AM
-
-
- Last Updated:
- July 17, 2023 - 2:45 PM
-
-
-
Next Step:
-
July 19, 2023 (Estimated)
+
+
+
+
+
+
+
+ Created:
+ July 15, 2023 - 9:30 AM
+
+
+ Last Updated:
+ July 17, 2023 - 2:45 PM
+
+
+ Next Step:
+ July 19, 2023 (Estimated)
+
-
-
-
-
-
-
From 21a8f9622a572e584965393a9aacb70b9612e50c Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 21:36:58 +0000
Subject: [PATCH 0026/1453] Avoid empty insert statement when there are no
aggregations
---
background/arcgis.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/background/arcgis.go b/background/arcgis.go
index 6237ccef..6997a2ec 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -1075,6 +1075,10 @@ func updateSummaryTables(ctx context.Context, org *models.Organization) {
im.SetCol("count_").To(psql.Raw("EXCLUDED.count_")),
))
//log.Info().Str("sql", insertQueryToString(psql.Insert(to_insert...))).Msg("Updating...")
+ if len(to_insert) == 0 {
+ log.Info().Int("resolution", i).Msg("No updates to perform")
+ continue
+ }
_, err := psql.Insert(to_insert...).Exec(ctx, db.PGInstance.BobDB)
if err != nil {
log.Error().Err(err).Msg("Faild to add h3 aggregation")
From 4f0b73c769a2dce7bbdc11704606f84cf6f9fde0 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 21:39:58 +0000
Subject: [PATCH 0027/1453] Add URL for Tegola to configuration
Avoid cross-environment pollution.
---
config/config.go | 6 +++++-
sync/dash.go | 8 ++++++++
sync/template/dashboard.html | 6 ++----
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/config/config.go b/config/config.go
index 94184e6a..1b6ac507 100644
--- a/config/config.go
+++ b/config/config.go
@@ -7,7 +7,7 @@ import (
"strconv"
)
-var Bind, ClientID, ClientSecret, Environment, FieldseekerSchemaDirectory, MapboxToken, PGDSN, URLReport, URLSync, FilesDirectoryPublic, FilesDirectoryUser string
+var Bind, ClientID, ClientSecret, Environment, FilesDirectoryPublic, FilesDirectoryUser, FieldseekerSchemaDirectory, MapboxToken, PGDSN, URLReport, URLSync, URLTegola string
// Build the ArcGIS authorization URL with PKCE
func BuildArcGISAuthURL(clientID string) string {
@@ -59,6 +59,10 @@ func Parse() error {
if URLSync == "" {
return fmt.Errorf("You must specify a non-empty URL_SYNC")
}
+ URLTegola = os.Getenv("URL_TEGOLA")
+ if URLTegola == "" {
+ return fmt.Errorf("You must specify a non-empty URL_TEGOLA")
+ }
Bind = os.Getenv("BIND")
if Bind == "" {
Bind = ":9001"
diff --git a/sync/dash.go b/sync/dash.go
index ae855655..e66a2fe0 100644
--- a/sync/dash.go
+++ b/sync/dash.go
@@ -29,7 +29,12 @@ var (
sourceT = buildTemplate("source", "authenticated")
)
+type Config struct {
+ URLTegola string
+}
+
type ContextDashboard struct {
+ Config Config
CountInspections int
CountMosquitoSources int
CountServiceRequests int
@@ -233,6 +238,9 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
return
}
data := ContextDashboard{
+ Config: Config{
+ URLTegola: config.URLTegola,
+ },
CountInspections: int(inspectionCount),
CountMosquitoSources: int(sourceCount),
CountServiceRequests: int(serviceCount),
diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html
index 36347afd..4dbb7ceb 100644
--- a/sync/template/dashboard.html
+++ b/sync/template/dashboard.html
@@ -20,8 +20,7 @@ function onLoad() {
map.addSource('tegola-bonn', {
'type': 'vector',
'tiles': [
- //'https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=MLY|4142433049200173|72206abe5035850d6743b23a49c41333'
- 'https://tegola.nidus.cloud/maps/bonn/{z}/{x}/{y}'
+ 'https://{{.Config.URLTegola}}/maps/bonn/{z}/{x}/{y}'
]
//'minzoom': 6,
//'maxzoom': 14
@@ -29,8 +28,7 @@ function onLoad() {
map.addSource('tegola-nidus', {
'type': 'vector',
'tiles': [
- //'https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=MLY|4142433049200173|72206abe5035850d6743b23a49c41333'
- 'https://tegola.nidus.cloud/maps/nidus/{z}/{x}/{y}?organization_id=1'
+ 'https://{{.Config.URLTegola}}/maps/nidus/{z}/{x}/{y}?organization_id={{.User.OrganizationID}}'
]
//'minzoom': 6,
//'maxzoom': 14
From a4c0e367a8bba90ca7a0251a7a08f5f94b6f7ffb Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 21:49:12 +0000
Subject: [PATCH 0028/1453] Make organization.name not-nullable, consolidate
org in dash context
---
auth/auth.go | 2 +-
db/dbinfo/district.bob.go | 12 +++-
db/dbinfo/organization.bob.go | 4 +-
db/factory/bobfactory_main.bob.go | 3 +-
db/factory/district.bob.go | 58 +++++++++++++++++++
db/factory/organization.bob.go | 40 ++++---------
.../00030_organization_name_not_null.sql | 5 ++
db/models/district.bob.go | 7 ++-
db/models/organization.bob.go | 20 +++----
sync/dash.go | 2 -
sync/template/dashboard.html | 4 +-
sync/types.go | 6 +-
sync/utils.go | 5 ++
13 files changed, 118 insertions(+), 50 deletions(-)
create mode 100644 db/migrations/00030_organization_name_not_null.sql
diff --git a/auth/auth.go b/auth/auth.go
index 24a372fc..83a6feee 100644
--- a/auth/auth.go
+++ b/auth/auth.go
@@ -131,7 +131,7 @@ func SignupUser(ctx context.Context, username string, name string, password stri
return nil, fmt.Errorf("Cannot signup user, failed to create hashed password: %w", err)
}
o_setter := models.OrganizationSetter{
- Name: omitnull.From(fmt.Sprintf("%s's organization", username)),
+ Name: omit.From(fmt.Sprintf("%s's organization", username)),
ArcgisID: omitnull.From(""),
ArcgisName: omitnull.From(""),
FieldseekerURL: omitnull.From(""),
diff --git a/db/dbinfo/district.bob.go b/db/dbinfo/district.bob.go
index bedd3bf0..11976f13 100644
--- a/db/dbinfo/district.bob.go
+++ b/db/dbinfo/district.bob.go
@@ -213,6 +213,15 @@ var Districts = Table[
Generated: false,
AutoIncr: false,
},
+ Geom4326: column{
+ Name: "geom_4326",
+ DBType: "geometry",
+ Default: "GENERATED",
+ Comment: "",
+ Nullable: true,
+ Generated: true,
+ AutoIncr: false,
+ },
},
Indexes: districtIndexes{
DistrictPkey: index{
@@ -282,11 +291,12 @@ type districtColumns struct {
ShapeLe1 column
ShapeArea column
Geom column
+ Geom4326 column
}
func (c districtColumns) AsSlice() []column {
return []column{
- c.Gid, c.ID, c.Website, c.Contact, c.Address, c.Regionid, c.PostalCod, c.Phone1, c.Fax1, c.Agency, c.Code1, c.City1, c.ShapeLeng, c.Address2, c.GeneralMG, c.City2, c.PostalC1, c.Fax2, c.Phone2, c.ShapeLe1, c.ShapeArea, c.Geom,
+ c.Gid, c.ID, c.Website, c.Contact, c.Address, c.Regionid, c.PostalCod, c.Phone1, c.Fax1, c.Agency, c.Code1, c.City1, c.ShapeLeng, c.Address2, c.GeneralMG, c.City2, c.PostalC1, c.Fax2, c.Phone2, c.ShapeLe1, c.ShapeArea, c.Geom, c.Geom4326,
}
}
diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go
index 7b707d42..c65f22a4 100644
--- a/db/dbinfo/organization.bob.go
+++ b/db/dbinfo/organization.bob.go
@@ -27,9 +27,9 @@ var Organizations = Table[
Name: column{
Name: "name",
DBType: "text",
- Default: "NULL",
+ Default: "",
Comment: "",
- Nullable: true,
+ Nullable: false,
Generated: false,
AutoIncr: false,
},
diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go
index 02a1eb5f..cae5658a 100644
--- a/db/factory/bobfactory_main.bob.go
+++ b/db/factory/bobfactory_main.bob.go
@@ -118,6 +118,7 @@ func (f *Factory) FromExistingDistrict(m *models.District) *DistrictTemplate {
o.ShapeLe1 = func() null.Val[decimal.Decimal] { return m.ShapeLe1 }
o.ShapeArea = func() null.Val[decimal.Decimal] { return m.ShapeArea }
o.Geom = func() null.Val[string] { return m.Geom }
+ o.Geom4326 = func() null.Val[string] { return m.Geom4326 }
return o
}
@@ -2317,7 +2318,7 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
o := &OrganizationTemplate{f: f, alreadyPersisted: true}
o.ID = func() int32 { return m.ID }
- o.Name = func() null.Val[string] { return m.Name }
+ o.Name = func() string { return m.Name }
o.ArcgisID = func() null.Val[string] { return m.ArcgisID }
o.ArcgisName = func() null.Val[string] { return m.ArcgisName }
o.FieldseekerURL = func() null.Val[string] { return m.FieldseekerURL }
diff --git a/db/factory/district.bob.go b/db/factory/district.bob.go
index 5f8f5c01..4a25435f 100644
--- a/db/factory/district.bob.go
+++ b/db/factory/district.bob.go
@@ -59,6 +59,7 @@ type DistrictTemplate struct {
ShapeLe1 func() null.Val[decimal.Decimal]
ShapeArea func() null.Val[decimal.Decimal]
Geom func() null.Val[string]
+ Geom4326 func() null.Val[string]
f *Factory
@@ -257,6 +258,9 @@ func (o DistrictTemplate) Build() *models.District {
if o.Geom != nil {
m.Geom = o.Geom()
}
+ if o.Geom4326 != nil {
+ m.Geom4326 = o.Geom4326()
+ }
o.setModelRels(m)
@@ -399,6 +403,7 @@ func (m districtMods) RandomizeAllColumns(f *faker.Faker) DistrictMod {
DistrictMods.RandomShapeLe1(f),
DistrictMods.RandomShapeArea(f),
DistrictMods.RandomGeom(f),
+ DistrictMods.RandomGeom4326(f),
}
}
@@ -1546,6 +1551,59 @@ func (m districtMods) RandomGeomNotNull(f *faker.Faker) DistrictMod {
})
}
+// Set the model columns to this value
+func (m districtMods) Geom4326(val null.Val[string]) DistrictMod {
+ return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+ o.Geom4326 = func() null.Val[string] { return val }
+ })
+}
+
+// Set the Column from the function
+func (m districtMods) Geom4326Func(f func() null.Val[string]) DistrictMod {
+ return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+ o.Geom4326 = f
+ })
+}
+
+// Clear any values for the column
+func (m districtMods) UnsetGeom4326() DistrictMod {
+ return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+ o.Geom4326 = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is sometimes null
+func (m districtMods) RandomGeom4326(f *faker.Faker) DistrictMod {
+ return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+ o.Geom4326 = func() null.Val[string] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_string(f)
+ return null.From(val)
+ }
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is never null
+func (m districtMods) RandomGeom4326NotNull(f *faker.Faker) DistrictMod {
+ return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+ o.Geom4326 = func() null.Val[string] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_string(f)
+ return null.From(val)
+ }
+ })
+}
+
func (m districtMods) WithParentsCascading() DistrictMod {
return DistrictModFunc(func(ctx context.Context, o *DistrictTemplate) {
if isDone, _ := districtWithParentsCascadingCtx.Value(ctx); isDone {
diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go
index 79f6a071..f7567bd7 100644
--- a/db/factory/organization.bob.go
+++ b/db/factory/organization.bob.go
@@ -37,7 +37,7 @@ func (mods OrganizationModSlice) Apply(ctx context.Context, n *OrganizationTempl
// all columns are optional and should be set by mods
type OrganizationTemplate struct {
ID func() int32
- Name func() null.Val[string]
+ Name func() string
ArcgisID func() null.Val[string]
ArcgisName func() null.Val[string]
FieldseekerURL func() null.Val[string]
@@ -650,7 +650,7 @@ func (o OrganizationTemplate) BuildSetter() *models.OrganizationSetter {
}
if o.Name != nil {
val := o.Name()
- m.Name = omitnull.FromNull(val)
+ m.Name = omit.From(val)
}
if o.ArcgisID != nil {
val := o.ArcgisID()
@@ -721,6 +721,10 @@ func (o OrganizationTemplate) BuildMany(number int) models.OrganizationSlice {
}
func ensureCreatableOrganization(m *models.OrganizationSetter) {
+ if !(m.Name.IsValue()) {
+ val := random_string(nil)
+ m.Name = omit.From(val)
+ }
}
// insertOptRels creates and inserts any optional the relationships on *models.Organization
@@ -1501,14 +1505,14 @@ func (m organizationMods) RandomID(f *faker.Faker) OrganizationMod {
}
// Set the model columns to this value
-func (m organizationMods) Name(val null.Val[string]) OrganizationMod {
+func (m organizationMods) Name(val string) OrganizationMod {
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
- o.Name = func() null.Val[string] { return val }
+ o.Name = func() string { return val }
})
}
// Set the Column from the function
-func (m organizationMods) NameFunc(f func() null.Val[string]) OrganizationMod {
+func (m organizationMods) NameFunc(f func() string) OrganizationMod {
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
o.Name = f
})
@@ -1523,32 +1527,10 @@ func (m organizationMods) UnsetName() OrganizationMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
-// The generated value is sometimes null
func (m organizationMods) RandomName(f *faker.Faker) OrganizationMod {
return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
- o.Name = func() null.Val[string] {
- if f == nil {
- f = &defaultFaker
- }
-
- val := random_string(f)
- return null.From(val)
- }
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-// The generated value is never null
-func (m organizationMods) RandomNameNotNull(f *faker.Faker) OrganizationMod {
- return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
- o.Name = func() null.Val[string] {
- if f == nil {
- f = &defaultFaker
- }
-
- val := random_string(f)
- return null.From(val)
+ o.Name = func() string {
+ return random_string(f)
}
})
}
diff --git a/db/migrations/00030_organization_name_not_null.sql b/db/migrations/00030_organization_name_not_null.sql
new file mode 100644
index 00000000..eecf7b98
--- /dev/null
+++ b/db/migrations/00030_organization_name_not_null.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE organization ALTER COLUMN name SET NOT NULL;
+
+-- +goose Down
+ALTER TABLE organization ALTER COLUMN name DROP NOT NULL;
diff --git a/db/models/district.bob.go b/db/models/district.bob.go
index 851dfcd2..026f4c47 100644
--- a/db/models/district.bob.go
+++ b/db/models/district.bob.go
@@ -44,6 +44,7 @@ type District struct {
ShapeLe1 null.Val[decimal.Decimal] `db:"shape_le_1" `
ShapeArea null.Val[decimal.Decimal] `db:"shape_area" `
Geom null.Val[string] `db:"geom" `
+ Geom4326 null.Val[string] `db:"geom_4326,generated" `
}
// DistrictSlice is an alias for a slice of pointers to District.
@@ -59,7 +60,7 @@ type DistrictsQuery = *psql.ViewQuery[*District, DistrictSlice]
func buildDistrictColumns(alias string) districtColumns {
return districtColumns{
ColumnsExpr: expr.NewColumnsExpr(
- "gid", "id", "website", "contact", "address", "regionid", "postal_cod", "phone1", "fax1", "agency", "code1", "city1", "shape_leng", "address2", "general_mg", "city2", "postal_c_1", "fax2", "phone2", "shape_le_1", "shape_area", "geom",
+ "gid", "id", "website", "contact", "address", "regionid", "postal_cod", "phone1", "fax1", "agency", "code1", "city1", "shape_leng", "address2", "general_mg", "city2", "postal_c_1", "fax2", "phone2", "shape_le_1", "shape_area", "geom", "geom_4326",
).WithParent("district"),
tableAlias: alias,
Gid: psql.Quote(alias, "gid"),
@@ -84,6 +85,7 @@ func buildDistrictColumns(alias string) districtColumns {
ShapeLe1: psql.Quote(alias, "shape_le_1"),
ShapeArea: psql.Quote(alias, "shape_area"),
Geom: psql.Quote(alias, "geom"),
+ Geom4326: psql.Quote(alias, "geom_4326"),
}
}
@@ -112,6 +114,7 @@ type districtColumns struct {
ShapeLe1 psql.Expression
ShapeArea psql.Expression
Geom psql.Expression
+ Geom4326 psql.Expression
}
func (c districtColumns) Alias() string {
@@ -842,6 +845,7 @@ type districtWhere[Q psql.Filterable] struct {
ShapeLe1 psql.WhereNullMod[Q, decimal.Decimal]
ShapeArea psql.WhereNullMod[Q, decimal.Decimal]
Geom psql.WhereNullMod[Q, string]
+ Geom4326 psql.WhereNullMod[Q, string]
}
func (districtWhere[Q]) AliasedAs(alias string) districtWhere[Q] {
@@ -872,5 +876,6 @@ func buildDistrictWhere[Q psql.Filterable](cols districtColumns) districtWhere[Q
ShapeLe1: psql.WhereNull[Q, decimal.Decimal](cols.ShapeLe1),
ShapeArea: psql.WhereNull[Q, decimal.Decimal](cols.ShapeArea),
Geom: psql.WhereNull[Q, string](cols.Geom),
+ Geom4326: psql.WhereNull[Q, string](cols.Geom4326),
}
}
diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go
index 1139d02c..f9bfcc28 100644
--- a/db/models/organization.bob.go
+++ b/db/models/organization.bob.go
@@ -26,7 +26,7 @@ import (
// Organization is an object representing the database table.
type Organization struct {
ID int32 `db:"id,pk" `
- Name null.Val[string] `db:"name" `
+ Name string `db:"name" `
ArcgisID null.Val[string] `db:"arcgis_id" `
ArcgisName null.Val[string] `db:"arcgis_name" `
FieldseekerURL null.Val[string] `db:"fieldseeker_url" `
@@ -117,7 +117,7 @@ func (organizationColumns) AliasedAs(alias string) organizationColumns {
// Generated columns are not included
type OrganizationSetter struct {
ID omit.Val[int32] `db:"id,pk" `
- Name omitnull.Val[string] `db:"name" `
+ Name omit.Val[string] `db:"name" `
ArcgisID omitnull.Val[string] `db:"arcgis_id" `
ArcgisName omitnull.Val[string] `db:"arcgis_name" `
FieldseekerURL omitnull.Val[string] `db:"fieldseeker_url" `
@@ -128,7 +128,7 @@ func (s OrganizationSetter) SetColumns() []string {
if s.ID.IsValue() {
vals = append(vals, "id")
}
- if !s.Name.IsUnset() {
+ if s.Name.IsValue() {
vals = append(vals, "name")
}
if !s.ArcgisID.IsUnset() {
@@ -147,8 +147,8 @@ func (s OrganizationSetter) Overwrite(t *Organization) {
if s.ID.IsValue() {
t.ID = s.ID.MustGet()
}
- if !s.Name.IsUnset() {
- t.Name = s.Name.MustGetNull()
+ if s.Name.IsValue() {
+ t.Name = s.Name.MustGet()
}
if !s.ArcgisID.IsUnset() {
t.ArcgisID = s.ArcgisID.MustGetNull()
@@ -174,8 +174,8 @@ func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) {
vals[0] = psql.Raw("DEFAULT")
}
- if !s.Name.IsUnset() {
- vals[1] = psql.Arg(s.Name.MustGetNull())
+ if s.Name.IsValue() {
+ vals[1] = psql.Arg(s.Name.MustGet())
} else {
vals[1] = psql.Raw("DEFAULT")
}
@@ -216,7 +216,7 @@ func (s OrganizationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
- if !s.Name.IsUnset() {
+ if s.Name.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "name")...),
psql.Arg(s.Name),
@@ -3416,7 +3416,7 @@ func (organization0 *Organization) AttachUser(ctx context.Context, exec bob.Exec
type organizationWhere[Q psql.Filterable] struct {
ID psql.WhereMod[Q, int32]
- Name psql.WhereNullMod[Q, string]
+ Name psql.WhereMod[Q, string]
ArcgisID psql.WhereNullMod[Q, string]
ArcgisName psql.WhereNullMod[Q, string]
FieldseekerURL psql.WhereNullMod[Q, string]
@@ -3429,7 +3429,7 @@ func (organizationWhere[Q]) AliasedAs(alias string) organizationWhere[Q] {
func buildOrganizationWhere[Q psql.Filterable](cols organizationColumns) organizationWhere[Q] {
return organizationWhere[Q]{
ID: psql.Where[Q, int32](cols.ID),
- Name: psql.WhereNull[Q, string](cols.Name),
+ Name: psql.Where[Q, string](cols.Name),
ArcgisID: psql.WhereNull[Q, string](cols.ArcgisID),
ArcgisName: psql.WhereNull[Q, string](cols.ArcgisName),
FieldseekerURL: psql.WhereNull[Q, string](cols.FieldseekerURL),
diff --git a/sync/dash.go b/sync/dash.go
index e66a2fe0..227f4b19 100644
--- a/sync/dash.go
+++ b/sync/dash.go
@@ -42,7 +42,6 @@ type ContextDashboard struct {
IsSyncOngoing bool
LastSync *time.Time
MapData ComponentMap
- Org string
RecentRequests []ServiceRequestSummary
User User
}
@@ -249,7 +248,6 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
MapData: ComponentMap{
MapboxToken: config.MapboxToken,
},
- Org: org.Name.MustGet(),
RecentRequests: requests,
User: userContent,
}
diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html
index 4dbb7ceb..60920964 100644
--- a/sync/template/dashboard.html
+++ b/sync/template/dashboard.html
@@ -28,7 +28,7 @@ function onLoad() {
map.addSource('tegola-nidus', {
'type': 'vector',
'tiles': [
- 'https://{{.Config.URLTegola}}/maps/nidus/{z}/{x}/{y}?organization_id={{.User.OrganizationID}}'
+ 'https://{{.Config.URLTegola}}/maps/nidus/{z}/{x}/{y}?organization_id={{.User.Organization.ID}}'
]
//'minzoom': 6,
//'maxzoom': 14
@@ -172,7 +172,7 @@ body {
-
{{ .Org }} Dashboard
+
{{ .User.Organization.Name }} Dashboard
Overview of mosquito control activities in your district
diff --git a/sync/types.go b/sync/types.go
index 8bcd0300..b8435495 100644
--- a/sync/types.go
+++ b/sync/types.go
@@ -94,6 +94,10 @@ type Link struct {
Href string
Title string
}
+type Organization struct {
+ ID int
+ Name string
+}
type ServiceRequestSummary struct {
Date time.Time
Location string
@@ -103,6 +107,6 @@ type User struct {
DisplayName string
Initials string
Notifications []notification.Notification
- OrganizationID int
+ Organization Organization
Username string
}
diff --git a/sync/utils.go b/sync/utils.go
index 827bfe44..45c0d23b 100644
--- a/sync/utils.go
+++ b/sync/utils.go
@@ -95,10 +95,15 @@ func contentForUser(ctx context.Context, user *models.User) (User, error) {
if err != nil {
return User{}, err
}
+ org := user.R.Organization
return User{
DisplayName: user.DisplayName,
Initials: extractInitials(user.DisplayName),
Notifications: notifications,
+ Organization: Organization {
+ ID: int(org.ID),
+ Name: org.Name,
+ },
Username: user.Username,
}, nil
From cd22818240455cde8acc3010ce03f724bc3e2c7e Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 21:52:36 +0000
Subject: [PATCH 0029/1453] Actually exit early on empty aggregate
Previous attempt was subtly wrong.
---
background/arcgis.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/background/arcgis.go b/background/arcgis.go
index 6997a2ec..6a32ec53 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -1039,6 +1039,10 @@ func updateSummaryTables(ctx context.Context, org *models.Organization) {
log.Error().Err(err).Msg("Failed to get organization")
return
}
+ if len(point_locations) == 0 {
+ log.Info().Int("org_id", int(org.ID)).Msg("No updates to perform")
+ return
+ }
log.Info().Int("count", len(point_locations)).Msg("Summarizing point locations")
for i := range 16 {
@@ -1075,10 +1079,6 @@ func updateSummaryTables(ctx context.Context, org *models.Organization) {
im.SetCol("count_").To(psql.Raw("EXCLUDED.count_")),
))
//log.Info().Str("sql", insertQueryToString(psql.Insert(to_insert...))).Msg("Updating...")
- if len(to_insert) == 0 {
- log.Info().Int("resolution", i).Msg("No updates to perform")
- continue
- }
_, err := psql.Insert(to_insert...).Exec(ctx, db.PGInstance.BobDB)
if err != nil {
log.Error().Err(err).Msg("Faild to add h3 aggregation")
From c44fe26cdf226a8c8e112159238bc96dfcc92f78 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 21:52:59 +0000
Subject: [PATCH 0030/1453] Remove debugging bonn layers
---
sync/template/dashboard.html | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html
index 60920964..420b521d 100644
--- a/sync/template/dashboard.html
+++ b/sync/template/dashboard.html
@@ -17,14 +17,6 @@ function onLoad() {
});
map.on("load", function() {
console.log("Map post-load...");
- map.addSource('tegola-bonn', {
- 'type': 'vector',
- 'tiles': [
- 'https://{{.Config.URLTegola}}/maps/bonn/{z}/{x}/{y}'
- ]
- //'minzoom': 6,
- //'maxzoom': 14
- });
map.addSource('tegola-nidus', {
'type': 'vector',
'tiles': [
@@ -33,17 +25,6 @@ function onLoad() {
//'minzoom': 6,
//'maxzoom': 14
});
- map.addLayer({
- 'id': 'bonn', // Layer ID
- 'type': 'fill',
- 'source': 'tegola-bonn', // ID of the tile source created above
- 'source-layer': 'lakes',
- 'paint': {
- 'fill-opacity': 0.1,
- 'fill-color': 'rgb(100, 50, 20)'
- }
- //slot: 'middle' // middle slot in Mapbox Standard style
- });
map.addLayer({
'id': 'nidus', // Layer ID
'type': 'fill',
From 35721e7fa678e01281cff8cb588a760bd6ae9c8b Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Wed, 14 Jan 2026 22:18:11 +0000
Subject: [PATCH 0031/1453] Add some handy tools
---
tools/README.md | 7 ++++++
tools/delete-all-fieldseeker.sql | 26 ++++++++++++++++++++
tools/delete-org.sql | 41 ++++++++++++++++++++++++++++++++
3 files changed, 74 insertions(+)
create mode 100644 tools/README.md
create mode 100644 tools/delete-all-fieldseeker.sql
create mode 100644 tools/delete-org.sql
diff --git a/tools/README.md b/tools/README.md
new file mode 100644
index 00000000..a6adf6c9
--- /dev/null
+++ b/tools/README.md
@@ -0,0 +1,7 @@
+# Tools
+
+Useful for doing one-off developer types of work. Can be run with:
+
+```
+psql -d nidus-sync -v org_id=3 -f tools/delete-org.sql
+```
diff --git a/tools/delete-all-fieldseeker.sql b/tools/delete-all-fieldseeker.sql
new file mode 100644
index 00000000..0f7a5391
--- /dev/null
+++ b/tools/delete-all-fieldseeker.sql
@@ -0,0 +1,26 @@
+TRUNCATE fieldseeker.containerrelate;
+TRUNCATE fieldseeker.fieldscoutinglog;
+TRUNCATE fieldseeker.habitatrelate;
+TRUNCATE fieldseeker.inspectionsample;
+TRUNCATE fieldseeker.inspectionsampledetail;
+TRUNCATE fieldseeker.linelocation;
+TRUNCATE fieldseeker.locationtracking;
+TRUNCATE fieldseeker.mosquitoinspection;
+TRUNCATE fieldseeker.pointlocation;
+TRUNCATE fieldseeker.polygonlocation;
+TRUNCATE fieldseeker.pool;
+TRUNCATE fieldseeker.pooldetail;
+TRUNCATE fieldseeker.proposedtreatmentarea;
+TRUNCATE fieldseeker.qamosquitoinspection;
+TRUNCATE fieldseeker.rodentlocation;
+TRUNCATE fieldseeker.samplecollection;
+TRUNCATE fieldseeker.samplelocation;
+TRUNCATE fieldseeker.servicerequest;
+TRUNCATE fieldseeker.speciesabundance;
+TRUNCATE fieldseeker.stormdrain;
+TRUNCATE fieldseeker.timecard;
+TRUNCATE fieldseeker.trapdata;
+TRUNCATE fieldseeker.traplocation;
+TRUNCATE fieldseeker.treatment;
+TRUNCATE fieldseeker.treatmentarea;
+TRUNCATE fieldseeker.zones;
diff --git a/tools/delete-org.sql b/tools/delete-org.sql
new file mode 100644
index 00000000..6bc09998
--- /dev/null
+++ b/tools/delete-org.sql
@@ -0,0 +1,41 @@
+-- delete-org.sql
+BEGIN;
+ DELETE FROM public.oauth_token WHERE user_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.notification WHERE user_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.note_audio WHERE creator_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.note_audio WHERE deletor_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.note_image WHERE creator_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.note_image WHERE deletor_id IN (SELECT id FROM public.user_ WHERE organization_id = :org_id);
+ DELETE FROM public.user_ WHERE organization_id = :org_id;
+ DELETE FROM public.fieldseeker_sync WHERE organization_id = :org_id;
+ DELETE FROM public.h3_aggregation WHERE organization_id = :org_id;
+ DELETE FROM public.note_audio WHERE organization_id = :org_id;
+ DELETE FROM public.note_image WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.containerrelate WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.fieldscoutinglog WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.habitatrelate WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.inspectionsample WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.inspectionsampledetail WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.linelocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.locationtracking WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.mosquitoinspection WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.pointlocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.polygonlocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.pool WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.pooldetail WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.proposedtreatmentarea WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.qamosquitoinspection WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.rodentlocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.samplecollection WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.samplelocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.servicerequest WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.speciesabundance WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.stormdrain WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.timecard WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.trapdata WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.traplocation WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.treatment WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.treatmentarea WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.zones WHERE organization_id = :org_id;
+ DELETE FROM fieldseeker.zones2 WHERE organization_id = :org_id;
+COMMIT;
From 92294e5b16ee4fb2573f2337dd51c9d9c328200b Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 00:20:19 +0000
Subject: [PATCH 0032/1453] Creat signout logic, make links use it.
---
auth/auth.go | 6 ++++++
sync/routes.go | 1 +
sync/signin.go | 6 ++++++
sync/template/components/header.html | 2 +-
sync/template/signup.html | 2 +-
5 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/auth/auth.go b/auth/auth.go
index 83a6feee..7548ecca 100644
--- a/auth/auth.go
+++ b/auth/auth.go
@@ -125,6 +125,12 @@ func SigninUser(r *http.Request, username string, password string) (*models.User
return user, nil
}
+func SignoutUser(r *http.Request, user *models.User) {
+ sessionManager.Put(r.Context(), "user_id", "")
+ sessionManager.Put(r.Context(), "username", "")
+ log.Info().Str("username", user.Username).Int32("user_id", user.ID).Msg("Ended user session")
+}
+
func SignupUser(ctx context.Context, username string, name string, password string) (*models.User, error) {
passwordHash, err := hashPassword(password)
if err != nil {
diff --git a/sync/routes.go b/sync/routes.go
index 8c57a09b..89cf6444 100644
--- a/sync/routes.go
+++ b/sync/routes.go
@@ -52,6 +52,7 @@ func Router() chi.Router {
r.Get("/qr-code/report/{code}", getQRCodeReport)
r.Get("/signin", getSignin)
r.Post("/signin", postSignin)
+ r.Method("GET", "/signout", auth.NewEnsureAuth(getSignout))
r.Get("/signup", getSignup)
r.Post("/signup", postSignup)
r.Get("/sms", getSMS)
diff --git a/sync/signin.go b/sync/signin.go
index 180b119c..b1f9b63f 100644
--- a/sync/signin.go
+++ b/sync/signin.go
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/Gleipnir-Technology/nidus-sync/auth"
+ "github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/htmlpage"
"github.com/rs/zerolog/log"
)
@@ -20,6 +21,11 @@ func getSignin(w http.ResponseWriter, r *http.Request) {
signin(w, errorCode)
}
+func getSignout(w http.ResponseWriter, r *http.Request, user *models.User) {
+ auth.SignoutUser(r, user)
+ http.Redirect(w, r, "/signin", http.StatusFound)
+}
+
func getSignup(w http.ResponseWriter, r *http.Request) {
signup(w, r.URL.Path)
}
diff --git a/sync/template/components/header.html b/sync/template/components/header.html
index 93e806df..00f43dad 100644
--- a/sync/template/components/header.html
+++ b/sync/template/components/header.html
@@ -70,7 +70,7 @@
diff --git a/sync/template/signup.html b/sync/template/signup.html
index a44e93da..57d2b072 100644
--- a/sync/template/signup.html
+++ b/sync/template/signup.html
@@ -65,7 +65,7 @@
-
Already have an account? Sign in
+
Already have an account? Sign in
From 248cffd323cc92d82f02c1506aa6aa8d7dddaa9e Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 01:05:21 +0000
Subject: [PATCH 0033/1453] Rework arcgis oauth flow logic
This is several changes after the demo with Ben
* When a user adds their oauth and they get an arcgis ID for an
organization that exits they are added to that organization. The
previous org isn't removed
* All layer processing is done in a single large pool. This makes it
much faster in aggregate
* Some queries are done more directly instead of through custom sql
---
background/arcgis.go | 173 ++++++++++++++++++++++---------------------
1 file changed, 88 insertions(+), 85 deletions(-)
diff --git a/background/arcgis.go b/background/arcgis.go
index 6a32ec53..cf6836a1 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -39,6 +39,8 @@ import (
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/dialect"
"github.com/stephenafamo/bob/dialect/psql/im"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
"github.com/uber/h3-go/v4"
)
@@ -245,18 +247,49 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s
}
log.Info().Str("Username", portal.User.Username).Str("user_id", portal.User.ID).Str("org_id", portal.User.OrgID).Str("org_name", portal.Name).Str("license_type_id", portal.User.UserLicenseTypeID).Msg("Got portals data")
- _, err = sql.UpdateOauthTokenOrg(portal.User.ID, portal.User.UserLicenseTypeID, refresh_token).Exec(ctx, db.PGInstance.BobDB)
+ _, err = models.OauthTokens.Update(
+ //um.SetCol(string(models.OauthTokens.Columns.ArcgisID)).ToArg(portal.User.ID),
+ //um.SetCol(string(models.OauthTokens.Columns.ArcgisLicenseTypeID)).ToArg(portal.User.UserLicenseTypeID),
+ um.SetCol("arcgis_id").ToArg(portal.User.ID),
+ um.SetCol("arcgis_license_type_id").ToArg(portal.User.UserLicenseTypeID),
+ um.Where(models.OauthTokens.Columns.RefreshToken.EQ(psql.Arg(refresh_token))),
+ ).Exec(ctx, db.PGInstance.BobDB)
+ //_, err = sql.UpdateOauthTokenOrg(portal.User.ID, portal.User.UserLicenseTypeID, refresh_token).Exec(ctx, db.PGInstance.BobDB)
if err != nil {
log.Error().Err(err).Msg("Failed to update oauth token portal data")
return
}
- org := user.R.Organization
- err = org.Update(ctx, db.PGInstance.BobDB, &models.OrganizationSetter{
- ArcgisID: omitnull.From(portal.User.OrgID),
- ArcgisName: omitnull.From(portal.Name),
- })
+ // At this point we have the arcgis ID. If the ID matches an existing ID, join it with the users organization
+ orgs, err := models.Organizations.Query(
+ sm.Where(
+ psql.Quote("arcgis_id").EQ(psql.Arg(portal.User.OrgID)),
+ ),
+ ).All(ctx, db.PGInstance.BobDB)
if err != nil {
- log.Error().Err(err).Int32("id", user.R.Organization.ID).Msg("Failed to update organization's arcgis info")
+ log.Error().Err(err).Str("arcgis_id", portal.User.OrgID).Msg("Failed to search for organization with arcgis id")
+ return
+ }
+ var org *models.Organization
+ switch len(orgs) {
+ case 0:
+ org = user.R.Organization
+ err = org.Update(ctx, db.PGInstance.BobDB, &models.OrganizationSetter{
+ ArcgisID: omitnull.From(portal.User.OrgID),
+ ArcgisName: omitnull.From(portal.Name),
+ })
+ if err != nil {
+ log.Error().Err(err).Int32("id", user.R.Organization.ID).Msg("Failed to update organization's arcgis info")
+ return
+ }
+ log.Info().Int32("org_id", org.ID).Str("arcgis_id", portal.User.OrgID).Msg("Updated org arcgis ID")
+ case 1:
+ org = orgs[0]
+ user.Update(ctx, db.PGInstance.BobDB, &models.UserSetter{
+ OrganizationID: omit.From(org.ID),
+ })
+ log.Info().Int32("org_id", org.ID).Int32("user_id", user.ID).Msg("Moved user into organization")
+ default:
+ log.Warn().Int("orgs", len(orgs)).Msg("Got too many orgs, programmer error.")
return
}
@@ -313,67 +346,6 @@ func maybeCreateWebhook(ctx context.Context, client *fieldseeker.FieldSeeker) {
}
}
-func downloadAllRecords(ctx context.Context, fssync *fieldseeker.FieldSeeker, layer arcgis.LayerFeature, org_id int32) (SyncStats, error) {
- var stats SyncStats
- count, err := fssync.QueryCount(layer.ID)
- if err != nil {
- return stats, fmt.Errorf("Failed to get counts for layer %s (%d): %w", layer.Name, layer.ID, err)
- }
- log.Info().Str("name", layer.Name).Uint("id", layer.ID).Msg("Starting on layer")
- if count.Count == 0 {
- return stats, nil
- }
- pool := pond.NewResultPool[SyncStats](20)
- group := pool.NewGroup()
- maxRecords := uint(fssync.MaxRecordCount())
- for offset := uint(0); offset < uint(count.Count); offset += maxRecords {
- group.SubmitErr(func() (SyncStats, error) {
- /*query := arcgis.NewQuery()
- query.ResultRecordCount = maxRecords
- query.ResultOffset = offset
- query.SpatialReference = "4326"
- query.OutFields = "*"
- query.Where = "1=1"
- qr, err := fssync.DoQuery(
- layer.ID,
- query)
- if err != nil {
- return SyncStats{}, fmt.Errorf("Failed to get layer %s (%d) at offset %d: %w", layer.Name, layer.ID, offset, err)
- }
-
- i, u, err := saveOrUpdateDBRecords(ctx, "FS_"+layer.Name, qr, org_id)
- if err != nil {
- filename := fmt.Sprintf("failure-%s-%d-%d.json", layer.Name, layer.ID, offset)
- saveRawQuery(fssync, layer, query, filename)
- log.Error().Err(err).Msg("Faild to save DB records")
- return SyncStats{}, fmt.Errorf("Failed to save records: %w", err)
- }
- return SyncStats{
- Inserts: i,
- Updates: u,
- Unchanged: len(qr.Features) - u - i,
- }, nil
- */
- return SyncStats{
- Inserts: 0,
- Updates: 0,
- Unchanged: 0,
- }, nil
- })
- }
- results, err := group.Wait()
- if err != nil {
- return stats, fmt.Errorf("one or more tasks in the work pool failed: %w", err)
- }
- for _, r := range results {
- stats.Inserts += r.Inserts
- stats.Updates += r.Updates
- stats.Unchanged += r.Unchanged
- }
- log.Info().Uint("inserts", stats.Inserts).Uint("updates", stats.Updates).Uint("no change", stats.Unchanged).Msg("Finished layer")
- return stats, nil
-}
-
func getOAuthForOrg(ctx context.Context, org *models.Organization) (*models.OauthToken, error) {
users, err := org.User().All(ctx, db.PGInstance.BobDB)
if err != nil {
@@ -402,6 +374,7 @@ func periodicallyExportFieldseeker(ctx context.Context, org *models.Organization
if err != nil {
return fmt.Errorf("Failed to get oauth for org: %w", err)
}
+ logPermissions(ctx, org, oauth)
err = exportFieldseekerData(ctx, org, oauth)
syncStatusByOrg[org.ID] = false
if err != nil {
@@ -436,11 +409,12 @@ func exportFieldseekerData(ctx context.Context, org *models.Organization, oauth
return fmt.Errorf("Failed to create fssync: %w", err)
}
var stats SyncStats
- //layers := fssync.FeatureServerLayers()
+ pool := pond.NewResultPool[SyncStats](20)
+ group := pool.NewGroup()
var ss SyncStats
for _, l := range fssync.FeatureServerLayers() {
- ss, err = exportFieldseekerLayer(ctx, org, fssync, l)
+ ss, err = exportFieldseekerLayer(ctx, group, org, fssync, l)
if err != nil {
return err
}
@@ -448,6 +422,15 @@ func exportFieldseekerData(ctx context.Context, org *models.Organization, oauth
stats.Updates += ss.Updates
stats.Unchanged += ss.Unchanged
}
+ results, err := group.Wait()
+ if err != nil {
+ return fmt.Errorf("one or more tasks in the work pool failed: %w", err)
+ }
+ for _, r := range results {
+ stats.Inserts += r.Inserts
+ stats.Updates += r.Updates
+ stats.Unchanged += r.Unchanged
+ }
setter := models.FieldseekerSyncSetter{
RecordsCreated: omit.From(int32(stats.Inserts)),
@@ -463,6 +446,37 @@ func exportFieldseekerData(ctx context.Context, org *models.Organization, oauth
return nil
}
+func logPermissions(ctx context.Context, org *models.Organization, oauth *models.OauthToken) {
+ ar := arcgis.NewArcGIS(
+ arcgis.AuthenticatorOAuth{
+ AccessToken: oauth.AccessToken,
+ AccessTokenExpires: oauth.AccessTokenExpires,
+ RefreshToken: oauth.RefreshToken,
+ RefreshTokenExpires: oauth.RefreshTokenExpires,
+ },
+ )
+ row, err := sql.OrgByOauthId(oauth.ID).One(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get org in log permissions")
+ return
+ }
+ fssync, err := fieldseeker.NewFieldSeeker(
+ ar,
+ row.FieldseekerURL.MustGet(),
+ )
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to create fieldseeker client in log permissions")
+ return
+ }
+ permissions, err := fssync.PermissionList()
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to query permissions in log permissions")
+ return
+ }
+ for _, p := range permissions {
+ log.Info().Str("p", p.Principal).Msg("Permission!")
+ }
+}
func maintainOAuth(ctx context.Context, oauth *models.OauthToken) error {
for {
// Refresh from the database
@@ -1086,24 +1100,22 @@ func updateSummaryTables(ctx context.Context, org *models.Organization) {
}
}
-func exportFieldseekerLayer(ctx context.Context, org *models.Organization, fssync *fieldseeker.FieldSeeker, layer arcgis.LayerFeature) (SyncStats, error) {
+func exportFieldseekerLayer(ctx context.Context, group pond.ResultTaskGroup[SyncStats], org *models.Organization, fssync *fieldseeker.FieldSeeker, layer arcgis.LayerFeature) (SyncStats, error) {
var stats SyncStats
count, err := fssync.QueryCount(layer.ID)
if err != nil {
return stats, fmt.Errorf("Failed to get counts for layer %s (%d): %w", layer.Name, layer.ID, err)
}
if count.Count == 0 {
- log.Info().Str("name", layer.Name).Uint("id", layer.ID).Msg("No records to download")
+ log.Info().Str("name", layer.Name).Uint("layer_id", layer.ID).Int32("org_id", org.ID).Msg("No records to download")
return stats, nil
}
- log.Info().Str("name", layer.Name).Uint("id", layer.ID).Msg("Starting on layer")
- pool := pond.NewResultPool[SyncStats](20)
- group := pool.NewGroup()
maxRecords := uint(fssync.MaxRecordCount())
l, err := fieldseeker.NameToLayerType(layer.Name)
if err != nil {
return stats, fmt.Errorf("Failed to get layer for '%s': %w", layer.Name, err)
}
+ log.Info().Str("name", layer.Name).Uint("layer_id", layer.ID).Int32("org_id", org.ID).Int("count", count.Count).Uint("iterations", uint(count.Count)/maxRecords).Msg("Queuing jobs for layer")
for offset := uint(0); offset < uint(count.Count); offset += maxRecords {
group.SubmitErr(func() (SyncStats, error) {
var ss SyncStats
@@ -1571,15 +1583,6 @@ func exportFieldseekerLayer(ctx context.Context, org *models.Organization, fssyn
return ss, err
})
}
- results, err := group.Wait()
- if err != nil {
- return stats, fmt.Errorf("one or more tasks in the work pool failed: %w", err)
- }
- for _, r := range results {
- stats.Inserts += r.Inserts
- stats.Updates += r.Updates
- stats.Unchanged += r.Unchanged
- }
- log.Info().Uint("inserts", stats.Inserts).Uint("updates", stats.Updates).Uint("no change", stats.Unchanged).Str("layer", layer.Name).Msg("Finished layer")
+ //log.Info().Uint("inserts", stats.Inserts).Uint("updates", stats.Updates).Uint("no change", stats.Unchanged).Str("layer", layer.Name).Msg("Finished layer")
return stats, nil
}
From d46d988b4d18b3a10215cf214da96e53ecde3187 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 04:10:54 +0000
Subject: [PATCH 0034/1453] Make aggregate layers clean up, add service request
aggregate
---
background/arcgis.go | 70 ++----------------
background/summary.go | 137 +++++++++++++++++++++++++++++++++++
sync/template/dashboard.html | 16 +++-
3 files changed, 157 insertions(+), 66 deletions(-)
create mode 100644 background/summary.go
diff --git a/background/arcgis.go b/background/arcgis.go
index cf6836a1..d1622068 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -24,24 +24,18 @@ import (
"github.com/Gleipnir-Technology/arcgis-go/fieldseeker"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/db"
- "github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
"github.com/Gleipnir-Technology/nidus-sync/debug"
- "github.com/Gleipnir-Technology/nidus-sync/h3utils"
"github.com/Gleipnir-Technology/nidus-sync/notification"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/alitto/pond/v2"
"github.com/jackc/pgx/v5"
"github.com/rs/zerolog/log"
- "github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
- "github.com/stephenafamo/bob/dialect/psql/dialect"
- "github.com/stephenafamo/bob/dialect/psql/im"
"github.com/stephenafamo/bob/dialect/psql/sm"
"github.com/stephenafamo/bob/dialect/psql/um"
- "github.com/uber/h3-go/v4"
)
var syncStatusByOrg map[int32]bool
@@ -468,6 +462,11 @@ func logPermissions(ctx context.Context, org *models.Organization, oauth *models
log.Error().Err(err).Msg("Failed to create fieldseeker client in log permissions")
return
}
+ _, err = fssync.AdminInfo()
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get admin info log permissions")
+ return
+ }
permissions, err := fssync.PermissionList()
if err != nil {
log.Error().Err(err).Msg("Failed to query permissions in log permissions")
@@ -477,6 +476,7 @@ func logPermissions(ctx context.Context, org *models.Organization, oauth *models
log.Info().Str("p", p.Principal).Msg("Permission!")
}
}
+
func maintainOAuth(ctx context.Context, oauth *models.OauthToken) error {
for {
// Refresh from the database
@@ -1042,64 +1042,6 @@ func updateRowFromFeatureFS(ctx context.Context, transaction pgx.Tx, table strin
return nil
}
-func updateSummaryTables(ctx context.Context, org *models.Organization) {
- /*org, err := models.FindOrganization(ctx, PGInstance.BobDB, org_id)
- if err != nil {
- log.Error().Err(err).Msg("Failed to get organization")
- }*/
- log.Info().Int("org_id", int(org.ID)).Msg("Getting point locations")
- point_locations, err := org.Pointlocations().All(ctx, db.PGInstance.BobDB)
- if err != nil {
- log.Error().Err(err).Msg("Failed to get organization")
- return
- }
- if len(point_locations) == 0 {
- log.Info().Int("org_id", int(org.ID)).Msg("No updates to perform")
- return
- }
- log.Info().Int("count", len(point_locations)).Msg("Summarizing point locations")
-
- for i := range 16 {
- log.Info().Int("resolution", i).Msg("Working summary layer")
- cellToCount := make(map[h3.Cell]int, 0)
- for _, p := range point_locations {
- if p.H3cell.IsNull() {
- continue
- }
- cell, err := h3utils.ToCell(p.H3cell.MustGet())
- if err != nil {
- log.Error().Err(err).Msg("Failed to get geometry point")
- continue
- }
- scaled, err := cell.Parent(i)
- if err != nil {
- log.Error().Err(err).Int("resolution", i).Msg("Failed to get cell's parent at resolution")
- continue
- }
- cellToCount[scaled] = cellToCount[scaled] + 1
- }
- var to_insert []bob.Mod[*dialect.InsertQuery] = make([]bob.Mod[*dialect.InsertQuery], 0)
- to_insert = append(to_insert, im.Into("h3_aggregation", "cell", "resolution", "count_", "type_", "organization_id", "geometry"))
- for cell, count := range cellToCount {
- polygon, err := h3utils.CellToPostgisGeometry(cell)
- if err != nil {
- log.Error().Err(err).Msg("Failed to get PostGIS geometry")
- continue
- }
- // log.Info().Str("polygon", polygon).Msg("Going to insert")
- to_insert = append(to_insert, im.Values(psql.Arg(cell.String(), i, count, enums.H3aggregationtypeServicerequest, org.ID), psql.F("st_geomfromtext", psql.S(polygon), 4326)))
- }
- to_insert = append(to_insert, im.OnConflict("cell, organization_id, type_").DoUpdate(
- im.SetCol("count_").To(psql.Raw("EXCLUDED.count_")),
- ))
- //log.Info().Str("sql", insertQueryToString(psql.Insert(to_insert...))).Msg("Updating...")
- _, err := psql.Insert(to_insert...).Exec(ctx, db.PGInstance.BobDB)
- if err != nil {
- log.Error().Err(err).Msg("Faild to add h3 aggregation")
- }
- }
-}
-
func exportFieldseekerLayer(ctx context.Context, group pond.ResultTaskGroup[SyncStats], org *models.Organization, fssync *fieldseeker.FieldSeeker, layer arcgis.LayerFeature) (SyncStats, error) {
var stats SyncStats
count, err := fssync.QueryCount(layer.ID)
diff --git a/background/summary.go b/background/summary.go
new file mode 100644
index 00000000..fc6b528a
--- /dev/null
+++ b/background/summary.go
@@ -0,0 +1,137 @@
+package background
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/Gleipnir-Technology/nidus-sync/db"
+ "github.com/Gleipnir-Technology/nidus-sync/db/enums"
+ "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/Gleipnir-Technology/nidus-sync/h3utils"
+ "github.com/rs/zerolog/log"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/im"
+ "github.com/uber/h3-go/v4"
+)
+
+func updateSummaryTables(ctx context.Context, org *models.Organization) {
+ updateSummaryMosquitoSource(ctx, org)
+ updateSummaryServiceRequest(ctx, org)
+}
+
+func aggregateAtResolution(ctx context.Context, resolution int, org_id int32, type_ enums.H3aggregationtype, cells []h3.Cell) error {
+ var err error
+ log.Info().Int("resolution", resolution).Str("type", string(type_)).Msg("Working summary layer")
+ cellToCount := make(map[h3.Cell]int, 0)
+ for _, cell := range cells {
+ scaled, err := cell.Parent(resolution)
+ if err != nil {
+ log.Error().Err(err).Int("resolution", resolution).Msg("Failed to get cell's parent at resolution")
+ continue
+ }
+ cellToCount[scaled] = cellToCount[scaled] + 1
+ }
+
+ _, err = models.H3Aggregations.Delete(
+ dm.Where(
+ psql.And(
+ models.H3Aggregations.Columns.OrganizationID.EQ(psql.Arg(org_id)),
+ models.H3Aggregations.Columns.Resolution.EQ(psql.Arg(resolution)),
+ models.H3Aggregations.Columns.Type.EQ(psql.Arg(type_)),
+ ),
+ ),
+ ).Exec(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return fmt.Errorf("Failed to clear previous aggregation: %w", err)
+ }
+ var to_insert []bob.Mod[*dialect.InsertQuery] = make([]bob.Mod[*dialect.InsertQuery], 0)
+ to_insert = append(to_insert, im.Into("h3_aggregation", "cell", "resolution", "count_", "type_", "organization_id", "geometry"))
+ for cell, count := range cellToCount {
+ polygon, err := h3utils.CellToPostgisGeometry(cell)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get PostGIS geometry")
+ continue
+ }
+ // log.Info().Str("polygon", polygon).Msg("Going to insert")
+ to_insert = append(to_insert, im.Values(psql.Arg(cell.String(), resolution, count, type_, org_id), psql.F("st_geomfromtext", psql.S(polygon), 4326)))
+ }
+ to_insert = append(to_insert, im.OnConflict("cell, organization_id, type_").DoUpdate(
+ im.SetCol("count_").To(psql.Raw("EXCLUDED.count_")),
+ ))
+ //log.Info().Str("sql", insertQueryToString(psql.Insert(to_insert...))).Msg("Updating...")
+ _, err = psql.Insert(to_insert...).Exec(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return fmt.Errorf("Failed to add h3 aggregation: %w", err)
+ }
+ return nil
+}
+
+func updateSummaryMosquitoSource(ctx context.Context, org *models.Organization) {
+ log.Info().Int("org_id", int(org.ID)).Msg("Getting point locations")
+ point_locations, err := org.Pointlocations().All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get all point locations")
+ return
+ }
+ if len(point_locations) == 0 {
+ log.Info().Int("org_id", int(org.ID)).Msg("No updates to perform")
+ return
+ }
+ log.Info().Int("count", len(point_locations)).Msg("Summarizing point locations")
+
+ cells := make([]h3.Cell, 0)
+ for _, p := range point_locations {
+ if p.H3cell.IsNull() {
+ continue
+ }
+ cell, err := h3utils.ToCell(p.H3cell.MustGet())
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get geometry point")
+ continue
+ }
+ cells = append(cells, cell)
+ }
+
+ for i := range 16 {
+ err = aggregateAtResolution(ctx, i, org.ID, enums.H3aggregationtypeMosquitosource, cells)
+ if err != nil {
+ log.Error().Err(err).Int("resolution", i).Msg("Failed to aggregate mosquito source")
+ }
+ }
+}
+
+func updateSummaryServiceRequest(ctx context.Context, org *models.Organization) {
+ log.Info().Int("org_id", int(org.ID)).Msg("Getting service requests")
+ service_requests, err := org.Servicerequests().All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get all service requests")
+ return
+ }
+ if len(service_requests) == 0 {
+ log.Info().Int("org_id", int(org.ID)).Msg("No updates to perform")
+ return
+ }
+ log.Info().Int("count", len(service_requests)).Msg("Summarizing point locations")
+
+ cells := make([]h3.Cell, 0)
+ for _, p := range service_requests {
+ if p.H3cell.IsNull() {
+ continue
+ }
+ cell, err := h3utils.ToCell(p.H3cell.MustGet())
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to get geometry point")
+ continue
+ }
+ cells = append(cells, cell)
+ }
+ for i := range 16 {
+ err = aggregateAtResolution(ctx, i, org.ID, enums.H3aggregationtypeServicerequest, cells)
+ if err != nil {
+ log.Error().Err(err).Int("resolution", i).Msg("Failed to aggregate service request")
+ }
+ }
+}
diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html
index 420b521d..1479c335 100644
--- a/sync/template/dashboard.html
+++ b/sync/template/dashboard.html
@@ -26,17 +26,29 @@ function onLoad() {
//'maxzoom': 14
});
map.addLayer({
- 'id': 'nidus', // Layer ID
+ 'id': 'mosquito_source', // Layer ID
'type': 'fill',
'filter': ['==', ['zoom'], ['+', 2, ['to-number', ['get', 'resolution']]]],
'source': 'tegola-nidus', // ID of the tile source created above
- 'source-layer': 'h3_aggregation',
+ 'source-layer': 'mosquito_source',
'paint': {
'fill-opacity': 0.3,
'fill-color': 'rgb(250, 100, 100)'
}
//slot: 'middle' // middle slot in Mapbox Standard style
});
+ map.addLayer({
+ 'id': 'service_request', // Layer ID
+ 'type': 'fill',
+ 'filter': ['==', ['zoom'], ['+', 2, ['to-number', ['get', 'resolution']]]],
+ 'source': 'tegola-nidus', // ID of the tile source created above
+ 'source-layer': 'service_request',
+ 'paint': {
+ 'fill-opacity': 0.3,
+ 'fill-color': 'rgb(100, 100, 250)'
+ }
+ //slot: 'middle' // middle slot in Mapbox Standard style
+ });
map.addInteraction("nidus-click-interaction", {
type: 'click',
target: { layerId: 'nidus' },
From f94b89381f603056a596d4ac367898e08e0b6dbe Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 04:11:19 +0000
Subject: [PATCH 0035/1453] Actually delete the organization in delete-org.sql
---
tools/delete-org.sql | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/delete-org.sql b/tools/delete-org.sql
index 6bc09998..d01361d7 100644
--- a/tools/delete-org.sql
+++ b/tools/delete-org.sql
@@ -38,4 +38,5 @@ BEGIN;
DELETE FROM fieldseeker.treatmentarea WHERE organization_id = :org_id;
DELETE FROM fieldseeker.zones WHERE organization_id = :org_id;
DELETE FROM fieldseeker.zones2 WHERE organization_id = :org_id;
+ DELETE FROM organization WHERE id = :org_id;
COMMIT;
From 06140a9062b3f8c7f33228795a0ee8f4b65f55be Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 19:18:34 +0000
Subject: [PATCH 0036/1453] Remove bob submodule, add arcgis.user
I had to remove the submodule because of the go bug at
https://github.com/golang/go/issues/77196
I found the bug because of a bug in bob itself
https://github.com/stephenafamo/bob/issues/610
This was because I'm trying to save data about the Arcgis user for use
in determining if I can set up hooks to avoid the polling for data
changes.
---
.gitmodules | 3 -
background/arcgis.go | 81 +-
db/bob | 1 -
db/bobgen.sh | 3 +-
db/bobgen.yaml | 7 +
db/dberrors/arcgis.user_.bob.go | 17 +
db/dberrors/arcgis.user_privilege.bob.go | 17 +
db/dberrors/bob_errors.bob.go | 2 +-
db/dberrors/district.bob.go | 2 +-
.../fieldseeker.containerrelate.bob.go | 2 +-
.../fieldseeker.fieldscoutinglog.bob.go | 2 +-
db/dberrors/fieldseeker.habitatrelate.bob.go | 2 +-
.../fieldseeker.inspectionsample.bob.go | 2 +-
.../fieldseeker.inspectionsampledetail.bob.go | 2 +-
db/dberrors/fieldseeker.linelocation.bob.go | 2 +-
.../fieldseeker.locationtracking.bob.go | 2 +-
.../fieldseeker.mosquitoinspection.bob.go | 2 +-
db/dberrors/fieldseeker.pointlocation.bob.go | 2 +-
.../fieldseeker.polygonlocation.bob.go | 2 +-
db/dberrors/fieldseeker.pool.bob.go | 2 +-
db/dberrors/fieldseeker.pooldetail.bob.go | 2 +-
.../fieldseeker.proposedtreatmentarea.bob.go | 2 +-
.../fieldseeker.qamosquitoinspection.bob.go | 2 +-
db/dberrors/fieldseeker.rodentlocation.bob.go | 2 +-
.../fieldseeker.samplecollection.bob.go | 2 +-
db/dberrors/fieldseeker.samplelocation.bob.go | 2 +-
db/dberrors/fieldseeker.servicerequest.bob.go | 2 +-
.../fieldseeker.speciesabundance.bob.go | 2 +-
db/dberrors/fieldseeker.stormdrain.bob.go | 2 +-
db/dberrors/fieldseeker.timecard.bob.go | 2 +-
db/dberrors/fieldseeker.trapdata.bob.go | 2 +-
db/dberrors/fieldseeker.traplocation.bob.go | 2 +-
db/dberrors/fieldseeker.treatment.bob.go | 2 +-
db/dberrors/fieldseeker.treatmentarea.bob.go | 2 +-
db/dberrors/fieldseeker.zones.bob.go | 2 +-
db/dberrors/fieldseeker.zones2.bob.go | 2 +-
db/dberrors/fieldseeker_sync.bob.go | 2 +-
db/dberrors/goose_db_version.bob.go | 2 +-
db/dberrors/h3_aggregation.bob.go | 2 +-
db/dberrors/note_audio.bob.go | 2 +-
db/dberrors/note_audio_breadcrumb.bob.go | 2 +-
db/dberrors/note_audio_data.bob.go | 2 +-
db/dberrors/note_image.bob.go | 2 +-
db/dberrors/note_image_breadcrumb.bob.go | 2 +-
db/dberrors/note_image_data.bob.go | 2 +-
db/dberrors/notification.bob.go | 2 +-
db/dberrors/oauth_token.bob.go | 2 +-
db/dberrors/organization.bob.go | 2 +-
db/dberrors/publicreport.nuisance.bob.go | 2 +-
db/dberrors/publicreport.pool.bob.go | 2 +-
db/dberrors/publicreport.pool_photo.bob.go | 2 +-
db/dberrors/publicreport.quick.bob.go | 2 +-
db/dberrors/publicreport.quick_photo.bob.go | 2 +-
db/dberrors/sessions.bob.go | 2 +-
db/dberrors/spatial_ref_sys.bob.go | 2 +-
db/dberrors/user_.bob.go | 2 +-
db/dbinfo/arcgis.user_.bob.go | 237 ++
db/dbinfo/arcgis.user_privilege.bob.go | 122 +
db/dbinfo/bob_types.bob.go | 2 +-
db/dbinfo/district.bob.go | 2 +-
db/dbinfo/fieldseeker.containerrelate.bob.go | 2 +-
db/dbinfo/fieldseeker.fieldscoutinglog.bob.go | 2 +-
db/dbinfo/fieldseeker.habitatrelate.bob.go | 2 +-
db/dbinfo/fieldseeker.inspectionsample.bob.go | 2 +-
.../fieldseeker.inspectionsampledetail.bob.go | 2 +-
db/dbinfo/fieldseeker.linelocation.bob.go | 2 +-
db/dbinfo/fieldseeker.locationtracking.bob.go | 2 +-
.../fieldseeker.mosquitoinspection.bob.go | 2 +-
db/dbinfo/fieldseeker.pointlocation.bob.go | 2 +-
db/dbinfo/fieldseeker.polygonlocation.bob.go | 2 +-
db/dbinfo/fieldseeker.pool.bob.go | 2 +-
db/dbinfo/fieldseeker.pooldetail.bob.go | 2 +-
.../fieldseeker.proposedtreatmentarea.bob.go | 2 +-
.../fieldseeker.qamosquitoinspection.bob.go | 2 +-
db/dbinfo/fieldseeker.rodentlocation.bob.go | 2 +-
db/dbinfo/fieldseeker.samplecollection.bob.go | 2 +-
db/dbinfo/fieldseeker.samplelocation.bob.go | 2 +-
db/dbinfo/fieldseeker.servicerequest.bob.go | 2 +-
db/dbinfo/fieldseeker.speciesabundance.bob.go | 2 +-
db/dbinfo/fieldseeker.stormdrain.bob.go | 2 +-
db/dbinfo/fieldseeker.timecard.bob.go | 2 +-
db/dbinfo/fieldseeker.trapdata.bob.go | 2 +-
db/dbinfo/fieldseeker.traplocation.bob.go | 2 +-
db/dbinfo/fieldseeker.treatment.bob.go | 2 +-
db/dbinfo/fieldseeker.treatmentarea.bob.go | 2 +-
db/dbinfo/fieldseeker.zones.bob.go | 2 +-
db/dbinfo/fieldseeker.zones2.bob.go | 2 +-
db/dbinfo/fieldseeker_sync.bob.go | 2 +-
db/dbinfo/geography_columns.bob.go | 2 +-
db/dbinfo/geometry_columns.bob.go | 2 +-
db/dbinfo/goose_db_version.bob.go | 2 +-
db/dbinfo/h3_aggregation.bob.go | 2 +-
db/dbinfo/note_audio.bob.go | 2 +-
db/dbinfo/note_audio_breadcrumb.bob.go | 2 +-
db/dbinfo/note_audio_data.bob.go | 2 +-
db/dbinfo/note_image.bob.go | 2 +-
db/dbinfo/note_image_breadcrumb.bob.go | 2 +-
db/dbinfo/note_image_data.bob.go | 2 +-
db/dbinfo/notification.bob.go | 2 +-
db/dbinfo/oauth_token.bob.go | 2 +-
db/dbinfo/organization.bob.go | 2 +-
db/dbinfo/publicreport.nuisance.bob.go | 2 +-
db/dbinfo/publicreport.pool.bob.go | 2 +-
db/dbinfo/publicreport.pool_photo.bob.go | 2 +-
db/dbinfo/publicreport.quick.bob.go | 2 +-
db/dbinfo/publicreport.quick_photo.bob.go | 2 +-
db/dbinfo/publicreport.report_location.bob.go | 2 +-
db/dbinfo/raster_columns.bob.go | 2 +-
db/dbinfo/raster_overviews.bob.go | 2 +-
db/dbinfo/sessions.bob.go | 2 +-
db/dbinfo/spatial_ref_sys.bob.go | 2 +-
db/dbinfo/user_.bob.go | 2 +-
db/enums/enums.bob.go | 2 +-
db/factory/arcgis.user_.bob.go | 984 ++++++++
db/factory/arcgis.user_privilege.bob.go | 369 +++
db/factory/bobfactory_context.bob.go | 12 +-
db/factory/bobfactory_main.bob.go | 98 +-
db/factory/bobfactory_random.bob.go | 2 +-
db/factory/district.bob.go | 2 +-
db/factory/fieldseeker.containerrelate.bob.go | 2 +-
.../fieldseeker.fieldscoutinglog.bob.go | 2 +-
db/factory/fieldseeker.habitatrelate.bob.go | 2 +-
.../fieldseeker.inspectionsample.bob.go | 2 +-
.../fieldseeker.inspectionsampledetail.bob.go | 2 +-
db/factory/fieldseeker.linelocation.bob.go | 2 +-
.../fieldseeker.locationtracking.bob.go | 2 +-
.../fieldseeker.mosquitoinspection.bob.go | 2 +-
db/factory/fieldseeker.pointlocation.bob.go | 2 +-
db/factory/fieldseeker.polygonlocation.bob.go | 2 +-
db/factory/fieldseeker.pool.bob.go | 2 +-
db/factory/fieldseeker.pooldetail.bob.go | 2 +-
.../fieldseeker.proposedtreatmentarea.bob.go | 2 +-
.../fieldseeker.qamosquitoinspection.bob.go | 2 +-
db/factory/fieldseeker.rodentlocation.bob.go | 2 +-
.../fieldseeker.samplecollection.bob.go | 2 +-
db/factory/fieldseeker.samplelocation.bob.go | 2 +-
db/factory/fieldseeker.servicerequest.bob.go | 2 +-
.../fieldseeker.speciesabundance.bob.go | 2 +-
db/factory/fieldseeker.stormdrain.bob.go | 2 +-
db/factory/fieldseeker.timecard.bob.go | 2 +-
db/factory/fieldseeker.trapdata.bob.go | 2 +-
db/factory/fieldseeker.traplocation.bob.go | 2 +-
db/factory/fieldseeker.treatment.bob.go | 2 +-
db/factory/fieldseeker.treatmentarea.bob.go | 2 +-
db/factory/fieldseeker.zones.bob.go | 2 +-
db/factory/fieldseeker.zones2.bob.go | 2 +-
db/factory/fieldseeker_sync.bob.go | 2 +-
db/factory/geography_columns.bob.go | 2 +-
db/factory/geometry_columns.bob.go | 2 +-
db/factory/goose_db_version.bob.go | 2 +-
db/factory/h3_aggregation.bob.go | 2 +-
db/factory/note_audio.bob.go | 2 +-
db/factory/note_audio_breadcrumb.bob.go | 2 +-
db/factory/note_audio_data.bob.go | 2 +-
db/factory/note_image.bob.go | 2 +-
db/factory/note_image_breadcrumb.bob.go | 2 +-
db/factory/note_image_data.bob.go | 2 +-
db/factory/notification.bob.go | 2 +-
db/factory/oauth_token.bob.go | 2 +-
db/factory/organization.bob.go | 2 +-
db/factory/publicreport.nuisance.bob.go | 2 +-
db/factory/publicreport.pool.bob.go | 2 +-
db/factory/publicreport.pool_photo.bob.go | 2 +-
db/factory/publicreport.quick.bob.go | 2 +-
db/factory/publicreport.quick_photo.bob.go | 2 +-
.../publicreport.report_location.bob.go | 2 +-
db/factory/raster_columns.bob.go | 2 +-
db/factory/raster_overviews.bob.go | 2 +-
db/factory/sessions.bob.go | 2 +-
db/factory/spatial_ref_sys.bob.go | 2 +-
db/factory/user_.bob.go | 122 +-
db/migrations/00031_arcgis_user.sql | 28 +
db/models/arcgis.user_.bob.go | 1191 ++++++++++
db/models/arcgis.user_privilege.bob.go | 612 +++++
db/models/bob_counts.bob.go | 168 ++
db/models/bob_joins.bob.go | 6 +-
db/models/bob_loaders.bob.go | 10 +-
db/models/bob_where.bob.go | 8 +-
db/models/district.bob.go | 2 +-
db/models/fieldseeker.containerrelate.bob.go | 2 +-
db/models/fieldseeker.fieldscoutinglog.bob.go | 2 +-
db/models/fieldseeker.habitatrelate.bob.go | 2 +-
db/models/fieldseeker.inspectionsample.bob.go | 2 +-
.../fieldseeker.inspectionsampledetail.bob.go | 2 +-
db/models/fieldseeker.linelocation.bob.go | 2 +-
db/models/fieldseeker.locationtracking.bob.go | 2 +-
.../fieldseeker.mosquitoinspection.bob.go | 2 +-
db/models/fieldseeker.pointlocation.bob.go | 2 +-
db/models/fieldseeker.polygonlocation.bob.go | 2 +-
db/models/fieldseeker.pool.bob.go | 2 +-
db/models/fieldseeker.pooldetail.bob.go | 2 +-
.../fieldseeker.proposedtreatmentarea.bob.go | 2 +-
.../fieldseeker.qamosquitoinspection.bob.go | 2 +-
db/models/fieldseeker.rodentlocation.bob.go | 2 +-
db/models/fieldseeker.samplecollection.bob.go | 2 +-
db/models/fieldseeker.samplelocation.bob.go | 2 +-
db/models/fieldseeker.servicerequest.bob.go | 2 +-
db/models/fieldseeker.speciesabundance.bob.go | 2 +-
db/models/fieldseeker.stormdrain.bob.go | 2 +-
db/models/fieldseeker.timecard.bob.go | 2 +-
db/models/fieldseeker.trapdata.bob.go | 2 +-
db/models/fieldseeker.traplocation.bob.go | 2 +-
db/models/fieldseeker.treatment.bob.go | 2 +-
db/models/fieldseeker.treatmentarea.bob.go | 2 +-
db/models/fieldseeker.zones.bob.go | 2 +-
db/models/fieldseeker.zones2.bob.go | 2 +-
db/models/fieldseeker_sync.bob.go | 2 +-
db/models/geography_columns.bob.go | 2 +-
db/models/geometry_columns.bob.go | 2 +-
db/models/goose_db_version.bob.go | 2 +-
db/models/h3_aggregation.bob.go | 2 +-
db/models/note_audio.bob.go | 160 +-
db/models/note_audio_breadcrumb.bob.go | 2 +-
db/models/note_audio_data.bob.go | 2 +-
db/models/note_image.bob.go | 160 +-
db/models/note_image_breadcrumb.bob.go | 2 +-
db/models/note_image_data.bob.go | 2 +-
db/models/notification.bob.go | 2 +-
db/models/oauth_token.bob.go | 2 +-
db/models/organization.bob.go | 1988 ++++++++++++++++-
db/models/publicreport.nuisance.bob.go | 2 +-
db/models/publicreport.pool.bob.go | 97 +-
db/models/publicreport.pool_photo.bob.go | 2 +-
db/models/publicreport.quick.bob.go | 97 +-
db/models/publicreport.quick_photo.bob.go | 2 +-
db/models/publicreport.report_location.bob.go | 2 +-
db/models/raster_columns.bob.go | 2 +-
db/models/raster_overviews.bob.go | 2 +-
db/models/sessions.bob.go | 2 +-
db/models/spatial_ref_sys.bob.go | 2 +-
db/models/user_.bob.go | 656 +++++-
db/sql/oauth_by_user_id.bob.go | 111 -
db/sql/oauth_by_user_id.bob.sql | 6 -
db/sql/oauth_by_user_id.sql | 3 -
db/sql/org_by_oauth_id.bob.go | 4 +-
db/sql/org_by_oauth_id.bob.sql | 2 +-
db/sql/publicreport_publicid_table.bob.go | 4 +-
db/sql/publicreport_publicid_table.bob.sql | 2 +-
db/sql/trapcount_by_location_id.bob.go | 4 +-
db/sql/trapcount_by_location_id.bob.sql | 2 +-
db/sql/trapdata_by_location_id_recent.bob.go | 4 +-
db/sql/trapdata_by_location_id_recent.bob.sql | 2 +-
db/sql/traplocation_by_source_id.bob.go | 6 +-
db/sql/traplocation_by_source_id.bob.sql | 2 +-
db/sql/update_oauth_org.bob.go | 4 +-
db/sql/update_oauth_org.bob.sql | 2 +-
db/sql/user_by_username.bob.go | 12 +-
db/sql/user_by_username.bob.sql | 4 +-
db/sql/user_by_username.sql | 2 +-
249 files changed, 7447 insertions(+), 391 deletions(-)
delete mode 160000 db/bob
create mode 100644 db/dberrors/arcgis.user_.bob.go
create mode 100644 db/dberrors/arcgis.user_privilege.bob.go
create mode 100644 db/dbinfo/arcgis.user_.bob.go
create mode 100644 db/dbinfo/arcgis.user_privilege.bob.go
create mode 100644 db/factory/arcgis.user_.bob.go
create mode 100644 db/factory/arcgis.user_privilege.bob.go
create mode 100644 db/migrations/00031_arcgis_user.sql
create mode 100644 db/models/arcgis.user_.bob.go
create mode 100644 db/models/arcgis.user_privilege.bob.go
create mode 100644 db/models/bob_counts.bob.go
delete mode 100644 db/sql/oauth_by_user_id.bob.go
delete mode 100644 db/sql/oauth_by_user_id.bob.sql
delete mode 100644 db/sql/oauth_by_user_id.sql
diff --git a/.gitmodules b/.gitmodules
index 555f12c9..dc0c25cc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,6 +4,3 @@
[submodule "go-geojson2h3"]
path = go-geojson2h3
url = git@github.com:Gleipnir-Technology/go-geojson2h3.git
-[submodule "bob"]
- path = db/bob
- url = git@github.com:Gleipnir-Technology/bob.git
diff --git a/background/arcgis.go b/background/arcgis.go
index d1622068..901fda63 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -34,6 +34,7 @@ import (
"github.com/jackc/pgx/v5"
"github.com/rs/zerolog/log"
"github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
"github.com/stephenafamo/bob/dialect/psql/sm"
"github.com/stephenafamo/bob/dialect/psql/um"
)
@@ -101,11 +102,15 @@ func HandleOauthAccessCode(ctx context.Context, user *models.User, code string)
}
func HasFieldseekerConnection(ctx context.Context, user *models.User) (bool, error) {
- result, err := sql.OauthTokenByUserId(user.ID).All(ctx, db.PGInstance.BobDB)
+ result, err := models.OauthTokens.Query(
+ sm.Where(
+ models.OauthTokens.Columns.UserID.EQ(psql.Arg(user.ID)),
+ ),
+ ).Exists(ctx, db.PGInstance.BobDB)
if err != nil {
return false, err
}
- return len(result) > 0, nil
+ return result, nil
}
func IsSyncOngoing(org_id int32) bool {
@@ -234,12 +239,12 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s
RefreshTokenExpires: refresh_token_expires,
},
)
- portal, err := client.PortalsSelf()
+
+ portal, err := updatePortalData(ctx, client, user.ID)
if err != nil {
- log.Error().Err(err).Msg("Failed to get ArcGIS user data")
+ log.Error().Err(err).Msg("Failed to get portal data")
return
}
- log.Info().Str("Username", portal.User.Username).Str("user_id", portal.User.ID).Str("org_id", portal.User.OrgID).Str("org_name", portal.Name).Str("license_type_id", portal.User.UserLicenseTypeID).Msg("Got portals data")
_, err = models.OauthTokens.Update(
//um.SetCol(string(models.OauthTokens.Columns.ArcgisID)).ToArg(portal.User.ID),
@@ -326,6 +331,72 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s
NewOAuthTokenChannel <- struct{}{}
}
+func updatePortalData(ctx context.Context, client *arcgis.ArcGIS, user_id int32) (*arcgis.PortalsResponse, error) {
+ p, err := client.PortalsSelf()
+ if err != nil {
+ return nil, fmt.Errorf("Failed to get ArcGIS user data: %w", err)
+ }
+
+ tx, err := db.PGInstance.BobDB.BeginTx(ctx, nil)
+ _, err = models.ArcgisUserPrivileges.Delete(
+ dm.Where(
+ models.ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(p.User.ID)),
+ ),
+ ).Exec(ctx, tx)
+
+ if err != nil {
+ tx.Rollback(ctx)
+ return nil, fmt.Errorf("Failed to delete previous user privilege data: %w", err)
+ }
+
+ _, err = models.ArcgisUsers.Delete(
+ dm.Where(
+ models.ArcgisUsers.Columns.ID.EQ(psql.Arg(p.User.ID)),
+ ),
+ ).Exec(ctx, tx)
+
+ if err != nil {
+ tx.Rollback(ctx)
+ return nil, fmt.Errorf("Failed to delete previous user data: %w", err)
+ }
+
+ setter := models.ArcgisUserSetter{
+ Access: omit.From(p.Access),
+ Created: omit.From(time.Unix(p.User.Created, 0)),
+ Email: omit.From(p.User.Email),
+ FullName: omit.From(p.User.FullName),
+ ID: omit.From(p.User.ID),
+ Level: omit.From(p.User.Level),
+ OrgID: omit.From(p.User.OrgID),
+ PublicUserID: omit.From(user_id),
+ Region: omit.From(p.Region),
+ Role: omit.From(p.User.Role),
+ RoleID: omit.From(p.User.RoleId),
+ Username: omit.From(p.User.Username),
+ UserLicenseTypeID: omit.From(p.User.UserLicenseTypeID),
+ UserType: omit.From(p.User.UserType),
+ }
+ _, err = models.ArcgisUsers.Insert(&setter).One(ctx, tx)
+ if err != nil {
+ tx.Rollback(ctx)
+ return nil, fmt.Errorf("Failed to add arcgis user data: %w", err)
+ }
+ for _, priv := range p.User.Privileges {
+ s := models.ArcgisUserPrivilegeSetter{
+ Privilege: omit.From(priv),
+ UserID: omit.From(p.User.ID),
+ }
+ _, err := models.ArcgisUserPrivileges.Insert(&s).One(ctx, tx)
+ if err != nil {
+ tx.Rollback(ctx)
+ return nil, fmt.Errorf("Failed to add arcgis user privilege data: %w", err)
+ }
+ }
+ err = tx.Commit(ctx)
+ log.Info().Str("username", p.User.Username).Str("user_id", p.User.ID).Str("org_id", p.User.OrgID).Str("org_name", p.Name).Str("license_type_id", p.User.UserLicenseTypeID).Msg("Updated portals data")
+ return p, nil
+}
+
func maybeCreateWebhook(ctx context.Context, client *fieldseeker.FieldSeeker) {
webhooks, err := client.WebhookList()
if err != nil {
diff --git a/db/bob b/db/bob
deleted file mode 160000
index d277a066..00000000
--- a/db/bob
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit d277a066d6bac5336e49615495ce2c74e736a7fd
diff --git a/db/bobgen.sh b/db/bobgen.sh
index ba30582d..9c2d653c 100755
--- a/db/bobgen.sh
+++ b/db/bobgen.sh
@@ -1,2 +1,3 @@
#!/run/current-system/sw/bin/bash
-PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" bob/bobgen-psql
+PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" /tmp/bobgen-psql
+#PSQL_DSN="postgresql://?host=/var/run/postgresql&sslmode=disable&dbname=nidus-sync" bob/gen/bobgen-psql/bobgen-psql
diff --git a/db/bobgen.yaml b/db/bobgen.yaml
index e5a60949..b9f4c8d7 100644
--- a/db/bobgen.yaml
+++ b/db/bobgen.yaml
@@ -1,4 +1,9 @@
aliases:
+ arcgis.user_:
+ up_plural: "ArcgisUsers"
+ up_singular: "ArcgisUser"
+ down_plural: "arcgisusers"
+ down_singular: "arcgisuser"
user_:
up_plural: "Users"
up_singular: "User"
@@ -7,9 +12,11 @@ aliases:
no_tests: true
psql:
schemas:
+ - "arcgis"
- "public"
- "publicreport"
- "fieldseeker"
+ shared_schema: "public"
queries:
- ./sql
uuid_pkg: google
diff --git a/db/dberrors/arcgis.user_.bob.go b/db/dberrors/arcgis.user_.bob.go
new file mode 100644
index 00000000..d17b1fef
--- /dev/null
+++ b/db/dberrors/arcgis.user_.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var ArcgisUserErrors = &arcgisuserErrors{
+ ErrUniqueUser_Pkey: &UniqueConstraintError{
+ schema: "arcgis",
+ table: "user_",
+ columns: []string{"id"},
+ s: "user__pkey",
+ },
+}
+
+type arcgisuserErrors struct {
+ ErrUniqueUser_Pkey *UniqueConstraintError
+}
diff --git a/db/dberrors/arcgis.user_privilege.bob.go b/db/dberrors/arcgis.user_privilege.bob.go
new file mode 100644
index 00000000..7ff6253f
--- /dev/null
+++ b/db/dberrors/arcgis.user_privilege.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var ArcgisUserPrivilegeErrors = &arcgisUserPrivilegeErrors{
+ ErrUniqueUserPrivilegePkey: &UniqueConstraintError{
+ schema: "arcgis",
+ table: "user_privilege",
+ columns: []string{"user_id", "privilege"},
+ s: "user_privilege_pkey",
+ },
+}
+
+type arcgisUserPrivilegeErrors struct {
+ ErrUniqueUserPrivilegePkey *UniqueConstraintError
+}
diff --git a/db/dberrors/bob_errors.bob.go b/db/dberrors/bob_errors.bob.go
index f98ecde7..ec4056c3 100644
--- a/db/dberrors/bob_errors.bob.go
+++ b/db/dberrors/bob_errors.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/district.bob.go b/db/dberrors/district.bob.go
index 06f8adee..b564e22b 100644
--- a/db/dberrors/district.bob.go
+++ b/db/dberrors/district.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.containerrelate.bob.go b/db/dberrors/fieldseeker.containerrelate.bob.go
index 2e5478b3..40d01312 100644
--- a/db/dberrors/fieldseeker.containerrelate.bob.go
+++ b/db/dberrors/fieldseeker.containerrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go
index 25c1147a..3237f5db 100644
--- a/db/dberrors/fieldseeker.fieldscoutinglog.bob.go
+++ b/db/dberrors/fieldseeker.fieldscoutinglog.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.habitatrelate.bob.go b/db/dberrors/fieldseeker.habitatrelate.bob.go
index 752bf877..d00f431c 100644
--- a/db/dberrors/fieldseeker.habitatrelate.bob.go
+++ b/db/dberrors/fieldseeker.habitatrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.inspectionsample.bob.go b/db/dberrors/fieldseeker.inspectionsample.bob.go
index b4e31312..ce6725a5 100644
--- a/db/dberrors/fieldseeker.inspectionsample.bob.go
+++ b/db/dberrors/fieldseeker.inspectionsample.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go
index 5538e4c9..69d7b6e6 100644
--- a/db/dberrors/fieldseeker.inspectionsampledetail.bob.go
+++ b/db/dberrors/fieldseeker.inspectionsampledetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.linelocation.bob.go b/db/dberrors/fieldseeker.linelocation.bob.go
index 353de2a0..5a135a53 100644
--- a/db/dberrors/fieldseeker.linelocation.bob.go
+++ b/db/dberrors/fieldseeker.linelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.locationtracking.bob.go b/db/dberrors/fieldseeker.locationtracking.bob.go
index 2f1f10ad..e68d1172 100644
--- a/db/dberrors/fieldseeker.locationtracking.bob.go
+++ b/db/dberrors/fieldseeker.locationtracking.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.mosquitoinspection.bob.go b/db/dberrors/fieldseeker.mosquitoinspection.bob.go
index 127e85ca..f9b119a7 100644
--- a/db/dberrors/fieldseeker.mosquitoinspection.bob.go
+++ b/db/dberrors/fieldseeker.mosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.pointlocation.bob.go b/db/dberrors/fieldseeker.pointlocation.bob.go
index 1b46e6c2..9078a437 100644
--- a/db/dberrors/fieldseeker.pointlocation.bob.go
+++ b/db/dberrors/fieldseeker.pointlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.polygonlocation.bob.go b/db/dberrors/fieldseeker.polygonlocation.bob.go
index 1502c145..250e5de2 100644
--- a/db/dberrors/fieldseeker.polygonlocation.bob.go
+++ b/db/dberrors/fieldseeker.polygonlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.pool.bob.go b/db/dberrors/fieldseeker.pool.bob.go
index fc41b355..7bb30e90 100644
--- a/db/dberrors/fieldseeker.pool.bob.go
+++ b/db/dberrors/fieldseeker.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.pooldetail.bob.go b/db/dberrors/fieldseeker.pooldetail.bob.go
index 613767bc..1423b462 100644
--- a/db/dberrors/fieldseeker.pooldetail.bob.go
+++ b/db/dberrors/fieldseeker.pooldetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go
index fcad48db..991a4d46 100644
--- a/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go
+++ b/db/dberrors/fieldseeker.proposedtreatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go
index 0d940baa..5ae42a56 100644
--- a/db/dberrors/fieldseeker.qamosquitoinspection.bob.go
+++ b/db/dberrors/fieldseeker.qamosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.rodentlocation.bob.go b/db/dberrors/fieldseeker.rodentlocation.bob.go
index 8b365032..d865425f 100644
--- a/db/dberrors/fieldseeker.rodentlocation.bob.go
+++ b/db/dberrors/fieldseeker.rodentlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.samplecollection.bob.go b/db/dberrors/fieldseeker.samplecollection.bob.go
index 1bbb4dc8..6f0de912 100644
--- a/db/dberrors/fieldseeker.samplecollection.bob.go
+++ b/db/dberrors/fieldseeker.samplecollection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.samplelocation.bob.go b/db/dberrors/fieldseeker.samplelocation.bob.go
index 889bb8b5..35a96bc1 100644
--- a/db/dberrors/fieldseeker.samplelocation.bob.go
+++ b/db/dberrors/fieldseeker.samplelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.servicerequest.bob.go b/db/dberrors/fieldseeker.servicerequest.bob.go
index ec0baf46..5e8d1020 100644
--- a/db/dberrors/fieldseeker.servicerequest.bob.go
+++ b/db/dberrors/fieldseeker.servicerequest.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.speciesabundance.bob.go b/db/dberrors/fieldseeker.speciesabundance.bob.go
index 5a6fde04..922bcc2a 100644
--- a/db/dberrors/fieldseeker.speciesabundance.bob.go
+++ b/db/dberrors/fieldseeker.speciesabundance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.stormdrain.bob.go b/db/dberrors/fieldseeker.stormdrain.bob.go
index fa72d71e..689fe28d 100644
--- a/db/dberrors/fieldseeker.stormdrain.bob.go
+++ b/db/dberrors/fieldseeker.stormdrain.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.timecard.bob.go b/db/dberrors/fieldseeker.timecard.bob.go
index a8c761ab..bf09f766 100644
--- a/db/dberrors/fieldseeker.timecard.bob.go
+++ b/db/dberrors/fieldseeker.timecard.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.trapdata.bob.go b/db/dberrors/fieldseeker.trapdata.bob.go
index f31e1333..7ffe6603 100644
--- a/db/dberrors/fieldseeker.trapdata.bob.go
+++ b/db/dberrors/fieldseeker.trapdata.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.traplocation.bob.go b/db/dberrors/fieldseeker.traplocation.bob.go
index a5c182e4..de57fa80 100644
--- a/db/dberrors/fieldseeker.traplocation.bob.go
+++ b/db/dberrors/fieldseeker.traplocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.treatment.bob.go b/db/dberrors/fieldseeker.treatment.bob.go
index 6231fcb3..40e0bddf 100644
--- a/db/dberrors/fieldseeker.treatment.bob.go
+++ b/db/dberrors/fieldseeker.treatment.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.treatmentarea.bob.go b/db/dberrors/fieldseeker.treatmentarea.bob.go
index 94ca5921..c7ff263b 100644
--- a/db/dberrors/fieldseeker.treatmentarea.bob.go
+++ b/db/dberrors/fieldseeker.treatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.zones.bob.go b/db/dberrors/fieldseeker.zones.bob.go
index d18052a7..bd2fd6e6 100644
--- a/db/dberrors/fieldseeker.zones.bob.go
+++ b/db/dberrors/fieldseeker.zones.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker.zones2.bob.go b/db/dberrors/fieldseeker.zones2.bob.go
index 3d378f51..644248d7 100644
--- a/db/dberrors/fieldseeker.zones2.bob.go
+++ b/db/dberrors/fieldseeker.zones2.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/fieldseeker_sync.bob.go b/db/dberrors/fieldseeker_sync.bob.go
index f02acf71..ac899d66 100644
--- a/db/dberrors/fieldseeker_sync.bob.go
+++ b/db/dberrors/fieldseeker_sync.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/goose_db_version.bob.go b/db/dberrors/goose_db_version.bob.go
index 1bd13dbd..af370d75 100644
--- a/db/dberrors/goose_db_version.bob.go
+++ b/db/dberrors/goose_db_version.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/h3_aggregation.bob.go b/db/dberrors/h3_aggregation.bob.go
index 0876f0ad..80c555b1 100644
--- a/db/dberrors/h3_aggregation.bob.go
+++ b/db/dberrors/h3_aggregation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_audio.bob.go b/db/dberrors/note_audio.bob.go
index 408f8d94..51621255 100644
--- a/db/dberrors/note_audio.bob.go
+++ b/db/dberrors/note_audio.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_audio_breadcrumb.bob.go b/db/dberrors/note_audio_breadcrumb.bob.go
index 36b73309..c0db7c25 100644
--- a/db/dberrors/note_audio_breadcrumb.bob.go
+++ b/db/dberrors/note_audio_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_audio_data.bob.go b/db/dberrors/note_audio_data.bob.go
index 6fe4fa73..bd4b07c1 100644
--- a/db/dberrors/note_audio_data.bob.go
+++ b/db/dberrors/note_audio_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_image.bob.go b/db/dberrors/note_image.bob.go
index 53ada199..8090f936 100644
--- a/db/dberrors/note_image.bob.go
+++ b/db/dberrors/note_image.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_image_breadcrumb.bob.go b/db/dberrors/note_image_breadcrumb.bob.go
index 256c0567..7e62d2ad 100644
--- a/db/dberrors/note_image_breadcrumb.bob.go
+++ b/db/dberrors/note_image_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/note_image_data.bob.go b/db/dberrors/note_image_data.bob.go
index eb67681f..91c1a89a 100644
--- a/db/dberrors/note_image_data.bob.go
+++ b/db/dberrors/note_image_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/notification.bob.go b/db/dberrors/notification.bob.go
index f9a429a1..d4f2841a 100644
--- a/db/dberrors/notification.bob.go
+++ b/db/dberrors/notification.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/oauth_token.bob.go b/db/dberrors/oauth_token.bob.go
index 5340029a..050b1a47 100644
--- a/db/dberrors/oauth_token.bob.go
+++ b/db/dberrors/oauth_token.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/organization.bob.go b/db/dberrors/organization.bob.go
index 1368c885..d9bf3dbd 100644
--- a/db/dberrors/organization.bob.go
+++ b/db/dberrors/organization.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/publicreport.nuisance.bob.go b/db/dberrors/publicreport.nuisance.bob.go
index fe815789..c1fcebb0 100644
--- a/db/dberrors/publicreport.nuisance.bob.go
+++ b/db/dberrors/publicreport.nuisance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/publicreport.pool.bob.go b/db/dberrors/publicreport.pool.bob.go
index d7ab3834..aefb420d 100644
--- a/db/dberrors/publicreport.pool.bob.go
+++ b/db/dberrors/publicreport.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/publicreport.pool_photo.bob.go b/db/dberrors/publicreport.pool_photo.bob.go
index 2bfed48d..0a5310e6 100644
--- a/db/dberrors/publicreport.pool_photo.bob.go
+++ b/db/dberrors/publicreport.pool_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/publicreport.quick.bob.go b/db/dberrors/publicreport.quick.bob.go
index f2d7db21..d51ed705 100644
--- a/db/dberrors/publicreport.quick.bob.go
+++ b/db/dberrors/publicreport.quick.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/publicreport.quick_photo.bob.go b/db/dberrors/publicreport.quick_photo.bob.go
index cce0eee3..4dd54714 100644
--- a/db/dberrors/publicreport.quick_photo.bob.go
+++ b/db/dberrors/publicreport.quick_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/sessions.bob.go b/db/dberrors/sessions.bob.go
index 8b54a349..e271ce05 100644
--- a/db/dberrors/sessions.bob.go
+++ b/db/dberrors/sessions.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/spatial_ref_sys.bob.go b/db/dberrors/spatial_ref_sys.bob.go
index 769f4bc2..195ac12d 100644
--- a/db/dberrors/spatial_ref_sys.bob.go
+++ b/db/dberrors/spatial_ref_sys.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dberrors/user_.bob.go b/db/dberrors/user_.bob.go
index 8b8b7295..d000ac1f 100644
--- a/db/dberrors/user_.bob.go
+++ b/db/dberrors/user_.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dberrors
diff --git a/db/dbinfo/arcgis.user_.bob.go b/db/dbinfo/arcgis.user_.bob.go
new file mode 100644
index 00000000..772f92db
--- /dev/null
+++ b/db/dbinfo/arcgis.user_.bob.go
@@ -0,0 +1,237 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var ArcgisUsers = Table[
+ arcgisuserColumns,
+ arcgisuserIndexes,
+ arcgisuserForeignKeys,
+ arcgisuserUniques,
+ arcgisuserChecks,
+]{
+ Schema: "arcgis",
+ Name: "user_",
+ Columns: arcgisuserColumns{
+ Access: column{
+ Name: "access",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Created: column{
+ Name: "created",
+ DBType: "timestamp without time zone",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Email: column{
+ Name: "email",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ FullName: column{
+ Name: "full_name",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ ID: column{
+ Name: "id",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Level: column{
+ Name: "level",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ OrgID: column{
+ Name: "org_id",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ PublicUserID: column{
+ Name: "public_user_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Region: column{
+ Name: "region",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Role: column{
+ Name: "role",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ RoleID: column{
+ Name: "role_id",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Username: column{
+ Name: "username",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ UserLicenseTypeID: column{
+ Name: "user_license_type_id",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ UserType: column{
+ Name: "user_type",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: arcgisuserIndexes{
+ UserPkey: index{
+ Type: "btree",
+ Name: "user__pkey",
+ Columns: []indexColumn{
+ {
+ Name: "id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "user__pkey",
+ Columns: []string{"id"},
+ Comment: "",
+ },
+ ForeignKeys: arcgisuserForeignKeys{
+ ArcgisUserUserPublicUserIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "arcgis.user_.user__public_user_id_fkey",
+ Columns: []string{"public_user_id"},
+ Comment: "",
+ },
+ ForeignTable: "user_",
+ ForeignColumns: []string{"id"},
+ },
+ },
+
+ Comment: "",
+}
+
+type arcgisuserColumns struct {
+ Access column
+ Created column
+ Email column
+ FullName column
+ ID column
+ Level column
+ OrgID column
+ PublicUserID column
+ Region column
+ Role column
+ RoleID column
+ Username column
+ UserLicenseTypeID column
+ UserType column
+}
+
+func (c arcgisuserColumns) AsSlice() []column {
+ return []column{
+ c.Access, c.Created, c.Email, c.FullName, c.ID, c.Level, c.OrgID, c.PublicUserID, c.Region, c.Role, c.RoleID, c.Username, c.UserLicenseTypeID, c.UserType,
+ }
+}
+
+type arcgisuserIndexes struct {
+ UserPkey index
+}
+
+func (i arcgisuserIndexes) AsSlice() []index {
+ return []index{
+ i.UserPkey,
+ }
+}
+
+type arcgisuserForeignKeys struct {
+ ArcgisUserUserPublicUserIDFkey foreignKey
+}
+
+func (f arcgisuserForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.ArcgisUserUserPublicUserIDFkey,
+ }
+}
+
+type arcgisuserUniques struct{}
+
+func (u arcgisuserUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type arcgisuserChecks struct{}
+
+func (c arcgisuserChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/arcgis.user_privilege.bob.go b/db/dbinfo/arcgis.user_privilege.bob.go
new file mode 100644
index 00000000..88e2785f
--- /dev/null
+++ b/db/dbinfo/arcgis.user_privilege.bob.go
@@ -0,0 +1,122 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var ArcgisUserPrivileges = Table[
+ arcgisUserPrivilegeColumns,
+ arcgisUserPrivilegeIndexes,
+ arcgisUserPrivilegeForeignKeys,
+ arcgisUserPrivilegeUniques,
+ arcgisUserPrivilegeChecks,
+]{
+ Schema: "arcgis",
+ Name: "user_privilege",
+ Columns: arcgisUserPrivilegeColumns{
+ UserID: column{
+ Name: "user_id",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Privilege: column{
+ Name: "privilege",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: arcgisUserPrivilegeIndexes{
+ UserPrivilegePkey: index{
+ Type: "btree",
+ Name: "user_privilege_pkey",
+ Columns: []indexColumn{
+ {
+ Name: "user_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ {
+ Name: "privilege",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false, false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "user_privilege_pkey",
+ Columns: []string{"user_id", "privilege"},
+ Comment: "",
+ },
+ ForeignKeys: arcgisUserPrivilegeForeignKeys{
+ ArcgisUserPrivilegeUserPrivilegeUserIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "arcgis.user_privilege.user_privilege_user_id_fkey",
+ Columns: []string{"user_id"},
+ Comment: "",
+ },
+ ForeignTable: "arcgis.user_",
+ ForeignColumns: []string{"id"},
+ },
+ },
+
+ Comment: "",
+}
+
+type arcgisUserPrivilegeColumns struct {
+ UserID column
+ Privilege column
+}
+
+func (c arcgisUserPrivilegeColumns) AsSlice() []column {
+ return []column{
+ c.UserID, c.Privilege,
+ }
+}
+
+type arcgisUserPrivilegeIndexes struct {
+ UserPrivilegePkey index
+}
+
+func (i arcgisUserPrivilegeIndexes) AsSlice() []index {
+ return []index{
+ i.UserPrivilegePkey,
+ }
+}
+
+type arcgisUserPrivilegeForeignKeys struct {
+ ArcgisUserPrivilegeUserPrivilegeUserIDFkey foreignKey
+}
+
+func (f arcgisUserPrivilegeForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.ArcgisUserPrivilegeUserPrivilegeUserIDFkey,
+ }
+}
+
+type arcgisUserPrivilegeUniques struct{}
+
+func (u arcgisUserPrivilegeUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type arcgisUserPrivilegeChecks struct{}
+
+func (c arcgisUserPrivilegeChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/bob_types.bob.go b/db/dbinfo/bob_types.bob.go
index 53d5f9be..2ece4dab 100644
--- a/db/dbinfo/bob_types.bob.go
+++ b/db/dbinfo/bob_types.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/district.bob.go b/db/dbinfo/district.bob.go
index 11976f13..1cbd0a70 100644
--- a/db/dbinfo/district.bob.go
+++ b/db/dbinfo/district.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.containerrelate.bob.go b/db/dbinfo/fieldseeker.containerrelate.bob.go
index e7f9fe89..9b293435 100644
--- a/db/dbinfo/fieldseeker.containerrelate.bob.go
+++ b/db/dbinfo/fieldseeker.containerrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go
index c506a744..7a8b2e88 100644
--- a/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go
+++ b/db/dbinfo/fieldseeker.fieldscoutinglog.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.habitatrelate.bob.go b/db/dbinfo/fieldseeker.habitatrelate.bob.go
index b19ac6ac..5b7eef2f 100644
--- a/db/dbinfo/fieldseeker.habitatrelate.bob.go
+++ b/db/dbinfo/fieldseeker.habitatrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.inspectionsample.bob.go b/db/dbinfo/fieldseeker.inspectionsample.bob.go
index d2e307a2..7222c516 100644
--- a/db/dbinfo/fieldseeker.inspectionsample.bob.go
+++ b/db/dbinfo/fieldseeker.inspectionsample.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go
index 6587df5f..9bfee61f 100644
--- a/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go
+++ b/db/dbinfo/fieldseeker.inspectionsampledetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.linelocation.bob.go b/db/dbinfo/fieldseeker.linelocation.bob.go
index ef4c5c02..426609fa 100644
--- a/db/dbinfo/fieldseeker.linelocation.bob.go
+++ b/db/dbinfo/fieldseeker.linelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.locationtracking.bob.go b/db/dbinfo/fieldseeker.locationtracking.bob.go
index 65aba4b0..fa3d2922 100644
--- a/db/dbinfo/fieldseeker.locationtracking.bob.go
+++ b/db/dbinfo/fieldseeker.locationtracking.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go
index 15436115..333ae452 100644
--- a/db/dbinfo/fieldseeker.mosquitoinspection.bob.go
+++ b/db/dbinfo/fieldseeker.mosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.pointlocation.bob.go b/db/dbinfo/fieldseeker.pointlocation.bob.go
index 999e6ef6..5f65e44a 100644
--- a/db/dbinfo/fieldseeker.pointlocation.bob.go
+++ b/db/dbinfo/fieldseeker.pointlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.polygonlocation.bob.go b/db/dbinfo/fieldseeker.polygonlocation.bob.go
index 835412ab..e200e6c7 100644
--- a/db/dbinfo/fieldseeker.polygonlocation.bob.go
+++ b/db/dbinfo/fieldseeker.polygonlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.pool.bob.go b/db/dbinfo/fieldseeker.pool.bob.go
index 51158097..9f359745 100644
--- a/db/dbinfo/fieldseeker.pool.bob.go
+++ b/db/dbinfo/fieldseeker.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.pooldetail.bob.go b/db/dbinfo/fieldseeker.pooldetail.bob.go
index 65c5b988..b3a9e700 100644
--- a/db/dbinfo/fieldseeker.pooldetail.bob.go
+++ b/db/dbinfo/fieldseeker.pooldetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go
index 8ae3d2f6..f85288c6 100644
--- a/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go
+++ b/db/dbinfo/fieldseeker.proposedtreatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go
index c841701d..76da7dd7 100644
--- a/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go
+++ b/db/dbinfo/fieldseeker.qamosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.rodentlocation.bob.go b/db/dbinfo/fieldseeker.rodentlocation.bob.go
index 5e57a239..8713d101 100644
--- a/db/dbinfo/fieldseeker.rodentlocation.bob.go
+++ b/db/dbinfo/fieldseeker.rodentlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.samplecollection.bob.go b/db/dbinfo/fieldseeker.samplecollection.bob.go
index a22bc7ec..a205203b 100644
--- a/db/dbinfo/fieldseeker.samplecollection.bob.go
+++ b/db/dbinfo/fieldseeker.samplecollection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.samplelocation.bob.go b/db/dbinfo/fieldseeker.samplelocation.bob.go
index 89007afd..1f63b1c4 100644
--- a/db/dbinfo/fieldseeker.samplelocation.bob.go
+++ b/db/dbinfo/fieldseeker.samplelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.servicerequest.bob.go b/db/dbinfo/fieldseeker.servicerequest.bob.go
index 92a55390..30de6afe 100644
--- a/db/dbinfo/fieldseeker.servicerequest.bob.go
+++ b/db/dbinfo/fieldseeker.servicerequest.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.speciesabundance.bob.go b/db/dbinfo/fieldseeker.speciesabundance.bob.go
index 3d67c19a..7431468f 100644
--- a/db/dbinfo/fieldseeker.speciesabundance.bob.go
+++ b/db/dbinfo/fieldseeker.speciesabundance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.stormdrain.bob.go b/db/dbinfo/fieldseeker.stormdrain.bob.go
index 931622c0..412832a3 100644
--- a/db/dbinfo/fieldseeker.stormdrain.bob.go
+++ b/db/dbinfo/fieldseeker.stormdrain.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.timecard.bob.go b/db/dbinfo/fieldseeker.timecard.bob.go
index d635a67a..65b6a792 100644
--- a/db/dbinfo/fieldseeker.timecard.bob.go
+++ b/db/dbinfo/fieldseeker.timecard.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.trapdata.bob.go b/db/dbinfo/fieldseeker.trapdata.bob.go
index 14f83873..2c7c523f 100644
--- a/db/dbinfo/fieldseeker.trapdata.bob.go
+++ b/db/dbinfo/fieldseeker.trapdata.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.traplocation.bob.go b/db/dbinfo/fieldseeker.traplocation.bob.go
index b2563629..cc3cda90 100644
--- a/db/dbinfo/fieldseeker.traplocation.bob.go
+++ b/db/dbinfo/fieldseeker.traplocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.treatment.bob.go b/db/dbinfo/fieldseeker.treatment.bob.go
index 914c0532..b6a0075e 100644
--- a/db/dbinfo/fieldseeker.treatment.bob.go
+++ b/db/dbinfo/fieldseeker.treatment.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.treatmentarea.bob.go b/db/dbinfo/fieldseeker.treatmentarea.bob.go
index f4dbf8b7..d9df5b58 100644
--- a/db/dbinfo/fieldseeker.treatmentarea.bob.go
+++ b/db/dbinfo/fieldseeker.treatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.zones.bob.go b/db/dbinfo/fieldseeker.zones.bob.go
index eb1ecf75..1cd771cd 100644
--- a/db/dbinfo/fieldseeker.zones.bob.go
+++ b/db/dbinfo/fieldseeker.zones.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker.zones2.bob.go b/db/dbinfo/fieldseeker.zones2.bob.go
index 6d26143d..7a55e0e8 100644
--- a/db/dbinfo/fieldseeker.zones2.bob.go
+++ b/db/dbinfo/fieldseeker.zones2.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/fieldseeker_sync.bob.go b/db/dbinfo/fieldseeker_sync.bob.go
index 6a53ec8e..f0d18f63 100644
--- a/db/dbinfo/fieldseeker_sync.bob.go
+++ b/db/dbinfo/fieldseeker_sync.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/geography_columns.bob.go b/db/dbinfo/geography_columns.bob.go
index 0cd86251..fede3218 100644
--- a/db/dbinfo/geography_columns.bob.go
+++ b/db/dbinfo/geography_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/geometry_columns.bob.go b/db/dbinfo/geometry_columns.bob.go
index c560a3d8..2292ee9a 100644
--- a/db/dbinfo/geometry_columns.bob.go
+++ b/db/dbinfo/geometry_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/goose_db_version.bob.go b/db/dbinfo/goose_db_version.bob.go
index 60d0e295..9bda0126 100644
--- a/db/dbinfo/goose_db_version.bob.go
+++ b/db/dbinfo/goose_db_version.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/h3_aggregation.bob.go b/db/dbinfo/h3_aggregation.bob.go
index 3f640a73..65bd6414 100644
--- a/db/dbinfo/h3_aggregation.bob.go
+++ b/db/dbinfo/h3_aggregation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_audio.bob.go b/db/dbinfo/note_audio.bob.go
index 413aa3e6..4725221d 100644
--- a/db/dbinfo/note_audio.bob.go
+++ b/db/dbinfo/note_audio.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_audio_breadcrumb.bob.go b/db/dbinfo/note_audio_breadcrumb.bob.go
index 9031f61a..0f6e5248 100644
--- a/db/dbinfo/note_audio_breadcrumb.bob.go
+++ b/db/dbinfo/note_audio_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_audio_data.bob.go b/db/dbinfo/note_audio_data.bob.go
index 20b42526..8e3dae3f 100644
--- a/db/dbinfo/note_audio_data.bob.go
+++ b/db/dbinfo/note_audio_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_image.bob.go b/db/dbinfo/note_image.bob.go
index 36545e55..89a0dccd 100644
--- a/db/dbinfo/note_image.bob.go
+++ b/db/dbinfo/note_image.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_image_breadcrumb.bob.go b/db/dbinfo/note_image_breadcrumb.bob.go
index a7dd7323..7824d997 100644
--- a/db/dbinfo/note_image_breadcrumb.bob.go
+++ b/db/dbinfo/note_image_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/note_image_data.bob.go b/db/dbinfo/note_image_data.bob.go
index be198b8f..dade46b3 100644
--- a/db/dbinfo/note_image_data.bob.go
+++ b/db/dbinfo/note_image_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/notification.bob.go b/db/dbinfo/notification.bob.go
index b4869c9a..b405ed17 100644
--- a/db/dbinfo/notification.bob.go
+++ b/db/dbinfo/notification.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/oauth_token.bob.go b/db/dbinfo/oauth_token.bob.go
index e72e1cb2..e7ae9dcf 100644
--- a/db/dbinfo/oauth_token.bob.go
+++ b/db/dbinfo/oauth_token.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go
index c65f22a4..3539999d 100644
--- a/db/dbinfo/organization.bob.go
+++ b/db/dbinfo/organization.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.nuisance.bob.go b/db/dbinfo/publicreport.nuisance.bob.go
index 4eef190c..625162eb 100644
--- a/db/dbinfo/publicreport.nuisance.bob.go
+++ b/db/dbinfo/publicreport.nuisance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.pool.bob.go b/db/dbinfo/publicreport.pool.bob.go
index 482e9357..045b24d7 100644
--- a/db/dbinfo/publicreport.pool.bob.go
+++ b/db/dbinfo/publicreport.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.pool_photo.bob.go b/db/dbinfo/publicreport.pool_photo.bob.go
index 8d22839c..8b116463 100644
--- a/db/dbinfo/publicreport.pool_photo.bob.go
+++ b/db/dbinfo/publicreport.pool_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.quick.bob.go b/db/dbinfo/publicreport.quick.bob.go
index eacf3433..77afb678 100644
--- a/db/dbinfo/publicreport.quick.bob.go
+++ b/db/dbinfo/publicreport.quick.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.quick_photo.bob.go b/db/dbinfo/publicreport.quick_photo.bob.go
index 9a7d4eca..f827d142 100644
--- a/db/dbinfo/publicreport.quick_photo.bob.go
+++ b/db/dbinfo/publicreport.quick_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/publicreport.report_location.bob.go b/db/dbinfo/publicreport.report_location.bob.go
index f59c9427..92fa50fe 100644
--- a/db/dbinfo/publicreport.report_location.bob.go
+++ b/db/dbinfo/publicreport.report_location.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/raster_columns.bob.go b/db/dbinfo/raster_columns.bob.go
index 485a0e21..a7d56223 100644
--- a/db/dbinfo/raster_columns.bob.go
+++ b/db/dbinfo/raster_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/raster_overviews.bob.go b/db/dbinfo/raster_overviews.bob.go
index 40e7ff4b..7199817b 100644
--- a/db/dbinfo/raster_overviews.bob.go
+++ b/db/dbinfo/raster_overviews.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/sessions.bob.go b/db/dbinfo/sessions.bob.go
index 365152f9..4f66b5ce 100644
--- a/db/dbinfo/sessions.bob.go
+++ b/db/dbinfo/sessions.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/spatial_ref_sys.bob.go b/db/dbinfo/spatial_ref_sys.bob.go
index cd06d3f8..78b5a363 100644
--- a/db/dbinfo/spatial_ref_sys.bob.go
+++ b/db/dbinfo/spatial_ref_sys.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/dbinfo/user_.bob.go b/db/dbinfo/user_.bob.go
index 556adb13..b72cfaf4 100644
--- a/db/dbinfo/user_.bob.go
+++ b/db/dbinfo/user_.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package dbinfo
diff --git a/db/enums/enums.bob.go b/db/enums/enums.bob.go
index ff1c3c5b..34c6ec6f 100644
--- a/db/enums/enums.bob.go
+++ b/db/enums/enums.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package enums
diff --git a/db/factory/arcgis.user_.bob.go b/db/factory/arcgis.user_.bob.go
new file mode 100644
index 00000000..43969366
--- /dev/null
+++ b/db/factory/arcgis.user_.bob.go
@@ -0,0 +1,984 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type ArcgisUserMod interface {
+ Apply(context.Context, *ArcgisUserTemplate)
+}
+
+type ArcgisUserModFunc func(context.Context, *ArcgisUserTemplate)
+
+func (f ArcgisUserModFunc) Apply(ctx context.Context, n *ArcgisUserTemplate) {
+ f(ctx, n)
+}
+
+type ArcgisUserModSlice []ArcgisUserMod
+
+func (mods ArcgisUserModSlice) Apply(ctx context.Context, n *ArcgisUserTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// ArcgisUserTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type ArcgisUserTemplate struct {
+ Access func() string
+ Created func() time.Time
+ Email func() string
+ FullName func() string
+ ID func() string
+ Level func() string
+ OrgID func() string
+ PublicUserID func() int32
+ Region func() string
+ Role func() string
+ RoleID func() string
+ Username func() string
+ UserLicenseTypeID func() string
+ UserType func() string
+
+ r arcgisuserR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type arcgisuserR struct {
+ PublicUserUser *arcgisuserRPublicUserUserR
+ UserUserPrivileges []*arcgisuserRUserUserPrivilegesR
+}
+
+type arcgisuserRPublicUserUserR struct {
+ o *UserTemplate
+}
+type arcgisuserRUserUserPrivilegesR struct {
+ number int
+ o *ArcgisUserPrivilegeTemplate
+}
+
+// Apply mods to the ArcgisUserTemplate
+func (o *ArcgisUserTemplate) Apply(ctx context.Context, mods ...ArcgisUserMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.ArcgisUser
+// according to the relationships in the template. Nothing is inserted into the db
+func (t ArcgisUserTemplate) setModelRels(o *models.ArcgisUser) {
+ if t.r.PublicUserUser != nil {
+ rel := t.r.PublicUserUser.o.Build()
+ rel.R.PublicUserUser = append(rel.R.PublicUserUser, o)
+ o.PublicUserID = rel.ID // h2
+ o.R.PublicUserUser = rel
+ }
+
+ if t.r.UserUserPrivileges != nil {
+ rel := models.ArcgisUserPrivilegeSlice{}
+ for _, r := range t.r.UserUserPrivileges {
+ related := r.o.BuildMany(r.number)
+ for _, rel := range related {
+ rel.UserID = o.ID // h2
+ rel.R.UserUser = o
+ }
+ rel = append(rel, related...)
+ }
+ o.R.UserUserPrivileges = rel
+ }
+}
+
+// BuildSetter returns an *models.ArcgisUserSetter
+// this does nothing with the relationship templates
+func (o ArcgisUserTemplate) BuildSetter() *models.ArcgisUserSetter {
+ m := &models.ArcgisUserSetter{}
+
+ if o.Access != nil {
+ val := o.Access()
+ m.Access = omit.From(val)
+ }
+ if o.Created != nil {
+ val := o.Created()
+ m.Created = omit.From(val)
+ }
+ if o.Email != nil {
+ val := o.Email()
+ m.Email = omit.From(val)
+ }
+ if o.FullName != nil {
+ val := o.FullName()
+ m.FullName = omit.From(val)
+ }
+ if o.ID != nil {
+ val := o.ID()
+ m.ID = omit.From(val)
+ }
+ if o.Level != nil {
+ val := o.Level()
+ m.Level = omit.From(val)
+ }
+ if o.OrgID != nil {
+ val := o.OrgID()
+ m.OrgID = omit.From(val)
+ }
+ if o.PublicUserID != nil {
+ val := o.PublicUserID()
+ m.PublicUserID = omit.From(val)
+ }
+ if o.Region != nil {
+ val := o.Region()
+ m.Region = omit.From(val)
+ }
+ if o.Role != nil {
+ val := o.Role()
+ m.Role = omit.From(val)
+ }
+ if o.RoleID != nil {
+ val := o.RoleID()
+ m.RoleID = omit.From(val)
+ }
+ if o.Username != nil {
+ val := o.Username()
+ m.Username = omit.From(val)
+ }
+ if o.UserLicenseTypeID != nil {
+ val := o.UserLicenseTypeID()
+ m.UserLicenseTypeID = omit.From(val)
+ }
+ if o.UserType != nil {
+ val := o.UserType()
+ m.UserType = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.ArcgisUserSetter
+// this does nothing with the relationship templates
+func (o ArcgisUserTemplate) BuildManySetter(number int) []*models.ArcgisUserSetter {
+ m := make([]*models.ArcgisUserSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.ArcgisUser
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use ArcgisUserTemplate.Create
+func (o ArcgisUserTemplate) Build() *models.ArcgisUser {
+ m := &models.ArcgisUser{}
+
+ if o.Access != nil {
+ m.Access = o.Access()
+ }
+ if o.Created != nil {
+ m.Created = o.Created()
+ }
+ if o.Email != nil {
+ m.Email = o.Email()
+ }
+ if o.FullName != nil {
+ m.FullName = o.FullName()
+ }
+ if o.ID != nil {
+ m.ID = o.ID()
+ }
+ if o.Level != nil {
+ m.Level = o.Level()
+ }
+ if o.OrgID != nil {
+ m.OrgID = o.OrgID()
+ }
+ if o.PublicUserID != nil {
+ m.PublicUserID = o.PublicUserID()
+ }
+ if o.Region != nil {
+ m.Region = o.Region()
+ }
+ if o.Role != nil {
+ m.Role = o.Role()
+ }
+ if o.RoleID != nil {
+ m.RoleID = o.RoleID()
+ }
+ if o.Username != nil {
+ m.Username = o.Username()
+ }
+ if o.UserLicenseTypeID != nil {
+ m.UserLicenseTypeID = o.UserLicenseTypeID()
+ }
+ if o.UserType != nil {
+ m.UserType = o.UserType()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.ArcgisUserSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use ArcgisUserTemplate.CreateMany
+func (o ArcgisUserTemplate) BuildMany(number int) models.ArcgisUserSlice {
+ m := make(models.ArcgisUserSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatableArcgisUser(m *models.ArcgisUserSetter) {
+ if !(m.Access.IsValue()) {
+ val := random_string(nil)
+ m.Access = omit.From(val)
+ }
+ if !(m.Created.IsValue()) {
+ val := random_time_Time(nil)
+ m.Created = omit.From(val)
+ }
+ if !(m.Email.IsValue()) {
+ val := random_string(nil)
+ m.Email = omit.From(val)
+ }
+ if !(m.FullName.IsValue()) {
+ val := random_string(nil)
+ m.FullName = omit.From(val)
+ }
+ if !(m.ID.IsValue()) {
+ val := random_string(nil)
+ m.ID = omit.From(val)
+ }
+ if !(m.Level.IsValue()) {
+ val := random_string(nil)
+ m.Level = omit.From(val)
+ }
+ if !(m.OrgID.IsValue()) {
+ val := random_string(nil)
+ m.OrgID = omit.From(val)
+ }
+ if !(m.PublicUserID.IsValue()) {
+ val := random_int32(nil)
+ m.PublicUserID = omit.From(val)
+ }
+ if !(m.Region.IsValue()) {
+ val := random_string(nil)
+ m.Region = omit.From(val)
+ }
+ if !(m.Role.IsValue()) {
+ val := random_string(nil)
+ m.Role = omit.From(val)
+ }
+ if !(m.RoleID.IsValue()) {
+ val := random_string(nil)
+ m.RoleID = omit.From(val)
+ }
+ if !(m.Username.IsValue()) {
+ val := random_string(nil)
+ m.Username = omit.From(val)
+ }
+ if !(m.UserLicenseTypeID.IsValue()) {
+ val := random_string(nil)
+ m.UserLicenseTypeID = omit.From(val)
+ }
+ if !(m.UserType.IsValue()) {
+ val := random_string(nil)
+ m.UserType = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.ArcgisUser
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *ArcgisUserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisUser) error {
+ var err error
+
+ isUserUserPrivilegesDone, _ := arcgisuserRelUserUserPrivilegesCtx.Value(ctx)
+ if !isUserUserPrivilegesDone && o.r.UserUserPrivileges != nil {
+ ctx = arcgisuserRelUserUserPrivilegesCtx.WithValue(ctx, true)
+ for _, r := range o.r.UserUserPrivileges {
+ if r.o.alreadyPersisted {
+ m.R.UserUserPrivileges = append(m.R.UserUserPrivileges, r.o.Build())
+ } else {
+ rel1, err := r.o.CreateMany(ctx, exec, r.number)
+ if err != nil {
+ return err
+ }
+
+ err = m.AttachUserUserPrivileges(ctx, exec, rel1...)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+
+ return err
+}
+
+// Create builds a arcgisuser and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *ArcgisUserTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisUser, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatableArcgisUser(opt)
+
+ if o.r.PublicUserUser == nil {
+ ArcgisUserMods.WithNewPublicUserUser().Apply(ctx, o)
+ }
+
+ var rel0 *models.User
+
+ if o.r.PublicUserUser.o.alreadyPersisted {
+ rel0 = o.r.PublicUserUser.o.Build()
+ } else {
+ rel0, err = o.r.PublicUserUser.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.PublicUserID = omit.From(rel0.ID)
+
+ m, err := models.ArcgisUsers.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ m.R.PublicUserUser = rel0
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a arcgisuser and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *ArcgisUserTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisUser {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a arcgisuser and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *ArcgisUserTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisUser {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple arcgisusers and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o ArcgisUserTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisUserSlice, error) {
+ var err error
+ m := make(models.ArcgisUserSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple arcgisusers and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o ArcgisUserTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisUserSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple arcgisusers and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o ArcgisUserTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisUserSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// ArcgisUser has methods that act as mods for the ArcgisUserTemplate
+var ArcgisUserMods arcgisuserMods
+
+type arcgisuserMods struct{}
+
+func (m arcgisuserMods) RandomizeAllColumns(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModSlice{
+ ArcgisUserMods.RandomAccess(f),
+ ArcgisUserMods.RandomCreated(f),
+ ArcgisUserMods.RandomEmail(f),
+ ArcgisUserMods.RandomFullName(f),
+ ArcgisUserMods.RandomID(f),
+ ArcgisUserMods.RandomLevel(f),
+ ArcgisUserMods.RandomOrgID(f),
+ ArcgisUserMods.RandomPublicUserID(f),
+ ArcgisUserMods.RandomRegion(f),
+ ArcgisUserMods.RandomRole(f),
+ ArcgisUserMods.RandomRoleID(f),
+ ArcgisUserMods.RandomUsername(f),
+ ArcgisUserMods.RandomUserLicenseTypeID(f),
+ ArcgisUserMods.RandomUserType(f),
+ }
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Access(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Access = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) AccessFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Access = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetAccess() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Access = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomAccess(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Access = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Created(val time.Time) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Created = func() time.Time { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) CreatedFunc(f func() time.Time) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Created = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetCreated() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Created = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomCreated(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Created = func() time.Time {
+ return random_time_Time(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Email(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Email = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) EmailFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Email = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetEmail() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Email = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomEmail(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Email = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) FullName(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.FullName = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) FullNameFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.FullName = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetFullName() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.FullName = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomFullName(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.FullName = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) ID(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.ID = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) IDFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.ID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetID() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.ID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomID(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.ID = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Level(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Level = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) LevelFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Level = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetLevel() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Level = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomLevel(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Level = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) OrgID(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.OrgID = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) OrgIDFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.OrgID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetOrgID() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.OrgID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomOrgID(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.OrgID = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) PublicUserID(val int32) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.PublicUserID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) PublicUserIDFunc(f func() int32) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.PublicUserID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetPublicUserID() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.PublicUserID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomPublicUserID(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.PublicUserID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Region(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Region = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) RegionFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Region = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetRegion() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Region = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomRegion(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Region = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Role(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Role = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) RoleFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Role = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetRole() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Role = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomRole(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Role = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) RoleID(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.RoleID = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) RoleIDFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.RoleID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetRoleID() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.RoleID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomRoleID(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.RoleID = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) Username(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Username = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) UsernameFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Username = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetUsername() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Username = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomUsername(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.Username = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) UserLicenseTypeID(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserLicenseTypeID = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) UserLicenseTypeIDFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserLicenseTypeID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetUserLicenseTypeID() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserLicenseTypeID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomUserLicenseTypeID(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserLicenseTypeID = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisuserMods) UserType(val string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserType = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisuserMods) UserTypeFunc(f func() string) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserType = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisuserMods) UnsetUserType() ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserType = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisuserMods) RandomUserType(f *faker.Faker) ArcgisUserMod {
+ return ArcgisUserModFunc(func(_ context.Context, o *ArcgisUserTemplate) {
+ o.UserType = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+func (m arcgisuserMods) WithParentsCascading() ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ if isDone, _ := arcgisuserWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = arcgisuserWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading())
+ m.WithPublicUserUser(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m arcgisuserMods) WithPublicUserUser(rel *UserTemplate) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.PublicUserUser = &arcgisuserRPublicUserUserR{
+ o: rel,
+ }
+ })
+}
+
+func (m arcgisuserMods) WithNewPublicUserUser(mods ...UserMod) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ related := o.f.NewUserWithContext(ctx, mods...)
+
+ m.WithPublicUserUser(related).Apply(ctx, o)
+ })
+}
+
+func (m arcgisuserMods) WithExistingPublicUserUser(em *models.User) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.PublicUserUser = &arcgisuserRPublicUserUserR{
+ o: o.f.FromExistingUser(em),
+ }
+ })
+}
+
+func (m arcgisuserMods) WithoutPublicUserUser() ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.PublicUserUser = nil
+ })
+}
+
+func (m arcgisuserMods) WithUserUserPrivileges(number int, related *ArcgisUserPrivilegeTemplate) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.UserUserPrivileges = []*arcgisuserRUserUserPrivilegesR{{
+ number: number,
+ o: related,
+ }}
+ })
+}
+
+func (m arcgisuserMods) WithNewUserUserPrivileges(number int, mods ...ArcgisUserPrivilegeMod) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ related := o.f.NewArcgisUserPrivilegeWithContext(ctx, mods...)
+ m.WithUserUserPrivileges(number, related).Apply(ctx, o)
+ })
+}
+
+func (m arcgisuserMods) AddUserUserPrivileges(number int, related *ArcgisUserPrivilegeTemplate) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.UserUserPrivileges = append(o.r.UserUserPrivileges, &arcgisuserRUserUserPrivilegesR{
+ number: number,
+ o: related,
+ })
+ })
+}
+
+func (m arcgisuserMods) AddNewUserUserPrivileges(number int, mods ...ArcgisUserPrivilegeMod) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ related := o.f.NewArcgisUserPrivilegeWithContext(ctx, mods...)
+ m.AddUserUserPrivileges(number, related).Apply(ctx, o)
+ })
+}
+
+func (m arcgisuserMods) AddExistingUserUserPrivileges(existingModels ...*models.ArcgisUserPrivilege) ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ for _, em := range existingModels {
+ o.r.UserUserPrivileges = append(o.r.UserUserPrivileges, &arcgisuserRUserUserPrivilegesR{
+ o: o.f.FromExistingArcgisUserPrivilege(em),
+ })
+ }
+ })
+}
+
+func (m arcgisuserMods) WithoutUserUserPrivileges() ArcgisUserMod {
+ return ArcgisUserModFunc(func(ctx context.Context, o *ArcgisUserTemplate) {
+ o.r.UserUserPrivileges = nil
+ })
+}
diff --git a/db/factory/arcgis.user_privilege.bob.go b/db/factory/arcgis.user_privilege.bob.go
new file mode 100644
index 00000000..37ed5e39
--- /dev/null
+++ b/db/factory/arcgis.user_privilege.bob.go
@@ -0,0 +1,369 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type ArcgisUserPrivilegeMod interface {
+ Apply(context.Context, *ArcgisUserPrivilegeTemplate)
+}
+
+type ArcgisUserPrivilegeModFunc func(context.Context, *ArcgisUserPrivilegeTemplate)
+
+func (f ArcgisUserPrivilegeModFunc) Apply(ctx context.Context, n *ArcgisUserPrivilegeTemplate) {
+ f(ctx, n)
+}
+
+type ArcgisUserPrivilegeModSlice []ArcgisUserPrivilegeMod
+
+func (mods ArcgisUserPrivilegeModSlice) Apply(ctx context.Context, n *ArcgisUserPrivilegeTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// ArcgisUserPrivilegeTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type ArcgisUserPrivilegeTemplate struct {
+ UserID func() string
+ Privilege func() string
+
+ r arcgisUserPrivilegeR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type arcgisUserPrivilegeR struct {
+ UserUser *arcgisUserPrivilegeRUserUserR
+}
+
+type arcgisUserPrivilegeRUserUserR struct {
+ o *ArcgisUserTemplate
+}
+
+// Apply mods to the ArcgisUserPrivilegeTemplate
+func (o *ArcgisUserPrivilegeTemplate) Apply(ctx context.Context, mods ...ArcgisUserPrivilegeMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.ArcgisUserPrivilege
+// according to the relationships in the template. Nothing is inserted into the db
+func (t ArcgisUserPrivilegeTemplate) setModelRels(o *models.ArcgisUserPrivilege) {
+ if t.r.UserUser != nil {
+ rel := t.r.UserUser.o.Build()
+ rel.R.UserUserPrivileges = append(rel.R.UserUserPrivileges, o)
+ o.UserID = rel.ID // h2
+ o.R.UserUser = rel
+ }
+}
+
+// BuildSetter returns an *models.ArcgisUserPrivilegeSetter
+// this does nothing with the relationship templates
+func (o ArcgisUserPrivilegeTemplate) BuildSetter() *models.ArcgisUserPrivilegeSetter {
+ m := &models.ArcgisUserPrivilegeSetter{}
+
+ if o.UserID != nil {
+ val := o.UserID()
+ m.UserID = omit.From(val)
+ }
+ if o.Privilege != nil {
+ val := o.Privilege()
+ m.Privilege = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.ArcgisUserPrivilegeSetter
+// this does nothing with the relationship templates
+func (o ArcgisUserPrivilegeTemplate) BuildManySetter(number int) []*models.ArcgisUserPrivilegeSetter {
+ m := make([]*models.ArcgisUserPrivilegeSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.ArcgisUserPrivilege
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use ArcgisUserPrivilegeTemplate.Create
+func (o ArcgisUserPrivilegeTemplate) Build() *models.ArcgisUserPrivilege {
+ m := &models.ArcgisUserPrivilege{}
+
+ if o.UserID != nil {
+ m.UserID = o.UserID()
+ }
+ if o.Privilege != nil {
+ m.Privilege = o.Privilege()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.ArcgisUserPrivilegeSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use ArcgisUserPrivilegeTemplate.CreateMany
+func (o ArcgisUserPrivilegeTemplate) BuildMany(number int) models.ArcgisUserPrivilegeSlice {
+ m := make(models.ArcgisUserPrivilegeSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatableArcgisUserPrivilege(m *models.ArcgisUserPrivilegeSetter) {
+ if !(m.UserID.IsValue()) {
+ val := random_string(nil)
+ m.UserID = omit.From(val)
+ }
+ if !(m.Privilege.IsValue()) {
+ val := random_string(nil)
+ m.Privilege = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.ArcgisUserPrivilege
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *ArcgisUserPrivilegeTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisUserPrivilege) error {
+ var err error
+
+ return err
+}
+
+// Create builds a arcgisUserPrivilege and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *ArcgisUserPrivilegeTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisUserPrivilege, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatableArcgisUserPrivilege(opt)
+
+ if o.r.UserUser == nil {
+ ArcgisUserPrivilegeMods.WithNewUserUser().Apply(ctx, o)
+ }
+
+ var rel0 *models.ArcgisUser
+
+ if o.r.UserUser.o.alreadyPersisted {
+ rel0 = o.r.UserUser.o.Build()
+ } else {
+ rel0, err = o.r.UserUser.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.UserID = omit.From(rel0.ID)
+
+ m, err := models.ArcgisUserPrivileges.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ m.R.UserUser = rel0
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a arcgisUserPrivilege and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *ArcgisUserPrivilegeTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisUserPrivilege {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a arcgisUserPrivilege and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *ArcgisUserPrivilegeTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisUserPrivilege {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple arcgisUserPrivileges and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o ArcgisUserPrivilegeTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisUserPrivilegeSlice, error) {
+ var err error
+ m := make(models.ArcgisUserPrivilegeSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple arcgisUserPrivileges and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o ArcgisUserPrivilegeTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisUserPrivilegeSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple arcgisUserPrivileges and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o ArcgisUserPrivilegeTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisUserPrivilegeSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// ArcgisUserPrivilege has methods that act as mods for the ArcgisUserPrivilegeTemplate
+var ArcgisUserPrivilegeMods arcgisUserPrivilegeMods
+
+type arcgisUserPrivilegeMods struct{}
+
+func (m arcgisUserPrivilegeMods) RandomizeAllColumns(f *faker.Faker) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModSlice{
+ ArcgisUserPrivilegeMods.RandomUserID(f),
+ ArcgisUserPrivilegeMods.RandomPrivilege(f),
+ }
+}
+
+// Set the model columns to this value
+func (m arcgisUserPrivilegeMods) UserID(val string) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.UserID = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisUserPrivilegeMods) UserIDFunc(f func() string) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.UserID = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisUserPrivilegeMods) UnsetUserID() ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.UserID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisUserPrivilegeMods) RandomUserID(f *faker.Faker) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.UserID = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m arcgisUserPrivilegeMods) Privilege(val string) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.Privilege = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m arcgisUserPrivilegeMods) PrivilegeFunc(f func() string) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.Privilege = f
+ })
+}
+
+// Clear any values for the column
+func (m arcgisUserPrivilegeMods) UnsetPrivilege() ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.Privilege = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m arcgisUserPrivilegeMods) RandomPrivilege(f *faker.Faker) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(_ context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.Privilege = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+func (m arcgisUserPrivilegeMods) WithParentsCascading() ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) {
+ if isDone, _ := arcgisUserPrivilegeWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = arcgisUserPrivilegeWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewArcgisUserWithContext(ctx, ArcgisUserMods.WithParentsCascading())
+ m.WithUserUser(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m arcgisUserPrivilegeMods) WithUserUser(rel *ArcgisUserTemplate) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.r.UserUser = &arcgisUserPrivilegeRUserUserR{
+ o: rel,
+ }
+ })
+}
+
+func (m arcgisUserPrivilegeMods) WithNewUserUser(mods ...ArcgisUserMod) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) {
+ related := o.f.NewArcgisUserWithContext(ctx, mods...)
+
+ m.WithUserUser(related).Apply(ctx, o)
+ })
+}
+
+func (m arcgisUserPrivilegeMods) WithExistingUserUser(em *models.ArcgisUser) ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.r.UserUser = &arcgisUserPrivilegeRUserUserR{
+ o: o.f.FromExistingArcgisUser(em),
+ }
+ })
+}
+
+func (m arcgisUserPrivilegeMods) WithoutUserUser() ArcgisUserPrivilegeMod {
+ return ArcgisUserPrivilegeModFunc(func(ctx context.Context, o *ArcgisUserPrivilegeTemplate) {
+ o.r.UserUser = nil
+ })
+}
diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go
index 0f3fa16f..f584a12c 100644
--- a/db/factory/bobfactory_context.bob.go
+++ b/db/factory/bobfactory_context.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
@@ -8,6 +8,15 @@ import "context"
type contextKey string
var (
+ // Relationship Contexts for arcgis.user_
+ arcgisuserWithParentsCascadingCtx = newContextual[bool]("arcgisuserWithParentsCascading")
+ arcgisuserRelPublicUserUserCtx = newContextual[bool]("arcgis.user_.user_.arcgis.user_.user__public_user_id_fkey")
+ arcgisuserRelUserUserPrivilegesCtx = newContextual[bool]("arcgis.user_.arcgis.user_privilege.arcgis.user_privilege.user_privilege_user_id_fkey")
+
+ // Relationship Contexts for arcgis.user_privilege
+ arcgisUserPrivilegeWithParentsCascadingCtx = newContextual[bool]("arcgisUserPrivilegeWithParentsCascading")
+ arcgisUserPrivilegeRelUserUserCtx = newContextual[bool]("arcgis.user_.arcgis.user_privilege.arcgis.user_privilege.user_privilege_user_id_fkey")
+
// Relationship Contexts for district
districtWithParentsCascadingCtx = newContextual[bool]("districtWithParentsCascading")
@@ -247,6 +256,7 @@ var (
// Relationship Contexts for user_
userWithParentsCascadingCtx = newContextual[bool]("userWithParentsCascading")
+ userRelPublicUserUserCtx = newContextual[bool]("arcgis.user_.user_.arcgis.user_.user__public_user_id_fkey")
userRelCreatorNoteAudiosCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_creator_id_fkey")
userRelDeletorNoteAudiosCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_deletor_id_fkey")
userRelCreatorNoteImagesCtx = newContextual[bool]("note_image.user_.note_image.note_image_creator_id_fkey")
diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go
index cae5658a..17d49c70 100644
--- a/db/factory/bobfactory_main.bob.go
+++ b/db/factory/bobfactory_main.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
@@ -18,6 +18,8 @@ import (
)
type Factory struct {
+ baseArcgisUserMods ArcgisUserModSlice
+ baseArcgisUserPrivilegeMods ArcgisUserPrivilegeModSlice
baseDistrictMods DistrictModSlice
baseFieldseekerContainerrelateMods FieldseekerContainerrelateModSlice
baseFieldseekerFieldscoutinglogMods FieldseekerFieldscoutinglogModSlice
@@ -77,6 +79,81 @@ func New() *Factory {
return &Factory{}
}
+func (f *Factory) NewArcgisUser(mods ...ArcgisUserMod) *ArcgisUserTemplate {
+ return f.NewArcgisUserWithContext(context.Background(), mods...)
+}
+
+func (f *Factory) NewArcgisUserWithContext(ctx context.Context, mods ...ArcgisUserMod) *ArcgisUserTemplate {
+ o := &ArcgisUserTemplate{f: f}
+
+ if f != nil {
+ f.baseArcgisUserMods.Apply(ctx, o)
+ }
+
+ ArcgisUserModSlice(mods).Apply(ctx, o)
+
+ return o
+}
+
+func (f *Factory) FromExistingArcgisUser(m *models.ArcgisUser) *ArcgisUserTemplate {
+ o := &ArcgisUserTemplate{f: f, alreadyPersisted: true}
+
+ o.Access = func() string { return m.Access }
+ o.Created = func() time.Time { return m.Created }
+ o.Email = func() string { return m.Email }
+ o.FullName = func() string { return m.FullName }
+ o.ID = func() string { return m.ID }
+ o.Level = func() string { return m.Level }
+ o.OrgID = func() string { return m.OrgID }
+ o.PublicUserID = func() int32 { return m.PublicUserID }
+ o.Region = func() string { return m.Region }
+ o.Role = func() string { return m.Role }
+ o.RoleID = func() string { return m.RoleID }
+ o.Username = func() string { return m.Username }
+ o.UserLicenseTypeID = func() string { return m.UserLicenseTypeID }
+ o.UserType = func() string { return m.UserType }
+
+ ctx := context.Background()
+ if m.R.PublicUserUser != nil {
+ ArcgisUserMods.WithExistingPublicUserUser(m.R.PublicUserUser).Apply(ctx, o)
+ }
+ if len(m.R.UserUserPrivileges) > 0 {
+ ArcgisUserMods.AddExistingUserUserPrivileges(m.R.UserUserPrivileges...).Apply(ctx, o)
+ }
+
+ return o
+}
+
+func (f *Factory) NewArcgisUserPrivilege(mods ...ArcgisUserPrivilegeMod) *ArcgisUserPrivilegeTemplate {
+ return f.NewArcgisUserPrivilegeWithContext(context.Background(), mods...)
+}
+
+func (f *Factory) NewArcgisUserPrivilegeWithContext(ctx context.Context, mods ...ArcgisUserPrivilegeMod) *ArcgisUserPrivilegeTemplate {
+ o := &ArcgisUserPrivilegeTemplate{f: f}
+
+ if f != nil {
+ f.baseArcgisUserPrivilegeMods.Apply(ctx, o)
+ }
+
+ ArcgisUserPrivilegeModSlice(mods).Apply(ctx, o)
+
+ return o
+}
+
+func (f *Factory) FromExistingArcgisUserPrivilege(m *models.ArcgisUserPrivilege) *ArcgisUserPrivilegeTemplate {
+ o := &ArcgisUserPrivilegeTemplate{f: f, alreadyPersisted: true}
+
+ o.UserID = func() string { return m.UserID }
+ o.Privilege = func() string { return m.Privilege }
+
+ ctx := context.Background()
+ if m.R.UserUser != nil {
+ ArcgisUserPrivilegeMods.WithExistingUserUser(m.R.UserUser).Apply(ctx, o)
+ }
+
+ return o
+}
+
func (f *Factory) NewDistrict(mods ...DistrictMod) *DistrictTemplate {
return f.NewDistrictWithContext(context.Background(), mods...)
}
@@ -2825,6 +2902,9 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate {
o.PasswordHash = func() string { return m.PasswordHash }
ctx := context.Background()
+ if len(m.R.PublicUserUser) > 0 {
+ UserMods.AddExistingPublicUserUser(m.R.PublicUserUser...).Apply(ctx, o)
+ }
if len(m.R.CreatorNoteAudios) > 0 {
UserMods.AddExistingCreatorNoteAudios(m.R.CreatorNoteAudios...).Apply(ctx, o)
}
@@ -2850,6 +2930,22 @@ func (f *Factory) FromExistingUser(m *models.User) *UserTemplate {
return o
}
+func (f *Factory) ClearBaseArcgisUserMods() {
+ f.baseArcgisUserMods = nil
+}
+
+func (f *Factory) AddBaseArcgisUserMod(mods ...ArcgisUserMod) {
+ f.baseArcgisUserMods = append(f.baseArcgisUserMods, mods...)
+}
+
+func (f *Factory) ClearBaseArcgisUserPrivilegeMods() {
+ f.baseArcgisUserPrivilegeMods = nil
+}
+
+func (f *Factory) AddBaseArcgisUserPrivilegeMod(mods ...ArcgisUserPrivilegeMod) {
+ f.baseArcgisUserPrivilegeMods = append(f.baseArcgisUserPrivilegeMods, mods...)
+}
+
func (f *Factory) ClearBaseDistrictMods() {
f.baseDistrictMods = nil
}
diff --git a/db/factory/bobfactory_random.bob.go b/db/factory/bobfactory_random.bob.go
index abb5ef00..0f93c1ad 100644
--- a/db/factory/bobfactory_random.bob.go
+++ b/db/factory/bobfactory_random.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/district.bob.go b/db/factory/district.bob.go
index 4a25435f..fd5944c4 100644
--- a/db/factory/district.bob.go
+++ b/db/factory/district.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.containerrelate.bob.go b/db/factory/fieldseeker.containerrelate.bob.go
index 8a1a3613..31dbc2be 100644
--- a/db/factory/fieldseeker.containerrelate.bob.go
+++ b/db/factory/fieldseeker.containerrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.fieldscoutinglog.bob.go b/db/factory/fieldseeker.fieldscoutinglog.bob.go
index e688ab28..ac7f0351 100644
--- a/db/factory/fieldseeker.fieldscoutinglog.bob.go
+++ b/db/factory/fieldseeker.fieldscoutinglog.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.habitatrelate.bob.go b/db/factory/fieldseeker.habitatrelate.bob.go
index bbf2eaef..863ee087 100644
--- a/db/factory/fieldseeker.habitatrelate.bob.go
+++ b/db/factory/fieldseeker.habitatrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.inspectionsample.bob.go b/db/factory/fieldseeker.inspectionsample.bob.go
index 3306127e..75993f79 100644
--- a/db/factory/fieldseeker.inspectionsample.bob.go
+++ b/db/factory/fieldseeker.inspectionsample.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.inspectionsampledetail.bob.go b/db/factory/fieldseeker.inspectionsampledetail.bob.go
index 006b3dd3..53e60c10 100644
--- a/db/factory/fieldseeker.inspectionsampledetail.bob.go
+++ b/db/factory/fieldseeker.inspectionsampledetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.linelocation.bob.go b/db/factory/fieldseeker.linelocation.bob.go
index 06e2dd00..4cd24b90 100644
--- a/db/factory/fieldseeker.linelocation.bob.go
+++ b/db/factory/fieldseeker.linelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.locationtracking.bob.go b/db/factory/fieldseeker.locationtracking.bob.go
index 02742246..a258b8a1 100644
--- a/db/factory/fieldseeker.locationtracking.bob.go
+++ b/db/factory/fieldseeker.locationtracking.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.mosquitoinspection.bob.go b/db/factory/fieldseeker.mosquitoinspection.bob.go
index 3f5e6093..fa9c480a 100644
--- a/db/factory/fieldseeker.mosquitoinspection.bob.go
+++ b/db/factory/fieldseeker.mosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.pointlocation.bob.go b/db/factory/fieldseeker.pointlocation.bob.go
index 55faf410..01cf29b0 100644
--- a/db/factory/fieldseeker.pointlocation.bob.go
+++ b/db/factory/fieldseeker.pointlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.polygonlocation.bob.go b/db/factory/fieldseeker.polygonlocation.bob.go
index 7f6485f8..7def30d7 100644
--- a/db/factory/fieldseeker.polygonlocation.bob.go
+++ b/db/factory/fieldseeker.polygonlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.pool.bob.go b/db/factory/fieldseeker.pool.bob.go
index 1ffac53a..322b8bcd 100644
--- a/db/factory/fieldseeker.pool.bob.go
+++ b/db/factory/fieldseeker.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.pooldetail.bob.go b/db/factory/fieldseeker.pooldetail.bob.go
index 22cb2ca4..c4978b51 100644
--- a/db/factory/fieldseeker.pooldetail.bob.go
+++ b/db/factory/fieldseeker.pooldetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.proposedtreatmentarea.bob.go b/db/factory/fieldseeker.proposedtreatmentarea.bob.go
index 1bf811dd..a9dd58c6 100644
--- a/db/factory/fieldseeker.proposedtreatmentarea.bob.go
+++ b/db/factory/fieldseeker.proposedtreatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.qamosquitoinspection.bob.go b/db/factory/fieldseeker.qamosquitoinspection.bob.go
index bf8ea348..cabb9b45 100644
--- a/db/factory/fieldseeker.qamosquitoinspection.bob.go
+++ b/db/factory/fieldseeker.qamosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.rodentlocation.bob.go b/db/factory/fieldseeker.rodentlocation.bob.go
index 63871fcd..4911723e 100644
--- a/db/factory/fieldseeker.rodentlocation.bob.go
+++ b/db/factory/fieldseeker.rodentlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.samplecollection.bob.go b/db/factory/fieldseeker.samplecollection.bob.go
index 9ce1f745..29e18a7d 100644
--- a/db/factory/fieldseeker.samplecollection.bob.go
+++ b/db/factory/fieldseeker.samplecollection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.samplelocation.bob.go b/db/factory/fieldseeker.samplelocation.bob.go
index 85d1ece6..bc41d319 100644
--- a/db/factory/fieldseeker.samplelocation.bob.go
+++ b/db/factory/fieldseeker.samplelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.servicerequest.bob.go b/db/factory/fieldseeker.servicerequest.bob.go
index 0ce06a72..4a69b438 100644
--- a/db/factory/fieldseeker.servicerequest.bob.go
+++ b/db/factory/fieldseeker.servicerequest.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.speciesabundance.bob.go b/db/factory/fieldseeker.speciesabundance.bob.go
index 18fea4e5..efafd1fe 100644
--- a/db/factory/fieldseeker.speciesabundance.bob.go
+++ b/db/factory/fieldseeker.speciesabundance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.stormdrain.bob.go b/db/factory/fieldseeker.stormdrain.bob.go
index 3b1caa24..bb3fdca3 100644
--- a/db/factory/fieldseeker.stormdrain.bob.go
+++ b/db/factory/fieldseeker.stormdrain.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.timecard.bob.go b/db/factory/fieldseeker.timecard.bob.go
index 5001368d..fa18147b 100644
--- a/db/factory/fieldseeker.timecard.bob.go
+++ b/db/factory/fieldseeker.timecard.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.trapdata.bob.go b/db/factory/fieldseeker.trapdata.bob.go
index aa03e598..649b359f 100644
--- a/db/factory/fieldseeker.trapdata.bob.go
+++ b/db/factory/fieldseeker.trapdata.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.traplocation.bob.go b/db/factory/fieldseeker.traplocation.bob.go
index b2699c74..621c0929 100644
--- a/db/factory/fieldseeker.traplocation.bob.go
+++ b/db/factory/fieldseeker.traplocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.treatment.bob.go b/db/factory/fieldseeker.treatment.bob.go
index 99e0a3bf..dadf53bd 100644
--- a/db/factory/fieldseeker.treatment.bob.go
+++ b/db/factory/fieldseeker.treatment.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.treatmentarea.bob.go b/db/factory/fieldseeker.treatmentarea.bob.go
index 9f48e08a..2290a138 100644
--- a/db/factory/fieldseeker.treatmentarea.bob.go
+++ b/db/factory/fieldseeker.treatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.zones.bob.go b/db/factory/fieldseeker.zones.bob.go
index e733cca5..1e6fab87 100644
--- a/db/factory/fieldseeker.zones.bob.go
+++ b/db/factory/fieldseeker.zones.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker.zones2.bob.go b/db/factory/fieldseeker.zones2.bob.go
index 2d383f58..9cf78520 100644
--- a/db/factory/fieldseeker.zones2.bob.go
+++ b/db/factory/fieldseeker.zones2.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/fieldseeker_sync.bob.go b/db/factory/fieldseeker_sync.bob.go
index 1e4eb34c..2358f34a 100644
--- a/db/factory/fieldseeker_sync.bob.go
+++ b/db/factory/fieldseeker_sync.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/geography_columns.bob.go b/db/factory/geography_columns.bob.go
index ae74519b..16709713 100644
--- a/db/factory/geography_columns.bob.go
+++ b/db/factory/geography_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/geometry_columns.bob.go b/db/factory/geometry_columns.bob.go
index f493872e..63c97d2a 100644
--- a/db/factory/geometry_columns.bob.go
+++ b/db/factory/geometry_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/goose_db_version.bob.go b/db/factory/goose_db_version.bob.go
index 68bc4aea..581502cb 100644
--- a/db/factory/goose_db_version.bob.go
+++ b/db/factory/goose_db_version.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/h3_aggregation.bob.go b/db/factory/h3_aggregation.bob.go
index ea3b03db..5977ac04 100644
--- a/db/factory/h3_aggregation.bob.go
+++ b/db/factory/h3_aggregation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_audio.bob.go b/db/factory/note_audio.bob.go
index e3a9620a..557894ba 100644
--- a/db/factory/note_audio.bob.go
+++ b/db/factory/note_audio.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_audio_breadcrumb.bob.go b/db/factory/note_audio_breadcrumb.bob.go
index 3abf3eef..b4a8c8a2 100644
--- a/db/factory/note_audio_breadcrumb.bob.go
+++ b/db/factory/note_audio_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_audio_data.bob.go b/db/factory/note_audio_data.bob.go
index cd6578e6..3030278b 100644
--- a/db/factory/note_audio_data.bob.go
+++ b/db/factory/note_audio_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_image.bob.go b/db/factory/note_image.bob.go
index a79ca241..53cc85cf 100644
--- a/db/factory/note_image.bob.go
+++ b/db/factory/note_image.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_image_breadcrumb.bob.go b/db/factory/note_image_breadcrumb.bob.go
index ed0ae5e7..31cb44f6 100644
--- a/db/factory/note_image_breadcrumb.bob.go
+++ b/db/factory/note_image_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/note_image_data.bob.go b/db/factory/note_image_data.bob.go
index 3b79cc04..dc8350ce 100644
--- a/db/factory/note_image_data.bob.go
+++ b/db/factory/note_image_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/notification.bob.go b/db/factory/notification.bob.go
index 42b1912e..9b34b0c7 100644
--- a/db/factory/notification.bob.go
+++ b/db/factory/notification.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/oauth_token.bob.go b/db/factory/oauth_token.bob.go
index fbe69c7a..12ef5b67 100644
--- a/db/factory/oauth_token.bob.go
+++ b/db/factory/oauth_token.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go
index f7567bd7..73aa2bed 100644
--- a/db/factory/organization.bob.go
+++ b/db/factory/organization.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.nuisance.bob.go b/db/factory/publicreport.nuisance.bob.go
index 022ef0ea..3590e4e1 100644
--- a/db/factory/publicreport.nuisance.bob.go
+++ b/db/factory/publicreport.nuisance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.pool.bob.go b/db/factory/publicreport.pool.bob.go
index f5184a82..d35ac5c2 100644
--- a/db/factory/publicreport.pool.bob.go
+++ b/db/factory/publicreport.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.pool_photo.bob.go b/db/factory/publicreport.pool_photo.bob.go
index a0a289d0..d41bd538 100644
--- a/db/factory/publicreport.pool_photo.bob.go
+++ b/db/factory/publicreport.pool_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.quick.bob.go b/db/factory/publicreport.quick.bob.go
index 85b456d4..95a66d3a 100644
--- a/db/factory/publicreport.quick.bob.go
+++ b/db/factory/publicreport.quick.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.quick_photo.bob.go b/db/factory/publicreport.quick_photo.bob.go
index 39b70215..4bd2bfb9 100644
--- a/db/factory/publicreport.quick_photo.bob.go
+++ b/db/factory/publicreport.quick_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/publicreport.report_location.bob.go b/db/factory/publicreport.report_location.bob.go
index a7ff64c2..2b1dac21 100644
--- a/db/factory/publicreport.report_location.bob.go
+++ b/db/factory/publicreport.report_location.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/raster_columns.bob.go b/db/factory/raster_columns.bob.go
index ca6ca8d8..bd01e09e 100644
--- a/db/factory/raster_columns.bob.go
+++ b/db/factory/raster_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/raster_overviews.bob.go b/db/factory/raster_overviews.bob.go
index ba9c8a89..3d7f41da 100644
--- a/db/factory/raster_overviews.bob.go
+++ b/db/factory/raster_overviews.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/sessions.bob.go b/db/factory/sessions.bob.go
index d5293505..d0148f28 100644
--- a/db/factory/sessions.bob.go
+++ b/db/factory/sessions.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/spatial_ref_sys.bob.go b/db/factory/spatial_ref_sys.bob.go
index 448a30ff..8eeff8fa 100644
--- a/db/factory/spatial_ref_sys.bob.go
+++ b/db/factory/spatial_ref_sys.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
diff --git a/db/factory/user_.bob.go b/db/factory/user_.bob.go
index 6425b915..0bfd18f8 100644
--- a/db/factory/user_.bob.go
+++ b/db/factory/user_.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package factory
@@ -58,6 +58,7 @@ type UserTemplate struct {
}
type userR struct {
+ PublicUserUser []*userRPublicUserUserR
CreatorNoteAudios []*userRCreatorNoteAudiosR
DeletorNoteAudios []*userRDeletorNoteAudiosR
CreatorNoteImages []*userRCreatorNoteImagesR
@@ -67,6 +68,10 @@ type userR struct {
Organization *userROrganizationR
}
+type userRPublicUserUserR struct {
+ number int
+ o *ArcgisUserTemplate
+}
type userRCreatorNoteAudiosR struct {
number int
o *NoteAudioTemplate
@@ -105,6 +110,19 @@ func (o *UserTemplate) Apply(ctx context.Context, mods ...UserMod) {
// setModelRels creates and sets the relationships on *models.User
// according to the relationships in the template. Nothing is inserted into the db
func (t UserTemplate) setModelRels(o *models.User) {
+ if t.r.PublicUserUser != nil {
+ rel := models.ArcgisUserSlice{}
+ for _, r := range t.r.PublicUserUser {
+ related := r.o.BuildMany(r.number)
+ for _, rel := range related {
+ rel.PublicUserID = o.ID // h2
+ rel.R.PublicUserUser = o
+ }
+ rel = append(rel, related...)
+ }
+ o.R.PublicUserUser = rel
+ }
+
if t.r.CreatorNoteAudios != nil {
rel := models.NoteAudioSlice{}
for _, r := range t.r.CreatorNoteAudios {
@@ -350,6 +368,26 @@ func ensureCreatableUser(m *models.UserSetter) {
func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.User) error {
var err error
+ isPublicUserUserDone, _ := userRelPublicUserUserCtx.Value(ctx)
+ if !isPublicUserUserDone && o.r.PublicUserUser != nil {
+ ctx = userRelPublicUserUserCtx.WithValue(ctx, true)
+ for _, r := range o.r.PublicUserUser {
+ if r.o.alreadyPersisted {
+ m.R.PublicUserUser = append(m.R.PublicUserUser, r.o.Build())
+ } else {
+ rel0, err := r.o.CreateMany(ctx, exec, r.number)
+ if err != nil {
+ return err
+ }
+
+ err = m.AttachPublicUserUser(ctx, exec, rel0...)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+
isCreatorNoteAudiosDone, _ := userRelCreatorNoteAudiosCtx.Value(ctx)
if !isCreatorNoteAudiosDone && o.r.CreatorNoteAudios != nil {
ctx = userRelCreatorNoteAudiosCtx.WithValue(ctx, true)
@@ -357,12 +395,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.CreatorNoteAudios = append(m.R.CreatorNoteAudios, r.o.Build())
} else {
- rel0, err := r.o.CreateMany(ctx, exec, r.number)
+ rel1, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachCreatorNoteAudios(ctx, exec, rel0...)
+ err = m.AttachCreatorNoteAudios(ctx, exec, rel1...)
if err != nil {
return err
}
@@ -377,12 +415,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.DeletorNoteAudios = append(m.R.DeletorNoteAudios, r.o.Build())
} else {
- rel1, err := r.o.CreateMany(ctx, exec, r.number)
+ rel2, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachDeletorNoteAudios(ctx, exec, rel1...)
+ err = m.AttachDeletorNoteAudios(ctx, exec, rel2...)
if err != nil {
return err
}
@@ -397,12 +435,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.CreatorNoteImages = append(m.R.CreatorNoteImages, r.o.Build())
} else {
- rel2, err := r.o.CreateMany(ctx, exec, r.number)
+ rel3, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachCreatorNoteImages(ctx, exec, rel2...)
+ err = m.AttachCreatorNoteImages(ctx, exec, rel3...)
if err != nil {
return err
}
@@ -417,12 +455,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.DeletorNoteImages = append(m.R.DeletorNoteImages, r.o.Build())
} else {
- rel3, err := r.o.CreateMany(ctx, exec, r.number)
+ rel4, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachDeletorNoteImages(ctx, exec, rel3...)
+ err = m.AttachDeletorNoteImages(ctx, exec, rel4...)
if err != nil {
return err
}
@@ -437,12 +475,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.UserNotifications = append(m.R.UserNotifications, r.o.Build())
} else {
- rel4, err := r.o.CreateMany(ctx, exec, r.number)
+ rel5, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachUserNotifications(ctx, exec, rel4...)
+ err = m.AttachUserNotifications(ctx, exec, rel5...)
if err != nil {
return err
}
@@ -457,12 +495,12 @@ func (o *UserTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *
if r.o.alreadyPersisted {
m.R.UserOauthTokens = append(m.R.UserOauthTokens, r.o.Build())
} else {
- rel5, err := r.o.CreateMany(ctx, exec, r.number)
+ rel6, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachUserOauthTokens(ctx, exec, rel5...)
+ err = m.AttachUserOauthTokens(ctx, exec, rel6...)
if err != nil {
return err
}
@@ -484,25 +522,25 @@ func (o *UserTemplate) Create(ctx context.Context, exec bob.Executor) (*models.U
UserMods.WithNewOrganization().Apply(ctx, o)
}
- var rel6 *models.Organization
+ var rel7 *models.Organization
if o.r.Organization.o.alreadyPersisted {
- rel6 = o.r.Organization.o.Build()
+ rel7 = o.r.Organization.o.Build()
} else {
- rel6, err = o.r.Organization.o.Create(ctx, exec)
+ rel7, err = o.r.Organization.o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
- opt.OrganizationID = omit.From(rel6.ID)
+ opt.OrganizationID = omit.From(rel7.ID)
m, err := models.Users.Insert(opt).One(ctx, exec)
if err != nil {
return nil, err
}
- m.R.Organization = rel6
+ m.R.Organization = rel7
if err := o.insertOptRels(ctx, exec, m); err != nil {
return nil, err
@@ -1144,6 +1182,54 @@ func (m userMods) WithoutOrganization() UserMod {
})
}
+func (m userMods) WithPublicUserUser(number int, related *ArcgisUserTemplate) UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ o.r.PublicUserUser = []*userRPublicUserUserR{{
+ number: number,
+ o: related,
+ }}
+ })
+}
+
+func (m userMods) WithNewPublicUserUser(number int, mods ...ArcgisUserMod) UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ related := o.f.NewArcgisUserWithContext(ctx, mods...)
+ m.WithPublicUserUser(number, related).Apply(ctx, o)
+ })
+}
+
+func (m userMods) AddPublicUserUser(number int, related *ArcgisUserTemplate) UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ o.r.PublicUserUser = append(o.r.PublicUserUser, &userRPublicUserUserR{
+ number: number,
+ o: related,
+ })
+ })
+}
+
+func (m userMods) AddNewPublicUserUser(number int, mods ...ArcgisUserMod) UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ related := o.f.NewArcgisUserWithContext(ctx, mods...)
+ m.AddPublicUserUser(number, related).Apply(ctx, o)
+ })
+}
+
+func (m userMods) AddExistingPublicUserUser(existingModels ...*models.ArcgisUser) UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ for _, em := range existingModels {
+ o.r.PublicUserUser = append(o.r.PublicUserUser, &userRPublicUserUserR{
+ o: o.f.FromExistingArcgisUser(em),
+ })
+ }
+ })
+}
+
+func (m userMods) WithoutPublicUserUser() UserMod {
+ return UserModFunc(func(ctx context.Context, o *UserTemplate) {
+ o.r.PublicUserUser = nil
+ })
+}
+
func (m userMods) WithCreatorNoteAudios(number int, related *NoteAudioTemplate) UserMod {
return UserModFunc(func(ctx context.Context, o *UserTemplate) {
o.r.CreatorNoteAudios = []*userRCreatorNoteAudiosR{{
diff --git a/db/migrations/00031_arcgis_user.sql b/db/migrations/00031_arcgis_user.sql
new file mode 100644
index 00000000..0e58193c
--- /dev/null
+++ b/db/migrations/00031_arcgis_user.sql
@@ -0,0 +1,28 @@
+-- +goose Up
+CREATE SCHEMA arcgis;
+CREATE TABLE arcgis.user_ (
+ access TEXT NOT NULL,
+ created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ email TEXT NOT NULL,
+ full_name TEXT NOT NULL,
+ id TEXT NOT NULL,
+ level TEXT NOT NULL,
+ org_id TEXT NOT NULL,
+ public_user_id INTEGER NOT NULL REFERENCES public.user_(id),
+ region TEXT NOT NULL,
+ role TEXT NOT NULL,
+ role_id TEXT NOT NULL,
+ username TEXT NOT NULL,
+ user_license_type_id TEXT NOT NULL,
+ user_type TEXT NOT NULL,
+ PRIMARY KEY (id)
+);
+CREATE TABLE arcgis.user_privilege (
+ user_id TEXT NOT NULL REFERENCES arcgis.user_(id),
+ privilege TEXT NOT NULL,
+ PRIMARY KEY(user_id, privilege)
+);
+-- +goose Down
+DROP TABLE arcgis.user_privilege;
+DROP TABLE arcgis.user_;
+DROP SCHEMA arcgis;
diff --git a/db/models/arcgis.user_.bob.go b/db/models/arcgis.user_.bob.go
new file mode 100644
index 00000000..6613b87f
--- /dev/null
+++ b/db/models/arcgis.user_.bob.go
@@ -0,0 +1,1191 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "time"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+)
+
+// ArcgisUser is an object representing the database table.
+type ArcgisUser struct {
+ Access string `db:"access" `
+ Created time.Time `db:"created" `
+ Email string `db:"email" `
+ FullName string `db:"full_name" `
+ ID string `db:"id,pk" `
+ Level string `db:"level" `
+ OrgID string `db:"org_id" `
+ PublicUserID int32 `db:"public_user_id" `
+ Region string `db:"region" `
+ Role string `db:"role" `
+ RoleID string `db:"role_id" `
+ Username string `db:"username" `
+ UserLicenseTypeID string `db:"user_license_type_id" `
+ UserType string `db:"user_type" `
+
+ R arcgisuserR `db:"-" `
+
+ C arcgisuserC `db:"-" `
+}
+
+// ArcgisUserSlice is an alias for a slice of pointers to ArcgisUser.
+// This should almost always be used instead of []*ArcgisUser.
+type ArcgisUserSlice []*ArcgisUser
+
+// ArcgisUsers contains methods to work with the user_ table
+var ArcgisUsers = psql.NewTablex[*ArcgisUser, ArcgisUserSlice, *ArcgisUserSetter]("arcgis", "user_", buildArcgisUserColumns("arcgis.user_"))
+
+// ArcgisUsersQuery is a query on the user_ table
+type ArcgisUsersQuery = *psql.ViewQuery[*ArcgisUser, ArcgisUserSlice]
+
+// arcgisuserR is where relationships are stored.
+type arcgisuserR struct {
+ PublicUserUser *User // arcgis.user_.user__public_user_id_fkey
+ UserUserPrivileges ArcgisUserPrivilegeSlice // arcgis.user_privilege.user_privilege_user_id_fkey
+}
+
+func buildArcgisUserColumns(alias string) arcgisuserColumns {
+ return arcgisuserColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "access", "created", "email", "full_name", "id", "level", "org_id", "public_user_id", "region", "role", "role_id", "username", "user_license_type_id", "user_type",
+ ).WithParent("arcgis.user_"),
+ tableAlias: alias,
+ Access: psql.Quote(alias, "access"),
+ Created: psql.Quote(alias, "created"),
+ Email: psql.Quote(alias, "email"),
+ FullName: psql.Quote(alias, "full_name"),
+ ID: psql.Quote(alias, "id"),
+ Level: psql.Quote(alias, "level"),
+ OrgID: psql.Quote(alias, "org_id"),
+ PublicUserID: psql.Quote(alias, "public_user_id"),
+ Region: psql.Quote(alias, "region"),
+ Role: psql.Quote(alias, "role"),
+ RoleID: psql.Quote(alias, "role_id"),
+ Username: psql.Quote(alias, "username"),
+ UserLicenseTypeID: psql.Quote(alias, "user_license_type_id"),
+ UserType: psql.Quote(alias, "user_type"),
+ }
+}
+
+type arcgisuserColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ Access psql.Expression
+ Created psql.Expression
+ Email psql.Expression
+ FullName psql.Expression
+ ID psql.Expression
+ Level psql.Expression
+ OrgID psql.Expression
+ PublicUserID psql.Expression
+ Region psql.Expression
+ Role psql.Expression
+ RoleID psql.Expression
+ Username psql.Expression
+ UserLicenseTypeID psql.Expression
+ UserType psql.Expression
+}
+
+func (c arcgisuserColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (arcgisuserColumns) AliasedAs(alias string) arcgisuserColumns {
+ return buildArcgisUserColumns(alias)
+}
+
+// ArcgisUserSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type ArcgisUserSetter struct {
+ Access omit.Val[string] `db:"access" `
+ Created omit.Val[time.Time] `db:"created" `
+ Email omit.Val[string] `db:"email" `
+ FullName omit.Val[string] `db:"full_name" `
+ ID omit.Val[string] `db:"id,pk" `
+ Level omit.Val[string] `db:"level" `
+ OrgID omit.Val[string] `db:"org_id" `
+ PublicUserID omit.Val[int32] `db:"public_user_id" `
+ Region omit.Val[string] `db:"region" `
+ Role omit.Val[string] `db:"role" `
+ RoleID omit.Val[string] `db:"role_id" `
+ Username omit.Val[string] `db:"username" `
+ UserLicenseTypeID omit.Val[string] `db:"user_license_type_id" `
+ UserType omit.Val[string] `db:"user_type" `
+}
+
+func (s ArcgisUserSetter) SetColumns() []string {
+ vals := make([]string, 0, 14)
+ if s.Access.IsValue() {
+ vals = append(vals, "access")
+ }
+ if s.Created.IsValue() {
+ vals = append(vals, "created")
+ }
+ if s.Email.IsValue() {
+ vals = append(vals, "email")
+ }
+ if s.FullName.IsValue() {
+ vals = append(vals, "full_name")
+ }
+ if s.ID.IsValue() {
+ vals = append(vals, "id")
+ }
+ if s.Level.IsValue() {
+ vals = append(vals, "level")
+ }
+ if s.OrgID.IsValue() {
+ vals = append(vals, "org_id")
+ }
+ if s.PublicUserID.IsValue() {
+ vals = append(vals, "public_user_id")
+ }
+ if s.Region.IsValue() {
+ vals = append(vals, "region")
+ }
+ if s.Role.IsValue() {
+ vals = append(vals, "role")
+ }
+ if s.RoleID.IsValue() {
+ vals = append(vals, "role_id")
+ }
+ if s.Username.IsValue() {
+ vals = append(vals, "username")
+ }
+ if s.UserLicenseTypeID.IsValue() {
+ vals = append(vals, "user_license_type_id")
+ }
+ if s.UserType.IsValue() {
+ vals = append(vals, "user_type")
+ }
+ return vals
+}
+
+func (s ArcgisUserSetter) Overwrite(t *ArcgisUser) {
+ if s.Access.IsValue() {
+ t.Access = s.Access.MustGet()
+ }
+ if s.Created.IsValue() {
+ t.Created = s.Created.MustGet()
+ }
+ if s.Email.IsValue() {
+ t.Email = s.Email.MustGet()
+ }
+ if s.FullName.IsValue() {
+ t.FullName = s.FullName.MustGet()
+ }
+ if s.ID.IsValue() {
+ t.ID = s.ID.MustGet()
+ }
+ if s.Level.IsValue() {
+ t.Level = s.Level.MustGet()
+ }
+ if s.OrgID.IsValue() {
+ t.OrgID = s.OrgID.MustGet()
+ }
+ if s.PublicUserID.IsValue() {
+ t.PublicUserID = s.PublicUserID.MustGet()
+ }
+ if s.Region.IsValue() {
+ t.Region = s.Region.MustGet()
+ }
+ if s.Role.IsValue() {
+ t.Role = s.Role.MustGet()
+ }
+ if s.RoleID.IsValue() {
+ t.RoleID = s.RoleID.MustGet()
+ }
+ if s.Username.IsValue() {
+ t.Username = s.Username.MustGet()
+ }
+ if s.UserLicenseTypeID.IsValue() {
+ t.UserLicenseTypeID = s.UserLicenseTypeID.MustGet()
+ }
+ if s.UserType.IsValue() {
+ t.UserType = s.UserType.MustGet()
+ }
+}
+
+func (s *ArcgisUserSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUsers.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 14)
+ if s.Access.IsValue() {
+ vals[0] = psql.Arg(s.Access.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.Created.IsValue() {
+ vals[1] = psql.Arg(s.Created.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ if s.Email.IsValue() {
+ vals[2] = psql.Arg(s.Email.MustGet())
+ } else {
+ vals[2] = psql.Raw("DEFAULT")
+ }
+
+ if s.FullName.IsValue() {
+ vals[3] = psql.Arg(s.FullName.MustGet())
+ } else {
+ vals[3] = psql.Raw("DEFAULT")
+ }
+
+ if s.ID.IsValue() {
+ vals[4] = psql.Arg(s.ID.MustGet())
+ } else {
+ vals[4] = psql.Raw("DEFAULT")
+ }
+
+ if s.Level.IsValue() {
+ vals[5] = psql.Arg(s.Level.MustGet())
+ } else {
+ vals[5] = psql.Raw("DEFAULT")
+ }
+
+ if s.OrgID.IsValue() {
+ vals[6] = psql.Arg(s.OrgID.MustGet())
+ } else {
+ vals[6] = psql.Raw("DEFAULT")
+ }
+
+ if s.PublicUserID.IsValue() {
+ vals[7] = psql.Arg(s.PublicUserID.MustGet())
+ } else {
+ vals[7] = psql.Raw("DEFAULT")
+ }
+
+ if s.Region.IsValue() {
+ vals[8] = psql.Arg(s.Region.MustGet())
+ } else {
+ vals[8] = psql.Raw("DEFAULT")
+ }
+
+ if s.Role.IsValue() {
+ vals[9] = psql.Arg(s.Role.MustGet())
+ } else {
+ vals[9] = psql.Raw("DEFAULT")
+ }
+
+ if s.RoleID.IsValue() {
+ vals[10] = psql.Arg(s.RoleID.MustGet())
+ } else {
+ vals[10] = psql.Raw("DEFAULT")
+ }
+
+ if s.Username.IsValue() {
+ vals[11] = psql.Arg(s.Username.MustGet())
+ } else {
+ vals[11] = psql.Raw("DEFAULT")
+ }
+
+ if s.UserLicenseTypeID.IsValue() {
+ vals[12] = psql.Arg(s.UserLicenseTypeID.MustGet())
+ } else {
+ vals[12] = psql.Raw("DEFAULT")
+ }
+
+ if s.UserType.IsValue() {
+ vals[13] = psql.Arg(s.UserType.MustGet())
+ } else {
+ vals[13] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s ArcgisUserSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s ArcgisUserSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 14)
+
+ if s.Access.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "access")...),
+ psql.Arg(s.Access),
+ }})
+ }
+
+ if s.Created.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "created")...),
+ psql.Arg(s.Created),
+ }})
+ }
+
+ if s.Email.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "email")...),
+ psql.Arg(s.Email),
+ }})
+ }
+
+ if s.FullName.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "full_name")...),
+ psql.Arg(s.FullName),
+ }})
+ }
+
+ if s.ID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "id")...),
+ psql.Arg(s.ID),
+ }})
+ }
+
+ if s.Level.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "level")...),
+ psql.Arg(s.Level),
+ }})
+ }
+
+ if s.OrgID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "org_id")...),
+ psql.Arg(s.OrgID),
+ }})
+ }
+
+ if s.PublicUserID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "public_user_id")...),
+ psql.Arg(s.PublicUserID),
+ }})
+ }
+
+ if s.Region.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "region")...),
+ psql.Arg(s.Region),
+ }})
+ }
+
+ if s.Role.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "role")...),
+ psql.Arg(s.Role),
+ }})
+ }
+
+ if s.RoleID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "role_id")...),
+ psql.Arg(s.RoleID),
+ }})
+ }
+
+ if s.Username.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "username")...),
+ psql.Arg(s.Username),
+ }})
+ }
+
+ if s.UserLicenseTypeID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "user_license_type_id")...),
+ psql.Arg(s.UserLicenseTypeID),
+ }})
+ }
+
+ if s.UserType.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "user_type")...),
+ psql.Arg(s.UserType),
+ }})
+ }
+
+ return exprs
+}
+
+// FindArcgisUser retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindArcgisUser(ctx context.Context, exec bob.Executor, IDPK string, cols ...string) (*ArcgisUser, error) {
+ if len(cols) == 0 {
+ return ArcgisUsers.Query(
+ sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))),
+ ).One(ctx, exec)
+ }
+
+ return ArcgisUsers.Query(
+ sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))),
+ sm.Columns(ArcgisUsers.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// ArcgisUserExists checks the presence of a single record by primary key
+func ArcgisUserExists(ctx context.Context, exec bob.Executor, IDPK string) (bool, error) {
+ return ArcgisUsers.Query(
+ sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(IDPK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after ArcgisUser is retrieved from the database
+func (o *ArcgisUser) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = ArcgisUsers.AfterSelectHooks.RunHooks(ctx, exec, ArcgisUserSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = ArcgisUsers.AfterInsertHooks.RunHooks(ctx, exec, ArcgisUserSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, ArcgisUserSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, ArcgisUserSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the ArcgisUser
+func (o *ArcgisUser) primaryKeyVals() bob.Expression {
+ return psql.Arg(o.ID)
+}
+
+func (o *ArcgisUser) pkEQ() dialect.Expression {
+ return psql.Quote("arcgis.user_", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the ArcgisUser
+func (o *ArcgisUser) Update(ctx context.Context, exec bob.Executor, s *ArcgisUserSetter) error {
+ v, err := ArcgisUsers.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single ArcgisUser record with an executor
+func (o *ArcgisUser) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := ArcgisUsers.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the ArcgisUser using the executor
+func (o *ArcgisUser) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := ArcgisUsers.Query(
+ sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(o.ID))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after ArcgisUserSlice is retrieved from the database
+func (o ArcgisUserSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = ArcgisUsers.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = ArcgisUsers.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o ArcgisUserSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Quote("arcgis.user_", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o ArcgisUserSlice) copyMatchingRows(from ...*ArcgisUser) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.ID != old.ID {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o ArcgisUserSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUsers.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *ArcgisUser:
+ o.copyMatchingRows(retrieved)
+ case []*ArcgisUser:
+ o.copyMatchingRows(retrieved...)
+ case ArcgisUserSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a ArcgisUser or a slice of ArcgisUser
+ // then run the AfterUpdateHooks on the slice
+ _, err = ArcgisUsers.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o ArcgisUserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUsers.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *ArcgisUser:
+ o.copyMatchingRows(retrieved)
+ case []*ArcgisUser:
+ o.copyMatchingRows(retrieved...)
+ case ArcgisUserSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a ArcgisUser or a slice of ArcgisUser
+ // then run the AfterDeleteHooks on the slice
+ _, err = ArcgisUsers.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o ArcgisUserSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ArcgisUserSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := ArcgisUsers.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o ArcgisUserSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := ArcgisUsers.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o ArcgisUserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := ArcgisUsers.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// PublicUserUser starts a query for related objects on user_
+func (o *ArcgisUser) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
+ return Users.Query(append(mods,
+ sm.Where(Users.Columns.ID.EQ(psql.Arg(o.PublicUserID))),
+ )...)
+}
+
+func (os ArcgisUserSlice) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
+ pkPublicUserID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkPublicUserID = append(pkPublicUserID, o.PublicUserID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkPublicUserID), "integer[]")),
+ ))
+
+ return Users.Query(append(mods,
+ sm.Where(psql.Group(Users.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+// UserUserPrivileges starts a query for related objects on arcgis.user_privilege
+func (o *ArcgisUser) UserUserPrivileges(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUserPrivilegesQuery {
+ return ArcgisUserPrivileges.Query(append(mods,
+ sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(o.ID))),
+ )...)
+}
+
+func (os ArcgisUserSlice) UserUserPrivileges(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUserPrivilegesQuery {
+ pkID := make(pgtypes.Array[string], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkID = append(pkID, o.ID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkID), "text[]")),
+ ))
+
+ return ArcgisUserPrivileges.Query(append(mods,
+ sm.Where(psql.Group(ArcgisUserPrivileges.Columns.UserID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func attachArcgisUserPublicUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisuser0 *ArcgisUser, user1 *User) (*ArcgisUser, error) {
+ setter := &ArcgisUserSetter{
+ PublicUserID: omit.From(user1.ID),
+ }
+
+ err := arcgisuser0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachArcgisUserPublicUserUser0: %w", err)
+ }
+
+ return arcgisuser0, nil
+}
+
+func (arcgisuser0 *ArcgisUser) InsertPublicUserUser(ctx context.Context, exec bob.Executor, related *UserSetter) error {
+ var err error
+
+ user1, err := Users.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachArcgisUserPublicUserUser0(ctx, exec, 1, arcgisuser0, user1)
+ if err != nil {
+ return err
+ }
+
+ arcgisuser0.R.PublicUserUser = user1
+
+ user1.R.PublicUserUser = append(user1.R.PublicUserUser, arcgisuser0)
+
+ return nil
+}
+
+func (arcgisuser0 *ArcgisUser) AttachPublicUserUser(ctx context.Context, exec bob.Executor, user1 *User) error {
+ var err error
+
+ _, err = attachArcgisUserPublicUserUser0(ctx, exec, 1, arcgisuser0, user1)
+ if err != nil {
+ return err
+ }
+
+ arcgisuser0.R.PublicUserUser = user1
+
+ user1.R.PublicUserUser = append(user1.R.PublicUserUser, arcgisuser0)
+
+ return nil
+}
+
+func insertArcgisUserUserUserPrivileges0(ctx context.Context, exec bob.Executor, arcgisUserPrivileges1 []*ArcgisUserPrivilegeSetter, arcgisuser0 *ArcgisUser) (ArcgisUserPrivilegeSlice, error) {
+ for i := range arcgisUserPrivileges1 {
+ arcgisUserPrivileges1[i].UserID = omit.From(arcgisuser0.ID)
+ }
+
+ ret, err := ArcgisUserPrivileges.Insert(bob.ToMods(arcgisUserPrivileges1...)).All(ctx, exec)
+ if err != nil {
+ return ret, fmt.Errorf("insertArcgisUserUserUserPrivileges0: %w", err)
+ }
+
+ return ret, nil
+}
+
+func attachArcgisUserUserUserPrivileges0(ctx context.Context, exec bob.Executor, count int, arcgisUserPrivileges1 ArcgisUserPrivilegeSlice, arcgisuser0 *ArcgisUser) (ArcgisUserPrivilegeSlice, error) {
+ setter := &ArcgisUserPrivilegeSetter{
+ UserID: omit.From(arcgisuser0.ID),
+ }
+
+ err := arcgisUserPrivileges1.UpdateAll(ctx, exec, *setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachArcgisUserUserUserPrivileges0: %w", err)
+ }
+
+ return arcgisUserPrivileges1, nil
+}
+
+func (arcgisuser0 *ArcgisUser) InsertUserUserPrivileges(ctx context.Context, exec bob.Executor, related ...*ArcgisUserPrivilegeSetter) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+
+ arcgisUserPrivileges1, err := insertArcgisUserUserUserPrivileges0(ctx, exec, related, arcgisuser0)
+ if err != nil {
+ return err
+ }
+
+ arcgisuser0.R.UserUserPrivileges = append(arcgisuser0.R.UserUserPrivileges, arcgisUserPrivileges1...)
+
+ for _, rel := range arcgisUserPrivileges1 {
+ rel.R.UserUser = arcgisuser0
+ }
+ return nil
+}
+
+func (arcgisuser0 *ArcgisUser) AttachUserUserPrivileges(ctx context.Context, exec bob.Executor, related ...*ArcgisUserPrivilege) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+ arcgisUserPrivileges1 := ArcgisUserPrivilegeSlice(related)
+
+ _, err = attachArcgisUserUserUserPrivileges0(ctx, exec, len(related), arcgisUserPrivileges1, arcgisuser0)
+ if err != nil {
+ return err
+ }
+
+ arcgisuser0.R.UserUserPrivileges = append(arcgisuser0.R.UserUserPrivileges, arcgisUserPrivileges1...)
+
+ for _, rel := range related {
+ rel.R.UserUser = arcgisuser0
+ }
+
+ return nil
+}
+
+type arcgisuserWhere[Q psql.Filterable] struct {
+ Access psql.WhereMod[Q, string]
+ Created psql.WhereMod[Q, time.Time]
+ Email psql.WhereMod[Q, string]
+ FullName psql.WhereMod[Q, string]
+ ID psql.WhereMod[Q, string]
+ Level psql.WhereMod[Q, string]
+ OrgID psql.WhereMod[Q, string]
+ PublicUserID psql.WhereMod[Q, int32]
+ Region psql.WhereMod[Q, string]
+ Role psql.WhereMod[Q, string]
+ RoleID psql.WhereMod[Q, string]
+ Username psql.WhereMod[Q, string]
+ UserLicenseTypeID psql.WhereMod[Q, string]
+ UserType psql.WhereMod[Q, string]
+}
+
+func (arcgisuserWhere[Q]) AliasedAs(alias string) arcgisuserWhere[Q] {
+ return buildArcgisUserWhere[Q](buildArcgisUserColumns(alias))
+}
+
+func buildArcgisUserWhere[Q psql.Filterable](cols arcgisuserColumns) arcgisuserWhere[Q] {
+ return arcgisuserWhere[Q]{
+ Access: psql.Where[Q, string](cols.Access),
+ Created: psql.Where[Q, time.Time](cols.Created),
+ Email: psql.Where[Q, string](cols.Email),
+ FullName: psql.Where[Q, string](cols.FullName),
+ ID: psql.Where[Q, string](cols.ID),
+ Level: psql.Where[Q, string](cols.Level),
+ OrgID: psql.Where[Q, string](cols.OrgID),
+ PublicUserID: psql.Where[Q, int32](cols.PublicUserID),
+ Region: psql.Where[Q, string](cols.Region),
+ Role: psql.Where[Q, string](cols.Role),
+ RoleID: psql.Where[Q, string](cols.RoleID),
+ Username: psql.Where[Q, string](cols.Username),
+ UserLicenseTypeID: psql.Where[Q, string](cols.UserLicenseTypeID),
+ UserType: psql.Where[Q, string](cols.UserType),
+ }
+}
+
+func (o *ArcgisUser) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "PublicUserUser":
+ rel, ok := retrieved.(*User)
+ if !ok {
+ return fmt.Errorf("arcgisuser cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.PublicUserUser = rel
+
+ if rel != nil {
+ rel.R.PublicUserUser = ArcgisUserSlice{o}
+ }
+ return nil
+ case "UserUserPrivileges":
+ rels, ok := retrieved.(ArcgisUserPrivilegeSlice)
+ if !ok {
+ return fmt.Errorf("arcgisuser cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.UserUserPrivileges = rels
+
+ for _, rel := range rels {
+ if rel != nil {
+ rel.R.UserUser = o
+ }
+ }
+ return nil
+ default:
+ return fmt.Errorf("arcgisuser has no relationship %q", name)
+ }
+}
+
+type arcgisuserPreloader struct {
+ PublicUserUser func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildArcgisUserPreloader() arcgisuserPreloader {
+ return arcgisuserPreloader{
+ PublicUserUser: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*User, UserSlice](psql.PreloadRel{
+ Name: "PublicUserUser",
+ Sides: []psql.PreloadSide{
+ {
+ From: ArcgisUsers,
+ To: Users,
+ FromColumns: []string{"public_user_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, Users.Columns.Names(), opts...)
+ },
+ }
+}
+
+type arcgisuserThenLoader[Q orm.Loadable] struct {
+ PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildArcgisUserThenLoader[Q orm.Loadable]() arcgisuserThenLoader[Q] {
+ type PublicUserUserLoadInterface interface {
+ LoadPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type UserUserPrivilegesLoadInterface interface {
+ LoadUserUserPrivileges(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return arcgisuserThenLoader[Q]{
+ PublicUserUser: thenLoadBuilder[Q](
+ "PublicUserUser",
+ func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadPublicUserUser(ctx, exec, mods...)
+ },
+ ),
+ UserUserPrivileges: thenLoadBuilder[Q](
+ "UserUserPrivileges",
+ func(ctx context.Context, exec bob.Executor, retrieved UserUserPrivilegesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadUserUserPrivileges(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadPublicUserUser loads the arcgisuser's PublicUserUser into the .R struct
+func (o *ArcgisUser) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.PublicUserUser = nil
+
+ related, err := o.PublicUserUser(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ related.R.PublicUserUser = ArcgisUserSlice{o}
+
+ o.R.PublicUserUser = related
+ return nil
+}
+
+// LoadPublicUserUser loads the arcgisuser's PublicUserUser into the .R struct
+func (os ArcgisUserSlice) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ users, err := os.PublicUserUser(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range users {
+
+ if !(o.PublicUserID == rel.ID) {
+ continue
+ }
+
+ rel.R.PublicUserUser = append(rel.R.PublicUserUser, o)
+
+ o.R.PublicUserUser = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+// LoadUserUserPrivileges loads the arcgisuser's UserUserPrivileges into the .R struct
+func (o *ArcgisUser) LoadUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.UserUserPrivileges = nil
+
+ related, err := o.UserUserPrivileges(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, rel := range related {
+ rel.R.UserUser = o
+ }
+
+ o.R.UserUserPrivileges = related
+ return nil
+}
+
+// LoadUserUserPrivileges loads the arcgisuser's UserUserPrivileges into the .R struct
+func (os ArcgisUserSlice) LoadUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ arcgisUserPrivileges, err := os.UserUserPrivileges(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ o.R.UserUserPrivileges = nil
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range arcgisUserPrivileges {
+
+ if !(o.ID == rel.UserID) {
+ continue
+ }
+
+ rel.R.UserUser = o
+
+ o.R.UserUserPrivileges = append(o.R.UserUserPrivileges, rel)
+ }
+ }
+
+ return nil
+}
+
+// arcgisuserC is where relationship counts are stored.
+type arcgisuserC struct {
+ UserUserPrivileges *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *ArcgisUser) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "UserUserPrivileges":
+ o.C.UserUserPrivileges = &count
+ }
+ return nil
+}
+
+type arcgisuserCountPreloader struct {
+ UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildArcgisUserCountPreloader() arcgisuserCountPreloader {
+ return arcgisuserCountPreloader{
+ UserUserPrivileges: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*ArcgisUser]("UserUserPrivileges", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = ArcgisUsers.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(ArcgisUserPrivileges.Name()),
+ sm.Where(psql.Quote(ArcgisUserPrivileges.Alias(), "user_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type arcgisuserCountThenLoader[Q orm.Loadable] struct {
+ UserUserPrivileges func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildArcgisUserCountThenLoader[Q orm.Loadable]() arcgisuserCountThenLoader[Q] {
+ type UserUserPrivilegesCountInterface interface {
+ LoadCountUserUserPrivileges(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return arcgisuserCountThenLoader[Q]{
+ UserUserPrivileges: countThenLoadBuilder[Q](
+ "UserUserPrivileges",
+ func(ctx context.Context, exec bob.Executor, retrieved UserUserPrivilegesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountUserUserPrivileges(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountUserUserPrivileges loads the count of UserUserPrivileges into the C struct
+func (o *ArcgisUser) LoadCountUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.UserUserPrivileges(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.UserUserPrivileges = &count
+ return nil
+}
+
+// LoadCountUserUserPrivileges loads the count of UserUserPrivileges for a slice
+func (os ArcgisUserSlice) LoadCountUserUserPrivileges(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountUserUserPrivileges(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+type arcgisuserJoins[Q dialect.Joinable] struct {
+ typ string
+ PublicUserUser modAs[Q, userColumns]
+ UserUserPrivileges modAs[Q, arcgisUserPrivilegeColumns]
+}
+
+func (j arcgisuserJoins[Q]) aliasedAs(alias string) arcgisuserJoins[Q] {
+ return buildArcgisUserJoins[Q](buildArcgisUserColumns(alias), j.typ)
+}
+
+func buildArcgisUserJoins[Q dialect.Joinable](cols arcgisuserColumns, typ string) arcgisuserJoins[Q] {
+ return arcgisuserJoins[Q]{
+ typ: typ,
+ PublicUserUser: modAs[Q, userColumns]{
+ c: Users.Columns,
+ f: func(to userColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, Users.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.PublicUserID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ UserUserPrivileges: modAs[Q, arcgisUserPrivilegeColumns]{
+ c: ArcgisUserPrivileges.Columns,
+ f: func(to arcgisUserPrivilegeColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, ArcgisUserPrivileges.Name().As(to.Alias())).On(
+ to.UserID.EQ(cols.ID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/arcgis.user_privilege.bob.go b/db/models/arcgis.user_privilege.bob.go
new file mode 100644
index 00000000..0783119b
--- /dev/null
+++ b/db/models/arcgis.user_privilege.bob.go
@@ -0,0 +1,612 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+)
+
+// ArcgisUserPrivilege is an object representing the database table.
+type ArcgisUserPrivilege struct {
+ UserID string `db:"user_id,pk" `
+ Privilege string `db:"privilege,pk" `
+
+ R arcgisUserPrivilegeR `db:"-" `
+}
+
+// ArcgisUserPrivilegeSlice is an alias for a slice of pointers to ArcgisUserPrivilege.
+// This should almost always be used instead of []*ArcgisUserPrivilege.
+type ArcgisUserPrivilegeSlice []*ArcgisUserPrivilege
+
+// ArcgisUserPrivileges contains methods to work with the user_privilege table
+var ArcgisUserPrivileges = psql.NewTablex[*ArcgisUserPrivilege, ArcgisUserPrivilegeSlice, *ArcgisUserPrivilegeSetter]("arcgis", "user_privilege", buildArcgisUserPrivilegeColumns("arcgis.user_privilege"))
+
+// ArcgisUserPrivilegesQuery is a query on the user_privilege table
+type ArcgisUserPrivilegesQuery = *psql.ViewQuery[*ArcgisUserPrivilege, ArcgisUserPrivilegeSlice]
+
+// arcgisUserPrivilegeR is where relationships are stored.
+type arcgisUserPrivilegeR struct {
+ UserUser *ArcgisUser // arcgis.user_privilege.user_privilege_user_id_fkey
+}
+
+func buildArcgisUserPrivilegeColumns(alias string) arcgisUserPrivilegeColumns {
+ return arcgisUserPrivilegeColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "user_id", "privilege",
+ ).WithParent("arcgis.user_privilege"),
+ tableAlias: alias,
+ UserID: psql.Quote(alias, "user_id"),
+ Privilege: psql.Quote(alias, "privilege"),
+ }
+}
+
+type arcgisUserPrivilegeColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ UserID psql.Expression
+ Privilege psql.Expression
+}
+
+func (c arcgisUserPrivilegeColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (arcgisUserPrivilegeColumns) AliasedAs(alias string) arcgisUserPrivilegeColumns {
+ return buildArcgisUserPrivilegeColumns(alias)
+}
+
+// ArcgisUserPrivilegeSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type ArcgisUserPrivilegeSetter struct {
+ UserID omit.Val[string] `db:"user_id,pk" `
+ Privilege omit.Val[string] `db:"privilege,pk" `
+}
+
+func (s ArcgisUserPrivilegeSetter) SetColumns() []string {
+ vals := make([]string, 0, 2)
+ if s.UserID.IsValue() {
+ vals = append(vals, "user_id")
+ }
+ if s.Privilege.IsValue() {
+ vals = append(vals, "privilege")
+ }
+ return vals
+}
+
+func (s ArcgisUserPrivilegeSetter) Overwrite(t *ArcgisUserPrivilege) {
+ if s.UserID.IsValue() {
+ t.UserID = s.UserID.MustGet()
+ }
+ if s.Privilege.IsValue() {
+ t.Privilege = s.Privilege.MustGet()
+ }
+}
+
+func (s *ArcgisUserPrivilegeSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUserPrivileges.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 2)
+ if s.UserID.IsValue() {
+ vals[0] = psql.Arg(s.UserID.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.Privilege.IsValue() {
+ vals[1] = psql.Arg(s.Privilege.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s ArcgisUserPrivilegeSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s ArcgisUserPrivilegeSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 2)
+
+ if s.UserID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "user_id")...),
+ psql.Arg(s.UserID),
+ }})
+ }
+
+ if s.Privilege.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "privilege")...),
+ psql.Arg(s.Privilege),
+ }})
+ }
+
+ return exprs
+}
+
+// FindArcgisUserPrivilege retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindArcgisUserPrivilege(ctx context.Context, exec bob.Executor, UserIDPK string, PrivilegePK string, cols ...string) (*ArcgisUserPrivilege, error) {
+ if len(cols) == 0 {
+ return ArcgisUserPrivileges.Query(
+ sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))),
+ sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))),
+ ).One(ctx, exec)
+ }
+
+ return ArcgisUserPrivileges.Query(
+ sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))),
+ sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))),
+ sm.Columns(ArcgisUserPrivileges.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// ArcgisUserPrivilegeExists checks the presence of a single record by primary key
+func ArcgisUserPrivilegeExists(ctx context.Context, exec bob.Executor, UserIDPK string, PrivilegePK string) (bool, error) {
+ return ArcgisUserPrivileges.Query(
+ sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(UserIDPK))),
+ sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(PrivilegePK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after ArcgisUserPrivilege is retrieved from the database
+func (o *ArcgisUserPrivilege) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = ArcgisUserPrivileges.AfterSelectHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = ArcgisUserPrivileges.AfterInsertHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, ArcgisUserPrivilegeSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the ArcgisUserPrivilege
+func (o *ArcgisUserPrivilege) primaryKeyVals() bob.Expression {
+ return psql.ArgGroup(
+ o.UserID,
+ o.Privilege,
+ )
+}
+
+func (o *ArcgisUserPrivilege) pkEQ() dialect.Expression {
+ return psql.Group(psql.Quote("arcgis.user_privilege", "user_id"), psql.Quote("arcgis.user_privilege", "privilege")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the ArcgisUserPrivilege
+func (o *ArcgisUserPrivilege) Update(ctx context.Context, exec bob.Executor, s *ArcgisUserPrivilegeSetter) error {
+ v, err := ArcgisUserPrivileges.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single ArcgisUserPrivilege record with an executor
+func (o *ArcgisUserPrivilege) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := ArcgisUserPrivileges.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the ArcgisUserPrivilege using the executor
+func (o *ArcgisUserPrivilege) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := ArcgisUserPrivileges.Query(
+ sm.Where(ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(o.UserID))),
+ sm.Where(ArcgisUserPrivileges.Columns.Privilege.EQ(psql.Arg(o.Privilege))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after ArcgisUserPrivilegeSlice is retrieved from the database
+func (o ArcgisUserPrivilegeSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = ArcgisUserPrivileges.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = ArcgisUserPrivileges.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o ArcgisUserPrivilegeSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Group(psql.Quote("arcgis.user_privilege", "user_id"), psql.Quote("arcgis.user_privilege", "privilege")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o ArcgisUserPrivilegeSlice) copyMatchingRows(from ...*ArcgisUserPrivilege) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.UserID != old.UserID {
+ continue
+ }
+ if new.Privilege != old.Privilege {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o ArcgisUserPrivilegeSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUserPrivileges.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *ArcgisUserPrivilege:
+ o.copyMatchingRows(retrieved)
+ case []*ArcgisUserPrivilege:
+ o.copyMatchingRows(retrieved...)
+ case ArcgisUserPrivilegeSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a ArcgisUserPrivilege or a slice of ArcgisUserPrivilege
+ // then run the AfterUpdateHooks on the slice
+ _, err = ArcgisUserPrivileges.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o ArcgisUserPrivilegeSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return ArcgisUserPrivileges.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *ArcgisUserPrivilege:
+ o.copyMatchingRows(retrieved)
+ case []*ArcgisUserPrivilege:
+ o.copyMatchingRows(retrieved...)
+ case ArcgisUserPrivilegeSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a ArcgisUserPrivilege or a slice of ArcgisUserPrivilege
+ // then run the AfterDeleteHooks on the slice
+ _, err = ArcgisUserPrivileges.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o ArcgisUserPrivilegeSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ArcgisUserPrivilegeSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := ArcgisUserPrivileges.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o ArcgisUserPrivilegeSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := ArcgisUserPrivileges.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o ArcgisUserPrivilegeSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := ArcgisUserPrivileges.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// UserUser starts a query for related objects on arcgis.user_
+func (o *ArcgisUserPrivilege) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery {
+ return ArcgisUsers.Query(append(mods,
+ sm.Where(ArcgisUsers.Columns.ID.EQ(psql.Arg(o.UserID))),
+ )...)
+}
+
+func (os ArcgisUserPrivilegeSlice) UserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery {
+ pkUserID := make(pgtypes.Array[string], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkUserID = append(pkUserID, o.UserID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkUserID), "text[]")),
+ ))
+
+ return ArcgisUsers.Query(append(mods,
+ sm.Where(psql.Group(ArcgisUsers.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func attachArcgisUserPrivilegeUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisUserPrivilege0 *ArcgisUserPrivilege, arcgisuser1 *ArcgisUser) (*ArcgisUserPrivilege, error) {
+ setter := &ArcgisUserPrivilegeSetter{
+ UserID: omit.From(arcgisuser1.ID),
+ }
+
+ err := arcgisUserPrivilege0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachArcgisUserPrivilegeUserUser0: %w", err)
+ }
+
+ return arcgisUserPrivilege0, nil
+}
+
+func (arcgisUserPrivilege0 *ArcgisUserPrivilege) InsertUserUser(ctx context.Context, exec bob.Executor, related *ArcgisUserSetter) error {
+ var err error
+
+ arcgisuser1, err := ArcgisUsers.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachArcgisUserPrivilegeUserUser0(ctx, exec, 1, arcgisUserPrivilege0, arcgisuser1)
+ if err != nil {
+ return err
+ }
+
+ arcgisUserPrivilege0.R.UserUser = arcgisuser1
+
+ arcgisuser1.R.UserUserPrivileges = append(arcgisuser1.R.UserUserPrivileges, arcgisUserPrivilege0)
+
+ return nil
+}
+
+func (arcgisUserPrivilege0 *ArcgisUserPrivilege) AttachUserUser(ctx context.Context, exec bob.Executor, arcgisuser1 *ArcgisUser) error {
+ var err error
+
+ _, err = attachArcgisUserPrivilegeUserUser0(ctx, exec, 1, arcgisUserPrivilege0, arcgisuser1)
+ if err != nil {
+ return err
+ }
+
+ arcgisUserPrivilege0.R.UserUser = arcgisuser1
+
+ arcgisuser1.R.UserUserPrivileges = append(arcgisuser1.R.UserUserPrivileges, arcgisUserPrivilege0)
+
+ return nil
+}
+
+type arcgisUserPrivilegeWhere[Q psql.Filterable] struct {
+ UserID psql.WhereMod[Q, string]
+ Privilege psql.WhereMod[Q, string]
+}
+
+func (arcgisUserPrivilegeWhere[Q]) AliasedAs(alias string) arcgisUserPrivilegeWhere[Q] {
+ return buildArcgisUserPrivilegeWhere[Q](buildArcgisUserPrivilegeColumns(alias))
+}
+
+func buildArcgisUserPrivilegeWhere[Q psql.Filterable](cols arcgisUserPrivilegeColumns) arcgisUserPrivilegeWhere[Q] {
+ return arcgisUserPrivilegeWhere[Q]{
+ UserID: psql.Where[Q, string](cols.UserID),
+ Privilege: psql.Where[Q, string](cols.Privilege),
+ }
+}
+
+func (o *ArcgisUserPrivilege) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "UserUser":
+ rel, ok := retrieved.(*ArcgisUser)
+ if !ok {
+ return fmt.Errorf("arcgisUserPrivilege cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.UserUser = rel
+
+ if rel != nil {
+ rel.R.UserUserPrivileges = ArcgisUserPrivilegeSlice{o}
+ }
+ return nil
+ default:
+ return fmt.Errorf("arcgisUserPrivilege has no relationship %q", name)
+ }
+}
+
+type arcgisUserPrivilegePreloader struct {
+ UserUser func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildArcgisUserPrivilegePreloader() arcgisUserPrivilegePreloader {
+ return arcgisUserPrivilegePreloader{
+ UserUser: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*ArcgisUser, ArcgisUserSlice](psql.PreloadRel{
+ Name: "UserUser",
+ Sides: []psql.PreloadSide{
+ {
+ From: ArcgisUserPrivileges,
+ To: ArcgisUsers,
+ FromColumns: []string{"user_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, ArcgisUsers.Columns.Names(), opts...)
+ },
+ }
+}
+
+type arcgisUserPrivilegeThenLoader[Q orm.Loadable] struct {
+ UserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildArcgisUserPrivilegeThenLoader[Q orm.Loadable]() arcgisUserPrivilegeThenLoader[Q] {
+ type UserUserLoadInterface interface {
+ LoadUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return arcgisUserPrivilegeThenLoader[Q]{
+ UserUser: thenLoadBuilder[Q](
+ "UserUser",
+ func(ctx context.Context, exec bob.Executor, retrieved UserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadUserUser(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadUserUser loads the arcgisUserPrivilege's UserUser into the .R struct
+func (o *ArcgisUserPrivilege) LoadUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.UserUser = nil
+
+ related, err := o.UserUser(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ related.R.UserUserPrivileges = ArcgisUserPrivilegeSlice{o}
+
+ o.R.UserUser = related
+ return nil
+}
+
+// LoadUserUser loads the arcgisUserPrivilege's UserUser into the .R struct
+func (os ArcgisUserPrivilegeSlice) LoadUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ arcgisusers, err := os.UserUser(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range arcgisusers {
+
+ if !(o.UserID == rel.ID) {
+ continue
+ }
+
+ rel.R.UserUserPrivileges = append(rel.R.UserUserPrivileges, o)
+
+ o.R.UserUser = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+type arcgisUserPrivilegeJoins[Q dialect.Joinable] struct {
+ typ string
+ UserUser modAs[Q, arcgisuserColumns]
+}
+
+func (j arcgisUserPrivilegeJoins[Q]) aliasedAs(alias string) arcgisUserPrivilegeJoins[Q] {
+ return buildArcgisUserPrivilegeJoins[Q](buildArcgisUserPrivilegeColumns(alias), j.typ)
+}
+
+func buildArcgisUserPrivilegeJoins[Q dialect.Joinable](cols arcgisUserPrivilegeColumns, typ string) arcgisUserPrivilegeJoins[Q] {
+ return arcgisUserPrivilegeJoins[Q]{
+ typ: typ,
+ UserUser: modAs[Q, arcgisuserColumns]{
+ c: ArcgisUsers.Columns,
+ f: func(to arcgisuserColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, ArcgisUsers.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.UserID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/bob_counts.bob.go b/db/models/bob_counts.bob.go
new file mode 100644
index 00000000..be17543e
--- /dev/null
+++ b/db/models/bob_counts.bob.go
@@ -0,0 +1,168 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "io"
+
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/scan"
+)
+
+var (
+ PreloadCount = getPreloadCount()
+ ThenLoadCount = getThenLoadCount[*dialect.SelectQuery]()
+ InsertThenLoadCount = getThenLoadCount[*dialect.InsertQuery]()
+)
+
+type preloadCounts struct {
+ ArcgisUser arcgisuserCountPreloader
+ NoteAudio noteAudioCountPreloader
+ NoteImage noteImageCountPreloader
+ Organization organizationCountPreloader
+ PublicreportPool publicreportPoolCountPreloader
+ PublicreportQuick publicreportQuickCountPreloader
+ User userCountPreloader
+}
+
+func getPreloadCount() preloadCounts {
+ return preloadCounts{
+ ArcgisUser: buildArcgisUserCountPreloader(),
+ NoteAudio: buildNoteAudioCountPreloader(),
+ NoteImage: buildNoteImageCountPreloader(),
+ Organization: buildOrganizationCountPreloader(),
+ PublicreportPool: buildPublicreportPoolCountPreloader(),
+ PublicreportQuick: buildPublicreportQuickCountPreloader(),
+ User: buildUserCountPreloader(),
+ }
+}
+
+type thenLoadCounts[Q orm.Loadable] struct {
+ ArcgisUser arcgisuserCountThenLoader[Q]
+ NoteAudio noteAudioCountThenLoader[Q]
+ NoteImage noteImageCountThenLoader[Q]
+ Organization organizationCountThenLoader[Q]
+ PublicreportPool publicreportPoolCountThenLoader[Q]
+ PublicreportQuick publicreportQuickCountThenLoader[Q]
+ User userCountThenLoader[Q]
+}
+
+func getThenLoadCount[Q orm.Loadable]() thenLoadCounts[Q] {
+ return thenLoadCounts[Q]{
+ ArcgisUser: buildArcgisUserCountThenLoader[Q](),
+ NoteAudio: buildNoteAudioCountThenLoader[Q](),
+ NoteImage: buildNoteImageCountThenLoader[Q](),
+ Organization: buildOrganizationCountThenLoader[Q](),
+ PublicreportPool: buildPublicreportPoolCountThenLoader[Q](),
+ PublicreportQuick: buildPublicreportQuickCountThenLoader[Q](),
+ User: buildUserCountThenLoader[Q](),
+ }
+}
+
+func countThenLoadBuilder[Q orm.Loadable, T any](name string, f func(context.Context, bob.Executor, T, ...bob.Mod[*dialect.SelectQuery]) error) func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] {
+ return func(queryMods ...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q] {
+ return func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ loader, isLoader := retrieved.(T)
+ if !isLoader {
+ return nil // silently skip if not the right type
+ }
+
+ return f(ctx, exec, loader, queryMods...)
+ }
+ }
+}
+
+// countPreloadable is an interface for models that can have counts preloaded
+type countPreloadable interface {
+ PreloadCount(name string, count int64) error
+}
+
+// countPreloadMod is used to add a count subquery to the SELECT
+type countPreloadMod[T countPreloadable] struct {
+ name string
+ countExpr func(from string) bob.Expression
+}
+
+// Apply implements bob.Mod
+func (c countPreloadMod[T]) Apply(q *dialect.SelectQuery) {
+ c.applyCount(q, "")
+}
+
+// applyCount adds the count subquery to the query
+func (c countPreloadMod[T]) applyCount(q *dialect.SelectQuery, parent string) {
+ countCol := c.countExpr(parent)
+ q.AppendPreloadSelect(aliasedExpr{expr: countCol, alias: "__count_" + c.name})
+}
+
+// aliasedExpr wraps an expression with an alias
+type aliasedExpr struct {
+ expr bob.Expression
+ alias string
+}
+
+func (a aliasedExpr) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ args, err := a.expr.WriteSQL(ctx, w, d, start)
+ if err != nil {
+ return nil, err
+ }
+ w.WriteString(" AS ")
+ d.WriteQuoted(w, a.alias)
+ return args, nil
+}
+
+// countPreloader returns a Preloader that adds a count subquery
+func countPreloader[T countPreloadable](name string, countExpr func(from string) bob.Expression) psql.Preloader {
+ return func(parent string) (bob.Mod[*dialect.SelectQuery], scan.MapperMod, []bob.Loader) {
+ m := countPreloadMod[T]{
+ name: name,
+ countExpr: countExpr,
+ }
+
+ queryMod := bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
+ m.applyCount(q, parent)
+ })
+
+ mapperMod := func(ctx context.Context, cols []string) (scan.BeforeFunc, scan.AfterMod) {
+ // Find the count column
+ countColName := "__count_" + name
+ colIndex := -1
+ for i, col := range cols {
+ if col == countColName {
+ colIndex = i
+ break
+ }
+ }
+
+ return func(r *scan.Row) (any, error) {
+ if colIndex >= 0 {
+ var count *int64
+ r.ScheduleScanByIndex(colIndex, &count)
+ return &count, nil
+ }
+ return nil, nil
+ }, func(link, retrieved any) error {
+ if link == nil {
+ return nil
+ }
+ countPtr, ok := link.(**int64)
+ if !ok || countPtr == nil || *countPtr == nil {
+ return nil
+ }
+
+ loader, isLoader := retrieved.(countPreloadable)
+ if !isLoader {
+ return nil
+ }
+
+ return loader.PreloadCount(name, **countPtr)
+ }
+ }
+
+ return queryMod, mapperMod, nil
+ }
+}
diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go
index 37643b0c..03d85cb1 100644
--- a/db/models/bob_joins.bob.go
+++ b/db/models/bob_joins.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -32,6 +32,8 @@ func (j joinSet[Q]) AliasedAs(alias string) joinSet[Q] {
}
type joins[Q dialect.Joinable] struct {
+ ArcgisUsers joinSet[arcgisuserJoins[Q]]
+ ArcgisUserPrivileges joinSet[arcgisUserPrivilegeJoins[Q]]
FieldseekerContainerrelates joinSet[fieldseekerContainerrelateJoins[Q]]
FieldseekerFieldscoutinglogs joinSet[fieldseekerFieldscoutinglogJoins[Q]]
FieldseekerHabitatrelates joinSet[fieldseekerHabitatrelateJoins[Q]]
@@ -87,6 +89,8 @@ func buildJoinSet[Q interface{ aliasedAs(string) Q }, C any, F func(C, string) Q
func getJoins[Q dialect.Joinable]() joins[Q] {
return joins[Q]{
+ ArcgisUsers: buildJoinSet[arcgisuserJoins[Q]](ArcgisUsers.Columns, buildArcgisUserJoins),
+ ArcgisUserPrivileges: buildJoinSet[arcgisUserPrivilegeJoins[Q]](ArcgisUserPrivileges.Columns, buildArcgisUserPrivilegeJoins),
FieldseekerContainerrelates: buildJoinSet[fieldseekerContainerrelateJoins[Q]](FieldseekerContainerrelates.Columns, buildFieldseekerContainerrelateJoins),
FieldseekerFieldscoutinglogs: buildJoinSet[fieldseekerFieldscoutinglogJoins[Q]](FieldseekerFieldscoutinglogs.Columns, buildFieldseekerFieldscoutinglogJoins),
FieldseekerHabitatrelates: buildJoinSet[fieldseekerHabitatrelateJoins[Q]](FieldseekerHabitatrelates.Columns, buildFieldseekerHabitatrelateJoins),
diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go
index 5af29980..21748f91 100644
--- a/db/models/bob_loaders.bob.go
+++ b/db/models/bob_loaders.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -17,6 +17,8 @@ import (
var Preload = getPreloaders()
type preloaders struct {
+ ArcgisUser arcgisuserPreloader
+ ArcgisUserPrivilege arcgisUserPrivilegePreloader
FieldseekerContainerrelate fieldseekerContainerrelatePreloader
FieldseekerFieldscoutinglog fieldseekerFieldscoutinglogPreloader
FieldseekerHabitatrelate fieldseekerHabitatrelatePreloader
@@ -64,6 +66,8 @@ type preloaders struct {
func getPreloaders() preloaders {
return preloaders{
+ ArcgisUser: buildArcgisUserPreloader(),
+ ArcgisUserPrivilege: buildArcgisUserPrivilegePreloader(),
FieldseekerContainerrelate: buildFieldseekerContainerrelatePreloader(),
FieldseekerFieldscoutinglog: buildFieldseekerFieldscoutinglogPreloader(),
FieldseekerHabitatrelate: buildFieldseekerHabitatrelatePreloader(),
@@ -117,6 +121,8 @@ var (
)
type thenLoaders[Q orm.Loadable] struct {
+ ArcgisUser arcgisuserThenLoader[Q]
+ ArcgisUserPrivilege arcgisUserPrivilegeThenLoader[Q]
FieldseekerContainerrelate fieldseekerContainerrelateThenLoader[Q]
FieldseekerFieldscoutinglog fieldseekerFieldscoutinglogThenLoader[Q]
FieldseekerHabitatrelate fieldseekerHabitatrelateThenLoader[Q]
@@ -164,6 +170,8 @@ type thenLoaders[Q orm.Loadable] struct {
func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] {
return thenLoaders[Q]{
+ ArcgisUser: buildArcgisUserThenLoader[Q](),
+ ArcgisUserPrivilege: buildArcgisUserPrivilegeThenLoader[Q](),
FieldseekerContainerrelate: buildFieldseekerContainerrelateThenLoader[Q](),
FieldseekerFieldscoutinglog: buildFieldseekerFieldscoutinglogThenLoader[Q](),
FieldseekerHabitatrelate: buildFieldseekerHabitatrelateThenLoader[Q](),
diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go
index 6af44c49..69ff2736 100644
--- a/db/models/bob_where.bob.go
+++ b/db/models/bob_where.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -17,6 +17,8 @@ var (
)
func Where[Q psql.Filterable]() struct {
+ ArcgisUsers arcgisuserWhere[Q]
+ ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q]
Districts districtWhere[Q]
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
@@ -72,6 +74,8 @@ func Where[Q psql.Filterable]() struct {
Users userWhere[Q]
} {
return struct {
+ ArcgisUsers arcgisuserWhere[Q]
+ ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q]
Districts districtWhere[Q]
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
@@ -126,6 +130,8 @@ func Where[Q psql.Filterable]() struct {
SpatialRefSys spatialRefSyWhere[Q]
Users userWhere[Q]
}{
+ ArcgisUsers: buildArcgisUserWhere[Q](ArcgisUsers.Columns),
+ ArcgisUserPrivileges: buildArcgisUserPrivilegeWhere[Q](ArcgisUserPrivileges.Columns),
Districts: buildDistrictWhere[Q](Districts.Columns),
FieldseekerContainerrelates: buildFieldseekerContainerrelateWhere[Q](FieldseekerContainerrelates.Columns),
FieldseekerFieldscoutinglogs: buildFieldseekerFieldscoutinglogWhere[Q](FieldseekerFieldscoutinglogs.Columns),
diff --git a/db/models/district.bob.go b/db/models/district.bob.go
index 026f4c47..a0c3bb5b 100644
--- a/db/models/district.bob.go
+++ b/db/models/district.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.containerrelate.bob.go b/db/models/fieldseeker.containerrelate.bob.go
index 434c2320..8b439dce 100644
--- a/db/models/fieldseeker.containerrelate.bob.go
+++ b/db/models/fieldseeker.containerrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.fieldscoutinglog.bob.go b/db/models/fieldseeker.fieldscoutinglog.bob.go
index 3d88e8fd..a0caa392 100644
--- a/db/models/fieldseeker.fieldscoutinglog.bob.go
+++ b/db/models/fieldseeker.fieldscoutinglog.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.habitatrelate.bob.go b/db/models/fieldseeker.habitatrelate.bob.go
index f78468e3..cefb73a8 100644
--- a/db/models/fieldseeker.habitatrelate.bob.go
+++ b/db/models/fieldseeker.habitatrelate.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.inspectionsample.bob.go b/db/models/fieldseeker.inspectionsample.bob.go
index 16fd4908..73aaa6da 100644
--- a/db/models/fieldseeker.inspectionsample.bob.go
+++ b/db/models/fieldseeker.inspectionsample.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.inspectionsampledetail.bob.go b/db/models/fieldseeker.inspectionsampledetail.bob.go
index de4bebc5..d9d4d406 100644
--- a/db/models/fieldseeker.inspectionsampledetail.bob.go
+++ b/db/models/fieldseeker.inspectionsampledetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.linelocation.bob.go b/db/models/fieldseeker.linelocation.bob.go
index 9cafe385..9efc4ee5 100644
--- a/db/models/fieldseeker.linelocation.bob.go
+++ b/db/models/fieldseeker.linelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.locationtracking.bob.go b/db/models/fieldseeker.locationtracking.bob.go
index da97a897..facfcf7d 100644
--- a/db/models/fieldseeker.locationtracking.bob.go
+++ b/db/models/fieldseeker.locationtracking.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.mosquitoinspection.bob.go b/db/models/fieldseeker.mosquitoinspection.bob.go
index 85baa2b7..db094235 100644
--- a/db/models/fieldseeker.mosquitoinspection.bob.go
+++ b/db/models/fieldseeker.mosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.pointlocation.bob.go b/db/models/fieldseeker.pointlocation.bob.go
index 4a879030..e212b558 100644
--- a/db/models/fieldseeker.pointlocation.bob.go
+++ b/db/models/fieldseeker.pointlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.polygonlocation.bob.go b/db/models/fieldseeker.polygonlocation.bob.go
index 2e65aa46..5003caa2 100644
--- a/db/models/fieldseeker.polygonlocation.bob.go
+++ b/db/models/fieldseeker.polygonlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.pool.bob.go b/db/models/fieldseeker.pool.bob.go
index c204b6c0..898e7bcb 100644
--- a/db/models/fieldseeker.pool.bob.go
+++ b/db/models/fieldseeker.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.pooldetail.bob.go b/db/models/fieldseeker.pooldetail.bob.go
index 385f4543..a9cbd612 100644
--- a/db/models/fieldseeker.pooldetail.bob.go
+++ b/db/models/fieldseeker.pooldetail.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.proposedtreatmentarea.bob.go b/db/models/fieldseeker.proposedtreatmentarea.bob.go
index 9669e95f..8f89fe65 100644
--- a/db/models/fieldseeker.proposedtreatmentarea.bob.go
+++ b/db/models/fieldseeker.proposedtreatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.qamosquitoinspection.bob.go b/db/models/fieldseeker.qamosquitoinspection.bob.go
index b742d6b3..76fcae96 100644
--- a/db/models/fieldseeker.qamosquitoinspection.bob.go
+++ b/db/models/fieldseeker.qamosquitoinspection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.rodentlocation.bob.go b/db/models/fieldseeker.rodentlocation.bob.go
index 6e57a0a1..28117cfb 100644
--- a/db/models/fieldseeker.rodentlocation.bob.go
+++ b/db/models/fieldseeker.rodentlocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.samplecollection.bob.go b/db/models/fieldseeker.samplecollection.bob.go
index 512a787f..f3648eda 100644
--- a/db/models/fieldseeker.samplecollection.bob.go
+++ b/db/models/fieldseeker.samplecollection.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.samplelocation.bob.go b/db/models/fieldseeker.samplelocation.bob.go
index 6782a33b..cde38c45 100644
--- a/db/models/fieldseeker.samplelocation.bob.go
+++ b/db/models/fieldseeker.samplelocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.servicerequest.bob.go b/db/models/fieldseeker.servicerequest.bob.go
index 5cac059f..f3b89f50 100644
--- a/db/models/fieldseeker.servicerequest.bob.go
+++ b/db/models/fieldseeker.servicerequest.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.speciesabundance.bob.go b/db/models/fieldseeker.speciesabundance.bob.go
index bb8fef8f..f8b46124 100644
--- a/db/models/fieldseeker.speciesabundance.bob.go
+++ b/db/models/fieldseeker.speciesabundance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.stormdrain.bob.go b/db/models/fieldseeker.stormdrain.bob.go
index 8169a1cd..c603b20c 100644
--- a/db/models/fieldseeker.stormdrain.bob.go
+++ b/db/models/fieldseeker.stormdrain.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.timecard.bob.go b/db/models/fieldseeker.timecard.bob.go
index d5571f34..8b7b1805 100644
--- a/db/models/fieldseeker.timecard.bob.go
+++ b/db/models/fieldseeker.timecard.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.trapdata.bob.go b/db/models/fieldseeker.trapdata.bob.go
index e23fa62d..f6fe3f01 100644
--- a/db/models/fieldseeker.trapdata.bob.go
+++ b/db/models/fieldseeker.trapdata.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.traplocation.bob.go b/db/models/fieldseeker.traplocation.bob.go
index ae0123ef..a3e56cda 100644
--- a/db/models/fieldseeker.traplocation.bob.go
+++ b/db/models/fieldseeker.traplocation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.treatment.bob.go b/db/models/fieldseeker.treatment.bob.go
index f4129dbd..d219c571 100644
--- a/db/models/fieldseeker.treatment.bob.go
+++ b/db/models/fieldseeker.treatment.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.treatmentarea.bob.go b/db/models/fieldseeker.treatmentarea.bob.go
index 507f947c..6e1ffcb8 100644
--- a/db/models/fieldseeker.treatmentarea.bob.go
+++ b/db/models/fieldseeker.treatmentarea.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.zones.bob.go b/db/models/fieldseeker.zones.bob.go
index c6b8695b..e5e9f7b4 100644
--- a/db/models/fieldseeker.zones.bob.go
+++ b/db/models/fieldseeker.zones.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker.zones2.bob.go b/db/models/fieldseeker.zones2.bob.go
index 93c6badb..02e3a743 100644
--- a/db/models/fieldseeker.zones2.bob.go
+++ b/db/models/fieldseeker.zones2.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/fieldseeker_sync.bob.go b/db/models/fieldseeker_sync.bob.go
index b2a8ea0e..fcf5e738 100644
--- a/db/models/fieldseeker_sync.bob.go
+++ b/db/models/fieldseeker_sync.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/geography_columns.bob.go b/db/models/geography_columns.bob.go
index 4e1b1c04..c1452873 100644
--- a/db/models/geography_columns.bob.go
+++ b/db/models/geography_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/geometry_columns.bob.go b/db/models/geometry_columns.bob.go
index 9b93f543..5d875b78 100644
--- a/db/models/geometry_columns.bob.go
+++ b/db/models/geometry_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/goose_db_version.bob.go b/db/models/goose_db_version.bob.go
index d65bd269..19519e27 100644
--- a/db/models/goose_db_version.bob.go
+++ b/db/models/goose_db_version.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/h3_aggregation.bob.go b/db/models/h3_aggregation.bob.go
index 476bdba1..7e09d5c5 100644
--- a/db/models/h3_aggregation.bob.go
+++ b/db/models/h3_aggregation.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/note_audio.bob.go b/db/models/note_audio.bob.go
index b491baed..204cb229 100644
--- a/db/models/note_audio.bob.go
+++ b/db/models/note_audio.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -39,6 +39,8 @@ type NoteAudio struct {
UUID uuid.UUID `db:"uuid,pk" `
R noteAudioR `db:"-" `
+
+ C noteAudioC `db:"-" `
}
// NoteAudioSlice is an alias for a slice of pointers to NoteAudio.
@@ -1487,6 +1489,162 @@ func (os NoteAudioSlice) LoadNoteAudioData(ctx context.Context, exec bob.Executo
return nil
}
+// noteAudioC is where relationship counts are stored.
+type noteAudioC struct {
+ NoteAudioBreadcrumbs *int64
+ NoteAudioData *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *NoteAudio) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "NoteAudioBreadcrumbs":
+ o.C.NoteAudioBreadcrumbs = &count
+ case "NoteAudioData":
+ o.C.NoteAudioData = &count
+ }
+ return nil
+}
+
+type noteAudioCountPreloader struct {
+ NoteAudioBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ NoteAudioData func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildNoteAudioCountPreloader() noteAudioCountPreloader {
+ return noteAudioCountPreloader{
+ NoteAudioBreadcrumbs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*NoteAudio]("NoteAudioBreadcrumbs", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = NoteAudios.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteAudioBreadcrumbs.Name()),
+ sm.Where(psql.Quote(NoteAudioBreadcrumbs.Alias(), "note_audio_version").EQ(psql.Quote(parent, "version"))),
+ sm.Where(psql.Quote(NoteAudioBreadcrumbs.Alias(), "note_audio_uuid").EQ(psql.Quote(parent, "uuid"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ NoteAudioData: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*NoteAudio]("NoteAudioData", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = NoteAudios.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteAudioData.Name()),
+ sm.Where(psql.Quote(NoteAudioData.Alias(), "note_audio_version").EQ(psql.Quote(parent, "version"))),
+ sm.Where(psql.Quote(NoteAudioData.Alias(), "note_audio_uuid").EQ(psql.Quote(parent, "uuid"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type noteAudioCountThenLoader[Q orm.Loadable] struct {
+ NoteAudioBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteAudioData func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildNoteAudioCountThenLoader[Q orm.Loadable]() noteAudioCountThenLoader[Q] {
+ type NoteAudioBreadcrumbsCountInterface interface {
+ LoadCountNoteAudioBreadcrumbs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type NoteAudioDataCountInterface interface {
+ LoadCountNoteAudioData(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return noteAudioCountThenLoader[Q]{
+ NoteAudioBreadcrumbs: countThenLoadBuilder[Q](
+ "NoteAudioBreadcrumbs",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteAudioBreadcrumbsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteAudioBreadcrumbs(ctx, exec, mods...)
+ },
+ ),
+ NoteAudioData: countThenLoadBuilder[Q](
+ "NoteAudioData",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteAudioDataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteAudioData(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountNoteAudioBreadcrumbs loads the count of NoteAudioBreadcrumbs into the C struct
+func (o *NoteAudio) LoadCountNoteAudioBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteAudioBreadcrumbs(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteAudioBreadcrumbs = &count
+ return nil
+}
+
+// LoadCountNoteAudioBreadcrumbs loads the count of NoteAudioBreadcrumbs for a slice
+func (os NoteAudioSlice) LoadCountNoteAudioBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteAudioBreadcrumbs(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountNoteAudioData loads the count of NoteAudioData into the C struct
+func (o *NoteAudio) LoadCountNoteAudioData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteAudioData(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteAudioData = &count
+ return nil
+}
+
+// LoadCountNoteAudioData loads the count of NoteAudioData for a slice
+func (os NoteAudioSlice) LoadCountNoteAudioData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteAudioData(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type noteAudioJoins[Q dialect.Joinable] struct {
typ string
CreatorUser modAs[Q, userColumns]
diff --git a/db/models/note_audio_breadcrumb.bob.go b/db/models/note_audio_breadcrumb.bob.go
index 5dd41d5b..67165c53 100644
--- a/db/models/note_audio_breadcrumb.bob.go
+++ b/db/models/note_audio_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/note_audio_data.bob.go b/db/models/note_audio_data.bob.go
index b4a9ec78..89dd6055 100644
--- a/db/models/note_audio_data.bob.go
+++ b/db/models/note_audio_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/note_image.bob.go b/db/models/note_image.bob.go
index 071a1ace..34e4edd2 100644
--- a/db/models/note_image.bob.go
+++ b/db/models/note_image.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -36,6 +36,8 @@ type NoteImage struct {
UUID uuid.UUID `db:"uuid,pk" `
R noteImageR `db:"-" `
+
+ C noteImageC `db:"-" `
}
// NoteImageSlice is an alias for a slice of pointers to NoteImage.
@@ -1412,6 +1414,162 @@ func (os NoteImageSlice) LoadNoteImageData(ctx context.Context, exec bob.Executo
return nil
}
+// noteImageC is where relationship counts are stored.
+type noteImageC struct {
+ NoteImageBreadcrumbs *int64
+ NoteImageData *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *NoteImage) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "NoteImageBreadcrumbs":
+ o.C.NoteImageBreadcrumbs = &count
+ case "NoteImageData":
+ o.C.NoteImageData = &count
+ }
+ return nil
+}
+
+type noteImageCountPreloader struct {
+ NoteImageBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ NoteImageData func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildNoteImageCountPreloader() noteImageCountPreloader {
+ return noteImageCountPreloader{
+ NoteImageBreadcrumbs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*NoteImage]("NoteImageBreadcrumbs", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = NoteImages.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteImageBreadcrumbs.Name()),
+ sm.Where(psql.Quote(NoteImageBreadcrumbs.Alias(), "note_image_version").EQ(psql.Quote(parent, "version"))),
+ sm.Where(psql.Quote(NoteImageBreadcrumbs.Alias(), "note_image_uuid").EQ(psql.Quote(parent, "uuid"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ NoteImageData: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*NoteImage]("NoteImageData", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = NoteImages.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteImageData.Name()),
+ sm.Where(psql.Quote(NoteImageData.Alias(), "note_image_version").EQ(psql.Quote(parent, "version"))),
+ sm.Where(psql.Quote(NoteImageData.Alias(), "note_image_uuid").EQ(psql.Quote(parent, "uuid"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type noteImageCountThenLoader[Q orm.Loadable] struct {
+ NoteImageBreadcrumbs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteImageData func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildNoteImageCountThenLoader[Q orm.Loadable]() noteImageCountThenLoader[Q] {
+ type NoteImageBreadcrumbsCountInterface interface {
+ LoadCountNoteImageBreadcrumbs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type NoteImageDataCountInterface interface {
+ LoadCountNoteImageData(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return noteImageCountThenLoader[Q]{
+ NoteImageBreadcrumbs: countThenLoadBuilder[Q](
+ "NoteImageBreadcrumbs",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteImageBreadcrumbsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteImageBreadcrumbs(ctx, exec, mods...)
+ },
+ ),
+ NoteImageData: countThenLoadBuilder[Q](
+ "NoteImageData",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteImageDataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteImageData(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountNoteImageBreadcrumbs loads the count of NoteImageBreadcrumbs into the C struct
+func (o *NoteImage) LoadCountNoteImageBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteImageBreadcrumbs(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteImageBreadcrumbs = &count
+ return nil
+}
+
+// LoadCountNoteImageBreadcrumbs loads the count of NoteImageBreadcrumbs for a slice
+func (os NoteImageSlice) LoadCountNoteImageBreadcrumbs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteImageBreadcrumbs(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountNoteImageData loads the count of NoteImageData into the C struct
+func (o *NoteImage) LoadCountNoteImageData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteImageData(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteImageData = &count
+ return nil
+}
+
+// LoadCountNoteImageData loads the count of NoteImageData for a slice
+func (os NoteImageSlice) LoadCountNoteImageData(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteImageData(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type noteImageJoins[Q dialect.Joinable] struct {
typ string
CreatorUser modAs[Q, userColumns]
diff --git a/db/models/note_image_breadcrumb.bob.go b/db/models/note_image_breadcrumb.bob.go
index eee5ba78..be232187 100644
--- a/db/models/note_image_breadcrumb.bob.go
+++ b/db/models/note_image_breadcrumb.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/note_image_data.bob.go b/db/models/note_image_data.bob.go
index 7adfe9b2..2eb3f729 100644
--- a/db/models/note_image_data.bob.go
+++ b/db/models/note_image_data.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/notification.bob.go b/db/models/notification.bob.go
index 5456125b..ee150774 100644
--- a/db/models/notification.bob.go
+++ b/db/models/notification.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/oauth_token.bob.go b/db/models/oauth_token.bob.go
index cd7ff27d..9b8c7156 100644
--- a/db/models/oauth_token.bob.go
+++ b/db/models/oauth_token.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go
index f9bfcc28..256a8f90 100644
--- a/db/models/organization.bob.go
+++ b/db/models/organization.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -32,6 +32,8 @@ type Organization struct {
FieldseekerURL null.Val[string] `db:"fieldseeker_url" `
R organizationR `db:"-" `
+
+ C organizationC `db:"-" `
}
// OrganizationSlice is an alias for a slice of pointers to Organization.
@@ -6182,6 +6184,1990 @@ func (os OrganizationSlice) LoadUser(ctx context.Context, exec bob.Executor, mod
return nil
}
+// organizationC is where relationship counts are stored.
+type organizationC struct {
+ Containerrelates *int64
+ Fieldscoutinglogs *int64
+ Habitatrelates *int64
+ Inspectionsamples *int64
+ Inspectionsampledetails *int64
+ Linelocations *int64
+ Locationtrackings *int64
+ Mosquitoinspections *int64
+ Pointlocations *int64
+ Polygonlocations *int64
+ Pools *int64
+ Pooldetails *int64
+ Proposedtreatmentareas *int64
+ Qamosquitoinspections *int64
+ Rodentlocations *int64
+ Samplecollections *int64
+ Samplelocations *int64
+ Servicerequests *int64
+ Speciesabundances *int64
+ Stormdrains *int64
+ Timecards *int64
+ Trapdata *int64
+ Traplocations *int64
+ Treatments *int64
+ Treatmentareas *int64
+ Zones *int64
+ Zones2s *int64
+ FieldseekerSyncs *int64
+ H3Aggregations *int64
+ NoteAudios *int64
+ NoteImages *int64
+ User *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *Organization) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "Containerrelates":
+ o.C.Containerrelates = &count
+ case "Fieldscoutinglogs":
+ o.C.Fieldscoutinglogs = &count
+ case "Habitatrelates":
+ o.C.Habitatrelates = &count
+ case "Inspectionsamples":
+ o.C.Inspectionsamples = &count
+ case "Inspectionsampledetails":
+ o.C.Inspectionsampledetails = &count
+ case "Linelocations":
+ o.C.Linelocations = &count
+ case "Locationtrackings":
+ o.C.Locationtrackings = &count
+ case "Mosquitoinspections":
+ o.C.Mosquitoinspections = &count
+ case "Pointlocations":
+ o.C.Pointlocations = &count
+ case "Polygonlocations":
+ o.C.Polygonlocations = &count
+ case "Pools":
+ o.C.Pools = &count
+ case "Pooldetails":
+ o.C.Pooldetails = &count
+ case "Proposedtreatmentareas":
+ o.C.Proposedtreatmentareas = &count
+ case "Qamosquitoinspections":
+ o.C.Qamosquitoinspections = &count
+ case "Rodentlocations":
+ o.C.Rodentlocations = &count
+ case "Samplecollections":
+ o.C.Samplecollections = &count
+ case "Samplelocations":
+ o.C.Samplelocations = &count
+ case "Servicerequests":
+ o.C.Servicerequests = &count
+ case "Speciesabundances":
+ o.C.Speciesabundances = &count
+ case "Stormdrains":
+ o.C.Stormdrains = &count
+ case "Timecards":
+ o.C.Timecards = &count
+ case "Trapdata":
+ o.C.Trapdata = &count
+ case "Traplocations":
+ o.C.Traplocations = &count
+ case "Treatments":
+ o.C.Treatments = &count
+ case "Treatmentareas":
+ o.C.Treatmentareas = &count
+ case "Zones":
+ o.C.Zones = &count
+ case "Zones2s":
+ o.C.Zones2s = &count
+ case "FieldseekerSyncs":
+ o.C.FieldseekerSyncs = &count
+ case "H3Aggregations":
+ o.C.H3Aggregations = &count
+ case "NoteAudios":
+ o.C.NoteAudios = &count
+ case "NoteImages":
+ o.C.NoteImages = &count
+ case "User":
+ o.C.User = &count
+ }
+ return nil
+}
+
+type organizationCountPreloader struct {
+ Containerrelates func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Linelocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Pointlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Pools func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Pooldetails func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Samplecollections func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Samplelocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Servicerequests func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Stormdrains func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Timecards func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Trapdata func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Traplocations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Treatments func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Zones func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Zones2s func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ NoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ NoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ User func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildOrganizationCountPreloader() organizationCountPreloader {
+ return organizationCountPreloader{
+ Containerrelates: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Containerrelates", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerContainerrelates.Name()),
+ sm.Where(psql.Quote(FieldseekerContainerrelates.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Fieldscoutinglogs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Fieldscoutinglogs", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerFieldscoutinglogs.Name()),
+ sm.Where(psql.Quote(FieldseekerFieldscoutinglogs.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Habitatrelates: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Habitatrelates", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerHabitatrelates.Name()),
+ sm.Where(psql.Quote(FieldseekerHabitatrelates.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Inspectionsamples: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Inspectionsamples", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerInspectionsamples.Name()),
+ sm.Where(psql.Quote(FieldseekerInspectionsamples.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Inspectionsampledetails: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Inspectionsampledetails", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerInspectionsampledetails.Name()),
+ sm.Where(psql.Quote(FieldseekerInspectionsampledetails.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Linelocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Linelocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerLinelocations.Name()),
+ sm.Where(psql.Quote(FieldseekerLinelocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Locationtrackings: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Locationtrackings", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerLocationtrackings.Name()),
+ sm.Where(psql.Quote(FieldseekerLocationtrackings.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Mosquitoinspections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Mosquitoinspections", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerMosquitoinspections.Name()),
+ sm.Where(psql.Quote(FieldseekerMosquitoinspections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Pointlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Pointlocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerPointlocations.Name()),
+ sm.Where(psql.Quote(FieldseekerPointlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Polygonlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Polygonlocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerPolygonlocations.Name()),
+ sm.Where(psql.Quote(FieldseekerPolygonlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Pools: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Pools", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerPools.Name()),
+ sm.Where(psql.Quote(FieldseekerPools.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Pooldetails: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Pooldetails", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerPooldetails.Name()),
+ sm.Where(psql.Quote(FieldseekerPooldetails.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Proposedtreatmentareas: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Proposedtreatmentareas", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerProposedtreatmentareas.Name()),
+ sm.Where(psql.Quote(FieldseekerProposedtreatmentareas.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Qamosquitoinspections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Qamosquitoinspections", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerQamosquitoinspections.Name()),
+ sm.Where(psql.Quote(FieldseekerQamosquitoinspections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Rodentlocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Rodentlocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerRodentlocations.Name()),
+ sm.Where(psql.Quote(FieldseekerRodentlocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Samplecollections: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Samplecollections", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerSamplecollections.Name()),
+ sm.Where(psql.Quote(FieldseekerSamplecollections.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Samplelocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Samplelocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerSamplelocations.Name()),
+ sm.Where(psql.Quote(FieldseekerSamplelocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Servicerequests: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Servicerequests", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerServicerequests.Name()),
+ sm.Where(psql.Quote(FieldseekerServicerequests.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Speciesabundances: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Speciesabundances", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerSpeciesabundances.Name()),
+ sm.Where(psql.Quote(FieldseekerSpeciesabundances.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Stormdrains: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Stormdrains", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerStormdrains.Name()),
+ sm.Where(psql.Quote(FieldseekerStormdrains.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Timecards: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Timecards", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerTimecards.Name()),
+ sm.Where(psql.Quote(FieldseekerTimecards.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Trapdata: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Trapdata", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerTrapdata.Name()),
+ sm.Where(psql.Quote(FieldseekerTrapdata.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Traplocations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Traplocations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerTraplocations.Name()),
+ sm.Where(psql.Quote(FieldseekerTraplocations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Treatments: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Treatments", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerTreatments.Name()),
+ sm.Where(psql.Quote(FieldseekerTreatments.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Treatmentareas: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Treatmentareas", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerTreatmentareas.Name()),
+ sm.Where(psql.Quote(FieldseekerTreatmentareas.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Zones: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Zones", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerZones.Name()),
+ sm.Where(psql.Quote(FieldseekerZones.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Zones2s: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("Zones2s", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerZones2s.Name()),
+ sm.Where(psql.Quote(FieldseekerZones2s.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ FieldseekerSyncs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("FieldseekerSyncs", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(FieldseekerSyncs.Name()),
+ sm.Where(psql.Quote(FieldseekerSyncs.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ H3Aggregations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("H3Aggregations", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(H3Aggregations.Name()),
+ sm.Where(psql.Quote(H3Aggregations.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ NoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("NoteAudios", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteAudios.Name()),
+ sm.Where(psql.Quote(NoteAudios.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ NoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("NoteImages", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteImages.Name()),
+ sm.Where(psql.Quote(NoteImages.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ User: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*Organization]("User", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Organizations.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(Users.Name()),
+ sm.Where(psql.Quote(Users.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type organizationCountThenLoader[Q orm.Loadable] struct {
+ Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildOrganizationCountThenLoader[Q orm.Loadable]() organizationCountThenLoader[Q] {
+ type ContainerrelatesCountInterface interface {
+ LoadCountContainerrelates(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type FieldscoutinglogsCountInterface interface {
+ LoadCountFieldscoutinglogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type HabitatrelatesCountInterface interface {
+ LoadCountHabitatrelates(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type InspectionsamplesCountInterface interface {
+ LoadCountInspectionsamples(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type InspectionsampledetailsCountInterface interface {
+ LoadCountInspectionsampledetails(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type LinelocationsCountInterface interface {
+ LoadCountLinelocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type LocationtrackingsCountInterface interface {
+ LoadCountLocationtrackings(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type MosquitoinspectionsCountInterface interface {
+ LoadCountMosquitoinspections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PointlocationsCountInterface interface {
+ LoadCountPointlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PolygonlocationsCountInterface interface {
+ LoadCountPolygonlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PoolsCountInterface interface {
+ LoadCountPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PooldetailsCountInterface interface {
+ LoadCountPooldetails(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type ProposedtreatmentareasCountInterface interface {
+ LoadCountProposedtreatmentareas(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type QamosquitoinspectionsCountInterface interface {
+ LoadCountQamosquitoinspections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type RodentlocationsCountInterface interface {
+ LoadCountRodentlocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type SamplecollectionsCountInterface interface {
+ LoadCountSamplecollections(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type SamplelocationsCountInterface interface {
+ LoadCountSamplelocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type ServicerequestsCountInterface interface {
+ LoadCountServicerequests(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type SpeciesabundancesCountInterface interface {
+ LoadCountSpeciesabundances(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type StormdrainsCountInterface interface {
+ LoadCountStormdrains(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type TimecardsCountInterface interface {
+ LoadCountTimecards(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type TrapdataCountInterface interface {
+ LoadCountTrapdata(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type TraplocationsCountInterface interface {
+ LoadCountTraplocations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type TreatmentsCountInterface interface {
+ LoadCountTreatments(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type TreatmentareasCountInterface interface {
+ LoadCountTreatmentareas(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type ZonesCountInterface interface {
+ LoadCountZones(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type Zones2sCountInterface interface {
+ LoadCountZones2s(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type FieldseekerSyncsCountInterface interface {
+ LoadCountFieldseekerSyncs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type H3AggregationsCountInterface interface {
+ LoadCountH3Aggregations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type NoteAudiosCountInterface interface {
+ LoadCountNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type NoteImagesCountInterface interface {
+ LoadCountNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type UserCountInterface interface {
+ LoadCountUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return organizationCountThenLoader[Q]{
+ Containerrelates: countThenLoadBuilder[Q](
+ "Containerrelates",
+ func(ctx context.Context, exec bob.Executor, retrieved ContainerrelatesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountContainerrelates(ctx, exec, mods...)
+ },
+ ),
+ Fieldscoutinglogs: countThenLoadBuilder[Q](
+ "Fieldscoutinglogs",
+ func(ctx context.Context, exec bob.Executor, retrieved FieldscoutinglogsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountFieldscoutinglogs(ctx, exec, mods...)
+ },
+ ),
+ Habitatrelates: countThenLoadBuilder[Q](
+ "Habitatrelates",
+ func(ctx context.Context, exec bob.Executor, retrieved HabitatrelatesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountHabitatrelates(ctx, exec, mods...)
+ },
+ ),
+ Inspectionsamples: countThenLoadBuilder[Q](
+ "Inspectionsamples",
+ func(ctx context.Context, exec bob.Executor, retrieved InspectionsamplesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountInspectionsamples(ctx, exec, mods...)
+ },
+ ),
+ Inspectionsampledetails: countThenLoadBuilder[Q](
+ "Inspectionsampledetails",
+ func(ctx context.Context, exec bob.Executor, retrieved InspectionsampledetailsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountInspectionsampledetails(ctx, exec, mods...)
+ },
+ ),
+ Linelocations: countThenLoadBuilder[Q](
+ "Linelocations",
+ func(ctx context.Context, exec bob.Executor, retrieved LinelocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountLinelocations(ctx, exec, mods...)
+ },
+ ),
+ Locationtrackings: countThenLoadBuilder[Q](
+ "Locationtrackings",
+ func(ctx context.Context, exec bob.Executor, retrieved LocationtrackingsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountLocationtrackings(ctx, exec, mods...)
+ },
+ ),
+ Mosquitoinspections: countThenLoadBuilder[Q](
+ "Mosquitoinspections",
+ func(ctx context.Context, exec bob.Executor, retrieved MosquitoinspectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountMosquitoinspections(ctx, exec, mods...)
+ },
+ ),
+ Pointlocations: countThenLoadBuilder[Q](
+ "Pointlocations",
+ func(ctx context.Context, exec bob.Executor, retrieved PointlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPointlocations(ctx, exec, mods...)
+ },
+ ),
+ Polygonlocations: countThenLoadBuilder[Q](
+ "Polygonlocations",
+ func(ctx context.Context, exec bob.Executor, retrieved PolygonlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPolygonlocations(ctx, exec, mods...)
+ },
+ ),
+ Pools: countThenLoadBuilder[Q](
+ "Pools",
+ func(ctx context.Context, exec bob.Executor, retrieved PoolsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPools(ctx, exec, mods...)
+ },
+ ),
+ Pooldetails: countThenLoadBuilder[Q](
+ "Pooldetails",
+ func(ctx context.Context, exec bob.Executor, retrieved PooldetailsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPooldetails(ctx, exec, mods...)
+ },
+ ),
+ Proposedtreatmentareas: countThenLoadBuilder[Q](
+ "Proposedtreatmentareas",
+ func(ctx context.Context, exec bob.Executor, retrieved ProposedtreatmentareasCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountProposedtreatmentareas(ctx, exec, mods...)
+ },
+ ),
+ Qamosquitoinspections: countThenLoadBuilder[Q](
+ "Qamosquitoinspections",
+ func(ctx context.Context, exec bob.Executor, retrieved QamosquitoinspectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountQamosquitoinspections(ctx, exec, mods...)
+ },
+ ),
+ Rodentlocations: countThenLoadBuilder[Q](
+ "Rodentlocations",
+ func(ctx context.Context, exec bob.Executor, retrieved RodentlocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountRodentlocations(ctx, exec, mods...)
+ },
+ ),
+ Samplecollections: countThenLoadBuilder[Q](
+ "Samplecollections",
+ func(ctx context.Context, exec bob.Executor, retrieved SamplecollectionsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountSamplecollections(ctx, exec, mods...)
+ },
+ ),
+ Samplelocations: countThenLoadBuilder[Q](
+ "Samplelocations",
+ func(ctx context.Context, exec bob.Executor, retrieved SamplelocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountSamplelocations(ctx, exec, mods...)
+ },
+ ),
+ Servicerequests: countThenLoadBuilder[Q](
+ "Servicerequests",
+ func(ctx context.Context, exec bob.Executor, retrieved ServicerequestsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountServicerequests(ctx, exec, mods...)
+ },
+ ),
+ Speciesabundances: countThenLoadBuilder[Q](
+ "Speciesabundances",
+ func(ctx context.Context, exec bob.Executor, retrieved SpeciesabundancesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountSpeciesabundances(ctx, exec, mods...)
+ },
+ ),
+ Stormdrains: countThenLoadBuilder[Q](
+ "Stormdrains",
+ func(ctx context.Context, exec bob.Executor, retrieved StormdrainsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountStormdrains(ctx, exec, mods...)
+ },
+ ),
+ Timecards: countThenLoadBuilder[Q](
+ "Timecards",
+ func(ctx context.Context, exec bob.Executor, retrieved TimecardsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountTimecards(ctx, exec, mods...)
+ },
+ ),
+ Trapdata: countThenLoadBuilder[Q](
+ "Trapdata",
+ func(ctx context.Context, exec bob.Executor, retrieved TrapdataCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountTrapdata(ctx, exec, mods...)
+ },
+ ),
+ Traplocations: countThenLoadBuilder[Q](
+ "Traplocations",
+ func(ctx context.Context, exec bob.Executor, retrieved TraplocationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountTraplocations(ctx, exec, mods...)
+ },
+ ),
+ Treatments: countThenLoadBuilder[Q](
+ "Treatments",
+ func(ctx context.Context, exec bob.Executor, retrieved TreatmentsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountTreatments(ctx, exec, mods...)
+ },
+ ),
+ Treatmentareas: countThenLoadBuilder[Q](
+ "Treatmentareas",
+ func(ctx context.Context, exec bob.Executor, retrieved TreatmentareasCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountTreatmentareas(ctx, exec, mods...)
+ },
+ ),
+ Zones: countThenLoadBuilder[Q](
+ "Zones",
+ func(ctx context.Context, exec bob.Executor, retrieved ZonesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountZones(ctx, exec, mods...)
+ },
+ ),
+ Zones2s: countThenLoadBuilder[Q](
+ "Zones2s",
+ func(ctx context.Context, exec bob.Executor, retrieved Zones2sCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountZones2s(ctx, exec, mods...)
+ },
+ ),
+ FieldseekerSyncs: countThenLoadBuilder[Q](
+ "FieldseekerSyncs",
+ func(ctx context.Context, exec bob.Executor, retrieved FieldseekerSyncsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountFieldseekerSyncs(ctx, exec, mods...)
+ },
+ ),
+ H3Aggregations: countThenLoadBuilder[Q](
+ "H3Aggregations",
+ func(ctx context.Context, exec bob.Executor, retrieved H3AggregationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountH3Aggregations(ctx, exec, mods...)
+ },
+ ),
+ NoteAudios: countThenLoadBuilder[Q](
+ "NoteAudios",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteAudios(ctx, exec, mods...)
+ },
+ ),
+ NoteImages: countThenLoadBuilder[Q](
+ "NoteImages",
+ func(ctx context.Context, exec bob.Executor, retrieved NoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountNoteImages(ctx, exec, mods...)
+ },
+ ),
+ User: countThenLoadBuilder[Q](
+ "User",
+ func(ctx context.Context, exec bob.Executor, retrieved UserCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountUser(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountContainerrelates loads the count of Containerrelates into the C struct
+func (o *Organization) LoadCountContainerrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Containerrelates(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Containerrelates = &count
+ return nil
+}
+
+// LoadCountContainerrelates loads the count of Containerrelates for a slice
+func (os OrganizationSlice) LoadCountContainerrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountContainerrelates(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountFieldscoutinglogs loads the count of Fieldscoutinglogs into the C struct
+func (o *Organization) LoadCountFieldscoutinglogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Fieldscoutinglogs(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Fieldscoutinglogs = &count
+ return nil
+}
+
+// LoadCountFieldscoutinglogs loads the count of Fieldscoutinglogs for a slice
+func (os OrganizationSlice) LoadCountFieldscoutinglogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountFieldscoutinglogs(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountHabitatrelates loads the count of Habitatrelates into the C struct
+func (o *Organization) LoadCountHabitatrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Habitatrelates(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Habitatrelates = &count
+ return nil
+}
+
+// LoadCountHabitatrelates loads the count of Habitatrelates for a slice
+func (os OrganizationSlice) LoadCountHabitatrelates(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountHabitatrelates(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountInspectionsamples loads the count of Inspectionsamples into the C struct
+func (o *Organization) LoadCountInspectionsamples(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Inspectionsamples(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Inspectionsamples = &count
+ return nil
+}
+
+// LoadCountInspectionsamples loads the count of Inspectionsamples for a slice
+func (os OrganizationSlice) LoadCountInspectionsamples(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountInspectionsamples(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountInspectionsampledetails loads the count of Inspectionsampledetails into the C struct
+func (o *Organization) LoadCountInspectionsampledetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Inspectionsampledetails(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Inspectionsampledetails = &count
+ return nil
+}
+
+// LoadCountInspectionsampledetails loads the count of Inspectionsampledetails for a slice
+func (os OrganizationSlice) LoadCountInspectionsampledetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountInspectionsampledetails(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountLinelocations loads the count of Linelocations into the C struct
+func (o *Organization) LoadCountLinelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Linelocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Linelocations = &count
+ return nil
+}
+
+// LoadCountLinelocations loads the count of Linelocations for a slice
+func (os OrganizationSlice) LoadCountLinelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountLinelocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountLocationtrackings loads the count of Locationtrackings into the C struct
+func (o *Organization) LoadCountLocationtrackings(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Locationtrackings(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Locationtrackings = &count
+ return nil
+}
+
+// LoadCountLocationtrackings loads the count of Locationtrackings for a slice
+func (os OrganizationSlice) LoadCountLocationtrackings(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountLocationtrackings(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountMosquitoinspections loads the count of Mosquitoinspections into the C struct
+func (o *Organization) LoadCountMosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Mosquitoinspections(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Mosquitoinspections = &count
+ return nil
+}
+
+// LoadCountMosquitoinspections loads the count of Mosquitoinspections for a slice
+func (os OrganizationSlice) LoadCountMosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountMosquitoinspections(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountPointlocations loads the count of Pointlocations into the C struct
+func (o *Organization) LoadCountPointlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Pointlocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Pointlocations = &count
+ return nil
+}
+
+// LoadCountPointlocations loads the count of Pointlocations for a slice
+func (os OrganizationSlice) LoadCountPointlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPointlocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountPolygonlocations loads the count of Polygonlocations into the C struct
+func (o *Organization) LoadCountPolygonlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Polygonlocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Polygonlocations = &count
+ return nil
+}
+
+// LoadCountPolygonlocations loads the count of Polygonlocations for a slice
+func (os OrganizationSlice) LoadCountPolygonlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPolygonlocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountPools loads the count of Pools into the C struct
+func (o *Organization) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Pools(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Pools = &count
+ return nil
+}
+
+// LoadCountPools loads the count of Pools for a slice
+func (os OrganizationSlice) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPools(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountPooldetails loads the count of Pooldetails into the C struct
+func (o *Organization) LoadCountPooldetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Pooldetails(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Pooldetails = &count
+ return nil
+}
+
+// LoadCountPooldetails loads the count of Pooldetails for a slice
+func (os OrganizationSlice) LoadCountPooldetails(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPooldetails(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountProposedtreatmentareas loads the count of Proposedtreatmentareas into the C struct
+func (o *Organization) LoadCountProposedtreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Proposedtreatmentareas(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Proposedtreatmentareas = &count
+ return nil
+}
+
+// LoadCountProposedtreatmentareas loads the count of Proposedtreatmentareas for a slice
+func (os OrganizationSlice) LoadCountProposedtreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountProposedtreatmentareas(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountQamosquitoinspections loads the count of Qamosquitoinspections into the C struct
+func (o *Organization) LoadCountQamosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Qamosquitoinspections(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Qamosquitoinspections = &count
+ return nil
+}
+
+// LoadCountQamosquitoinspections loads the count of Qamosquitoinspections for a slice
+func (os OrganizationSlice) LoadCountQamosquitoinspections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountQamosquitoinspections(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountRodentlocations loads the count of Rodentlocations into the C struct
+func (o *Organization) LoadCountRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Rodentlocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Rodentlocations = &count
+ return nil
+}
+
+// LoadCountRodentlocations loads the count of Rodentlocations for a slice
+func (os OrganizationSlice) LoadCountRodentlocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountRodentlocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountSamplecollections loads the count of Samplecollections into the C struct
+func (o *Organization) LoadCountSamplecollections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Samplecollections(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Samplecollections = &count
+ return nil
+}
+
+// LoadCountSamplecollections loads the count of Samplecollections for a slice
+func (os OrganizationSlice) LoadCountSamplecollections(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountSamplecollections(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountSamplelocations loads the count of Samplelocations into the C struct
+func (o *Organization) LoadCountSamplelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Samplelocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Samplelocations = &count
+ return nil
+}
+
+// LoadCountSamplelocations loads the count of Samplelocations for a slice
+func (os OrganizationSlice) LoadCountSamplelocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountSamplelocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountServicerequests loads the count of Servicerequests into the C struct
+func (o *Organization) LoadCountServicerequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Servicerequests(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Servicerequests = &count
+ return nil
+}
+
+// LoadCountServicerequests loads the count of Servicerequests for a slice
+func (os OrganizationSlice) LoadCountServicerequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountServicerequests(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountSpeciesabundances loads the count of Speciesabundances into the C struct
+func (o *Organization) LoadCountSpeciesabundances(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Speciesabundances(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Speciesabundances = &count
+ return nil
+}
+
+// LoadCountSpeciesabundances loads the count of Speciesabundances for a slice
+func (os OrganizationSlice) LoadCountSpeciesabundances(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountSpeciesabundances(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountStormdrains loads the count of Stormdrains into the C struct
+func (o *Organization) LoadCountStormdrains(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Stormdrains(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Stormdrains = &count
+ return nil
+}
+
+// LoadCountStormdrains loads the count of Stormdrains for a slice
+func (os OrganizationSlice) LoadCountStormdrains(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountStormdrains(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountTimecards loads the count of Timecards into the C struct
+func (o *Organization) LoadCountTimecards(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Timecards(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Timecards = &count
+ return nil
+}
+
+// LoadCountTimecards loads the count of Timecards for a slice
+func (os OrganizationSlice) LoadCountTimecards(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountTimecards(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountTrapdata loads the count of Trapdata into the C struct
+func (o *Organization) LoadCountTrapdata(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Trapdata(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Trapdata = &count
+ return nil
+}
+
+// LoadCountTrapdata loads the count of Trapdata for a slice
+func (os OrganizationSlice) LoadCountTrapdata(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountTrapdata(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountTraplocations loads the count of Traplocations into the C struct
+func (o *Organization) LoadCountTraplocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Traplocations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Traplocations = &count
+ return nil
+}
+
+// LoadCountTraplocations loads the count of Traplocations for a slice
+func (os OrganizationSlice) LoadCountTraplocations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountTraplocations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountTreatments loads the count of Treatments into the C struct
+func (o *Organization) LoadCountTreatments(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Treatments(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Treatments = &count
+ return nil
+}
+
+// LoadCountTreatments loads the count of Treatments for a slice
+func (os OrganizationSlice) LoadCountTreatments(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountTreatments(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountTreatmentareas loads the count of Treatmentareas into the C struct
+func (o *Organization) LoadCountTreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Treatmentareas(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Treatmentareas = &count
+ return nil
+}
+
+// LoadCountTreatmentareas loads the count of Treatmentareas for a slice
+func (os OrganizationSlice) LoadCountTreatmentareas(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountTreatmentareas(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountZones loads the count of Zones into the C struct
+func (o *Organization) LoadCountZones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Zones(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Zones = &count
+ return nil
+}
+
+// LoadCountZones loads the count of Zones for a slice
+func (os OrganizationSlice) LoadCountZones(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountZones(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountZones2s loads the count of Zones2s into the C struct
+func (o *Organization) LoadCountZones2s(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Zones2s(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Zones2s = &count
+ return nil
+}
+
+// LoadCountZones2s loads the count of Zones2s for a slice
+func (os OrganizationSlice) LoadCountZones2s(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountZones2s(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountFieldseekerSyncs loads the count of FieldseekerSyncs into the C struct
+func (o *Organization) LoadCountFieldseekerSyncs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.FieldseekerSyncs(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.FieldseekerSyncs = &count
+ return nil
+}
+
+// LoadCountFieldseekerSyncs loads the count of FieldseekerSyncs for a slice
+func (os OrganizationSlice) LoadCountFieldseekerSyncs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountFieldseekerSyncs(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountH3Aggregations loads the count of H3Aggregations into the C struct
+func (o *Organization) LoadCountH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.H3Aggregations(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.H3Aggregations = &count
+ return nil
+}
+
+// LoadCountH3Aggregations loads the count of H3Aggregations for a slice
+func (os OrganizationSlice) LoadCountH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountH3Aggregations(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountNoteAudios loads the count of NoteAudios into the C struct
+func (o *Organization) LoadCountNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteAudios(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteAudios = &count
+ return nil
+}
+
+// LoadCountNoteAudios loads the count of NoteAudios for a slice
+func (os OrganizationSlice) LoadCountNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteAudios(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountNoteImages loads the count of NoteImages into the C struct
+func (o *Organization) LoadCountNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.NoteImages(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.NoteImages = &count
+ return nil
+}
+
+// LoadCountNoteImages loads the count of NoteImages for a slice
+func (os OrganizationSlice) LoadCountNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountNoteImages(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountUser loads the count of User into the C struct
+func (o *Organization) LoadCountUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.User(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.User = &count
+ return nil
+}
+
+// LoadCountUser loads the count of User for a slice
+func (os OrganizationSlice) LoadCountUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountUser(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type organizationJoins[Q dialect.Joinable] struct {
typ string
Containerrelates modAs[Q, fieldseekerContainerrelateColumns]
diff --git a/db/models/publicreport.nuisance.bob.go b/db/models/publicreport.nuisance.bob.go
index 78ce3f54..031d4bf0 100644
--- a/db/models/publicreport.nuisance.bob.go
+++ b/db/models/publicreport.nuisance.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/publicreport.pool.bob.go b/db/models/publicreport.pool.bob.go
index 805c0576..350af417 100644
--- a/db/models/publicreport.pool.bob.go
+++ b/db/models/publicreport.pool.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -59,6 +59,8 @@ type PublicreportPool struct {
Status enums.PublicreportReportstatustype `db:"status" `
R publicreportPoolR `db:"-" `
+
+ C publicreportPoolC `db:"-" `
}
// PublicreportPoolSlice is an alias for a slice of pointers to PublicreportPool.
@@ -1291,6 +1293,99 @@ func (os PublicreportPoolSlice) LoadPoolPhotos(ctx context.Context, exec bob.Exe
return nil
}
+// publicreportPoolC is where relationship counts are stored.
+type publicreportPoolC struct {
+ PoolPhotos *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *PublicreportPool) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "PoolPhotos":
+ o.C.PoolPhotos = &count
+ }
+ return nil
+}
+
+type publicreportPoolCountPreloader struct {
+ PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader {
+ return publicreportPoolCountPreloader{
+ PoolPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportPool]("PoolPhotos", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = PublicreportPools.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(PublicreportPoolPhotos.Name()),
+ sm.Where(psql.Quote(PublicreportPoolPhotos.Alias(), "pool_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type publicreportPoolCountThenLoader[Q orm.Loadable] struct {
+ PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportPoolCountThenLoader[Q orm.Loadable]() publicreportPoolCountThenLoader[Q] {
+ type PoolPhotosCountInterface interface {
+ LoadCountPoolPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportPoolCountThenLoader[Q]{
+ PoolPhotos: countThenLoadBuilder[Q](
+ "PoolPhotos",
+ func(ctx context.Context, exec bob.Executor, retrieved PoolPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPoolPhotos(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountPoolPhotos loads the count of PoolPhotos into the C struct
+func (o *PublicreportPool) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.PoolPhotos(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.PoolPhotos = &count
+ return nil
+}
+
+// LoadCountPoolPhotos loads the count of PoolPhotos for a slice
+func (os PublicreportPoolSlice) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPoolPhotos(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type publicreportPoolJoins[Q dialect.Joinable] struct {
typ string
PoolPhotos modAs[Q, publicreportPoolPhotoColumns]
diff --git a/db/models/publicreport.pool_photo.bob.go b/db/models/publicreport.pool_photo.bob.go
index 11a67efb..1240a0e3 100644
--- a/db/models/publicreport.pool_photo.bob.go
+++ b/db/models/publicreport.pool_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/publicreport.quick.bob.go b/db/models/publicreport.quick.bob.go
index 1a97365f..5cec372c 100644
--- a/db/models/publicreport.quick.bob.go
+++ b/db/models/publicreport.quick.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -39,6 +39,8 @@ type PublicreportQuick struct {
Status enums.PublicreportReportstatustype `db:"status" `
R publicreportQuickR `db:"-" `
+
+ C publicreportQuickC `db:"-" `
}
// PublicreportQuickSlice is an alias for a slice of pointers to PublicreportQuick.
@@ -791,6 +793,99 @@ func (os PublicreportQuickSlice) LoadQuickPhotos(ctx context.Context, exec bob.E
return nil
}
+// publicreportQuickC is where relationship counts are stored.
+type publicreportQuickC struct {
+ QuickPhotos *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *PublicreportQuick) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "QuickPhotos":
+ o.C.QuickPhotos = &count
+ }
+ return nil
+}
+
+type publicreportQuickCountPreloader struct {
+ QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildPublicreportQuickCountPreloader() publicreportQuickCountPreloader {
+ return publicreportQuickCountPreloader{
+ QuickPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportQuick]("QuickPhotos", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = PublicreportQuicks.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(PublicreportQuickPhotos.Name()),
+ sm.Where(psql.Quote(PublicreportQuickPhotos.Alias(), "quick_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type publicreportQuickCountThenLoader[Q orm.Loadable] struct {
+ QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportQuickCountThenLoader[Q orm.Loadable]() publicreportQuickCountThenLoader[Q] {
+ type QuickPhotosCountInterface interface {
+ LoadCountQuickPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportQuickCountThenLoader[Q]{
+ QuickPhotos: countThenLoadBuilder[Q](
+ "QuickPhotos",
+ func(ctx context.Context, exec bob.Executor, retrieved QuickPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountQuickPhotos(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountQuickPhotos loads the count of QuickPhotos into the C struct
+func (o *PublicreportQuick) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.QuickPhotos(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.QuickPhotos = &count
+ return nil
+}
+
+// LoadCountQuickPhotos loads the count of QuickPhotos for a slice
+func (os PublicreportQuickSlice) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountQuickPhotos(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type publicreportQuickJoins[Q dialect.Joinable] struct {
typ string
QuickPhotos modAs[Q, publicreportQuickPhotoColumns]
diff --git a/db/models/publicreport.quick_photo.bob.go b/db/models/publicreport.quick_photo.bob.go
index 0dc99964..9f5171d4 100644
--- a/db/models/publicreport.quick_photo.bob.go
+++ b/db/models/publicreport.quick_photo.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/publicreport.report_location.bob.go b/db/models/publicreport.report_location.bob.go
index 7882ba24..1bbb46e9 100644
--- a/db/models/publicreport.report_location.bob.go
+++ b/db/models/publicreport.report_location.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/raster_columns.bob.go b/db/models/raster_columns.bob.go
index f53ea1e0..a97fc1cb 100644
--- a/db/models/raster_columns.bob.go
+++ b/db/models/raster_columns.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/raster_overviews.bob.go b/db/models/raster_overviews.bob.go
index b21dcf47..bc5115b3 100644
--- a/db/models/raster_overviews.bob.go
+++ b/db/models/raster_overviews.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/sessions.bob.go b/db/models/sessions.bob.go
index 7e0d3f29..4899065f 100644
--- a/db/models/sessions.bob.go
+++ b/db/models/sessions.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/spatial_ref_sys.bob.go b/db/models/spatial_ref_sys.bob.go
index 20b5bfcb..651d4ad9 100644
--- a/db/models/spatial_ref_sys.bob.go
+++ b/db/models/spatial_ref_sys.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
diff --git a/db/models/user_.bob.go b/db/models/user_.bob.go
index 7063a0e8..2b8e80c2 100644
--- a/db/models/user_.bob.go
+++ b/db/models/user_.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
@@ -41,6 +41,8 @@ type User struct {
PasswordHash string `db:"password_hash" `
R userR `db:"-" `
+
+ C userC `db:"-" `
}
// UserSlice is an alias for a slice of pointers to User.
@@ -55,6 +57,7 @@ type UsersQuery = *psql.ViewQuery[*User, UserSlice]
// userR is where relationships are stored.
type userR struct {
+ PublicUserUser ArcgisUserSlice // arcgis.user_.user__public_user_id_fkey
CreatorNoteAudios NoteAudioSlice // note_audio.note_audio_creator_id_fkey
DeletorNoteAudios NoteAudioSlice // note_audio.note_audio_deletor_id_fkey
CreatorNoteImages NoteImageSlice // note_image.note_image_creator_id_fkey
@@ -608,6 +611,30 @@ func (o UserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
return nil
}
+// PublicUserUser starts a query for related objects on arcgis.user_
+func (o *User) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery {
+ return ArcgisUsers.Query(append(mods,
+ sm.Where(ArcgisUsers.Columns.PublicUserID.EQ(psql.Arg(o.ID))),
+ )...)
+}
+
+func (os UserSlice) PublicUserUser(mods ...bob.Mod[*dialect.SelectQuery]) ArcgisUsersQuery {
+ pkID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkID = append(pkID, o.ID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
+ ))
+
+ return ArcgisUsers.Query(append(mods,
+ sm.Where(psql.Group(ArcgisUsers.Columns.PublicUserID).OP("IN", PKArgExpr)),
+ )...)
+}
+
// CreatorNoteAudios starts a query for related objects on note_audio
func (o *User) CreatorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery {
return NoteAudios.Query(append(mods,
@@ -776,6 +803,74 @@ func (os UserSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) Organiza
)...)
}
+func insertUserPublicUserUser0(ctx context.Context, exec bob.Executor, arcgisusers1 []*ArcgisUserSetter, user0 *User) (ArcgisUserSlice, error) {
+ for i := range arcgisusers1 {
+ arcgisusers1[i].PublicUserID = omit.From(user0.ID)
+ }
+
+ ret, err := ArcgisUsers.Insert(bob.ToMods(arcgisusers1...)).All(ctx, exec)
+ if err != nil {
+ return ret, fmt.Errorf("insertUserPublicUserUser0: %w", err)
+ }
+
+ return ret, nil
+}
+
+func attachUserPublicUserUser0(ctx context.Context, exec bob.Executor, count int, arcgisusers1 ArcgisUserSlice, user0 *User) (ArcgisUserSlice, error) {
+ setter := &ArcgisUserSetter{
+ PublicUserID: omit.From(user0.ID),
+ }
+
+ err := arcgisusers1.UpdateAll(ctx, exec, *setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachUserPublicUserUser0: %w", err)
+ }
+
+ return arcgisusers1, nil
+}
+
+func (user0 *User) InsertPublicUserUser(ctx context.Context, exec bob.Executor, related ...*ArcgisUserSetter) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+
+ arcgisusers1, err := insertUserPublicUserUser0(ctx, exec, related, user0)
+ if err != nil {
+ return err
+ }
+
+ user0.R.PublicUserUser = append(user0.R.PublicUserUser, arcgisusers1...)
+
+ for _, rel := range arcgisusers1 {
+ rel.R.PublicUserUser = user0
+ }
+ return nil
+}
+
+func (user0 *User) AttachPublicUserUser(ctx context.Context, exec bob.Executor, related ...*ArcgisUser) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+ arcgisusers1 := ArcgisUserSlice(related)
+
+ _, err = attachUserPublicUserUser0(ctx, exec, len(related), arcgisusers1, user0)
+ if err != nil {
+ return err
+ }
+
+ user0.R.PublicUserUser = append(user0.R.PublicUserUser, arcgisusers1...)
+
+ for _, rel := range related {
+ rel.R.PublicUserUser = user0
+ }
+
+ return nil
+}
+
func insertUserCreatorNoteAudios0(ctx context.Context, exec bob.Executor, noteAudios1 []*NoteAudioSetter, user0 *User) (NoteAudioSlice, error) {
for i := range noteAudios1 {
noteAudios1[i].CreatorID = omit.From(user0.ID)
@@ -1274,6 +1369,20 @@ func (o *User) Preload(name string, retrieved any) error {
}
switch name {
+ case "PublicUserUser":
+ rels, ok := retrieved.(ArcgisUserSlice)
+ if !ok {
+ return fmt.Errorf("user cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.PublicUserUser = rels
+
+ for _, rel := range rels {
+ if rel != nil {
+ rel.R.PublicUserUser = o
+ }
+ }
+ return nil
case "CreatorNoteAudios":
rels, ok := retrieved.(NoteAudioSlice)
if !ok {
@@ -1398,6 +1507,7 @@ func buildUserPreloader() userPreloader {
}
type userThenLoader[Q orm.Loadable] struct {
+ PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
@@ -1408,6 +1518,9 @@ type userThenLoader[Q orm.Loadable] struct {
}
func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
+ type PublicUserUserLoadInterface interface {
+ LoadPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
type CreatorNoteAudiosLoadInterface interface {
LoadCreatorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
@@ -1431,6 +1544,12 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
}
return userThenLoader[Q]{
+ PublicUserUser: thenLoadBuilder[Q](
+ "PublicUserUser",
+ func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadPublicUserUser(ctx, exec, mods...)
+ },
+ ),
CreatorNoteAudios: thenLoadBuilder[Q](
"CreatorNoteAudios",
func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteAudiosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
@@ -1476,6 +1595,67 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
}
}
+// LoadPublicUserUser loads the user's PublicUserUser into the .R struct
+func (o *User) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.PublicUserUser = nil
+
+ related, err := o.PublicUserUser(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, rel := range related {
+ rel.R.PublicUserUser = o
+ }
+
+ o.R.PublicUserUser = related
+ return nil
+}
+
+// LoadPublicUserUser loads the user's PublicUserUser into the .R struct
+func (os UserSlice) LoadPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ arcgisusers, err := os.PublicUserUser(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ o.R.PublicUserUser = nil
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range arcgisusers {
+
+ if !(o.ID == rel.PublicUserID) {
+ continue
+ }
+
+ rel.R.PublicUserUser = o
+
+ o.R.PublicUserUser = append(o.R.PublicUserUser, rel)
+ }
+ }
+
+ return nil
+}
+
// LoadCreatorNoteAudios loads the user's CreatorNoteAudios into the .R struct
func (o *User) LoadCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
@@ -1900,8 +2080,468 @@ func (os UserSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mod
return nil
}
+// userC is where relationship counts are stored.
+type userC struct {
+ PublicUserUser *int64
+ CreatorNoteAudios *int64
+ DeletorNoteAudios *int64
+ CreatorNoteImages *int64
+ DeletorNoteImages *int64
+ UserNotifications *int64
+ UserOauthTokens *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *User) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "PublicUserUser":
+ o.C.PublicUserUser = &count
+ case "CreatorNoteAudios":
+ o.C.CreatorNoteAudios = &count
+ case "DeletorNoteAudios":
+ o.C.DeletorNoteAudios = &count
+ case "CreatorNoteImages":
+ o.C.CreatorNoteImages = &count
+ case "DeletorNoteImages":
+ o.C.DeletorNoteImages = &count
+ case "UserNotifications":
+ o.C.UserNotifications = &count
+ case "UserOauthTokens":
+ o.C.UserOauthTokens = &count
+ }
+ return nil
+}
+
+type userCountPreloader struct {
+ PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ UserNotifications func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ UserOauthTokens func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildUserCountPreloader() userCountPreloader {
+ return userCountPreloader{
+ PublicUserUser: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("PublicUserUser", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(ArcgisUsers.Name()),
+ sm.Where(psql.Quote(ArcgisUsers.Alias(), "public_user_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ CreatorNoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("CreatorNoteAudios", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteAudios.Name()),
+ sm.Where(psql.Quote(NoteAudios.Alias(), "creator_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ DeletorNoteAudios: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("DeletorNoteAudios", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteAudios.Name()),
+ sm.Where(psql.Quote(NoteAudios.Alias(), "deletor_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ CreatorNoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("CreatorNoteImages", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteImages.Name()),
+ sm.Where(psql.Quote(NoteImages.Alias(), "creator_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ DeletorNoteImages: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("DeletorNoteImages", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(NoteImages.Name()),
+ sm.Where(psql.Quote(NoteImages.Alias(), "deletor_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ UserNotifications: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("UserNotifications", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(Notifications.Name()),
+ sm.Where(psql.Quote(Notifications.Alias(), "user_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ UserOauthTokens: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*User]("UserOauthTokens", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = Users.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(OauthTokens.Name()),
+ sm.Where(psql.Quote(OauthTokens.Alias(), "user_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type userCountThenLoader[Q orm.Loadable] struct {
+ PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ UserNotifications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ UserOauthTokens func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildUserCountThenLoader[Q orm.Loadable]() userCountThenLoader[Q] {
+ type PublicUserUserCountInterface interface {
+ LoadCountPublicUserUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type CreatorNoteAudiosCountInterface interface {
+ LoadCountCreatorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type DeletorNoteAudiosCountInterface interface {
+ LoadCountDeletorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type CreatorNoteImagesCountInterface interface {
+ LoadCountCreatorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type DeletorNoteImagesCountInterface interface {
+ LoadCountDeletorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type UserNotificationsCountInterface interface {
+ LoadCountUserNotifications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type UserOauthTokensCountInterface interface {
+ LoadCountUserOauthTokens(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return userCountThenLoader[Q]{
+ PublicUserUser: countThenLoadBuilder[Q](
+ "PublicUserUser",
+ func(ctx context.Context, exec bob.Executor, retrieved PublicUserUserCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPublicUserUser(ctx, exec, mods...)
+ },
+ ),
+ CreatorNoteAudios: countThenLoadBuilder[Q](
+ "CreatorNoteAudios",
+ func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountCreatorNoteAudios(ctx, exec, mods...)
+ },
+ ),
+ DeletorNoteAudios: countThenLoadBuilder[Q](
+ "DeletorNoteAudios",
+ func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteAudiosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountDeletorNoteAudios(ctx, exec, mods...)
+ },
+ ),
+ CreatorNoteImages: countThenLoadBuilder[Q](
+ "CreatorNoteImages",
+ func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountCreatorNoteImages(ctx, exec, mods...)
+ },
+ ),
+ DeletorNoteImages: countThenLoadBuilder[Q](
+ "DeletorNoteImages",
+ func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountDeletorNoteImages(ctx, exec, mods...)
+ },
+ ),
+ UserNotifications: countThenLoadBuilder[Q](
+ "UserNotifications",
+ func(ctx context.Context, exec bob.Executor, retrieved UserNotificationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountUserNotifications(ctx, exec, mods...)
+ },
+ ),
+ UserOauthTokens: countThenLoadBuilder[Q](
+ "UserOauthTokens",
+ func(ctx context.Context, exec bob.Executor, retrieved UserOauthTokensCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountUserOauthTokens(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountPublicUserUser loads the count of PublicUserUser into the C struct
+func (o *User) LoadCountPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.PublicUserUser(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.PublicUserUser = &count
+ return nil
+}
+
+// LoadCountPublicUserUser loads the count of PublicUserUser for a slice
+func (os UserSlice) LoadCountPublicUserUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPublicUserUser(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountCreatorNoteAudios loads the count of CreatorNoteAudios into the C struct
+func (o *User) LoadCountCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.CreatorNoteAudios(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.CreatorNoteAudios = &count
+ return nil
+}
+
+// LoadCountCreatorNoteAudios loads the count of CreatorNoteAudios for a slice
+func (os UserSlice) LoadCountCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountCreatorNoteAudios(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountDeletorNoteAudios loads the count of DeletorNoteAudios into the C struct
+func (o *User) LoadCountDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.DeletorNoteAudios(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.DeletorNoteAudios = &count
+ return nil
+}
+
+// LoadCountDeletorNoteAudios loads the count of DeletorNoteAudios for a slice
+func (os UserSlice) LoadCountDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountDeletorNoteAudios(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountCreatorNoteImages loads the count of CreatorNoteImages into the C struct
+func (o *User) LoadCountCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.CreatorNoteImages(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.CreatorNoteImages = &count
+ return nil
+}
+
+// LoadCountCreatorNoteImages loads the count of CreatorNoteImages for a slice
+func (os UserSlice) LoadCountCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountCreatorNoteImages(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountDeletorNoteImages loads the count of DeletorNoteImages into the C struct
+func (o *User) LoadCountDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.DeletorNoteImages(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.DeletorNoteImages = &count
+ return nil
+}
+
+// LoadCountDeletorNoteImages loads the count of DeletorNoteImages for a slice
+func (os UserSlice) LoadCountDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountDeletorNoteImages(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountUserNotifications loads the count of UserNotifications into the C struct
+func (o *User) LoadCountUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.UserNotifications(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.UserNotifications = &count
+ return nil
+}
+
+// LoadCountUserNotifications loads the count of UserNotifications for a slice
+func (os UserSlice) LoadCountUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountUserNotifications(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountUserOauthTokens loads the count of UserOauthTokens into the C struct
+func (o *User) LoadCountUserOauthTokens(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.UserOauthTokens(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.UserOauthTokens = &count
+ return nil
+}
+
+// LoadCountUserOauthTokens loads the count of UserOauthTokens for a slice
+func (os UserSlice) LoadCountUserOauthTokens(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountUserOauthTokens(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
type userJoins[Q dialect.Joinable] struct {
typ string
+ PublicUserUser modAs[Q, arcgisuserColumns]
CreatorNoteAudios modAs[Q, noteAudioColumns]
DeletorNoteAudios modAs[Q, noteAudioColumns]
CreatorNoteImages modAs[Q, noteImageColumns]
@@ -1918,6 +2558,20 @@ func (j userJoins[Q]) aliasedAs(alias string) userJoins[Q] {
func buildUserJoins[Q dialect.Joinable](cols userColumns, typ string) userJoins[Q] {
return userJoins[Q]{
typ: typ,
+ PublicUserUser: modAs[Q, arcgisuserColumns]{
+ c: ArcgisUsers.Columns,
+ f: func(to arcgisuserColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, ArcgisUsers.Name().As(to.Alias())).On(
+ to.PublicUserID.EQ(cols.ID),
+ ))
+ }
+
+ return mods
+ },
+ },
CreatorNoteAudios: modAs[Q, noteAudioColumns]{
c: NoteAudios.Columns,
f: func(to noteAudioColumns) bob.Mod[Q] {
diff --git a/db/sql/oauth_by_user_id.bob.go b/db/sql/oauth_by_user_id.bob.go
deleted file mode 100644
index f2b6eb5d..00000000
--- a/db/sql/oauth_by_user_id.bob.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package sql
-
-import (
- "context"
- _ "embed"
- "io"
- "iter"
- "time"
-
- "github.com/aarondl/opt/null"
- "github.com/stephenafamo/bob"
- "github.com/stephenafamo/bob/dialect/psql"
- "github.com/stephenafamo/bob/dialect/psql/dialect"
- "github.com/stephenafamo/bob/orm"
- "github.com/stephenafamo/scan"
-)
-
-//go:embed oauth_by_user_id.bob.sql
-var formattedQueries_oauth_by_user_id string
-
-var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[191:729]
-
-type OauthTokenByUserIdQuery = orm.ModQuery[*dialect.SelectQuery, oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer]
-
-func OauthTokenByUserId(UserID int32) *OauthTokenByUserIdQuery {
- var expressionTypArgs oauthTokenByUserId
-
- expressionTypArgs.UserID = psql.Arg(UserID)
-
- return &OauthTokenByUserIdQuery{
- Query: orm.Query[oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer]{
- ExecQuery: orm.ExecQuery[oauthTokenByUserId]{
- BaseQuery: bob.BaseQuery[oauthTokenByUserId]{
- Expression: expressionTypArgs,
- Dialect: dialect.Dialect,
- QueryType: bob.QueryTypeSelect,
- },
- },
- Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (OauthTokenByUserIdRow, error)) {
- return func(row *scan.Row) (any, error) {
- var t OauthTokenByUserIdRow
- row.ScheduleScanByIndex(0, &t.ID)
- row.ScheduleScanByIndex(1, &t.AccessToken)
- row.ScheduleScanByIndex(2, &t.AccessTokenExpires)
- row.ScheduleScanByIndex(3, &t.RefreshToken)
- row.ScheduleScanByIndex(4, &t.Username)
- row.ScheduleScanByIndex(5, &t.UserID)
- row.ScheduleScanByIndex(6, &t.ArcgisID)
- row.ScheduleScanByIndex(7, &t.ArcgisLicenseTypeID)
- row.ScheduleScanByIndex(8, &t.RefreshTokenExpires)
- row.ScheduleScanByIndex(9, &t.InvalidatedAt)
- return &t, nil
- }, func(v any) (OauthTokenByUserIdRow, error) {
- return *(v.(*OauthTokenByUserIdRow)), nil
- }
- },
- },
- Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
- q.AppendSelect(expressionTypArgs.subExpr(7, 501))
- q.SetTable(expressionTypArgs.subExpr(507, 518))
- q.AppendWhere(expressionTypArgs.subExpr(526, 538))
- }),
- }
-}
-
-type OauthTokenByUserIdRow = struct {
- ID int32 `db:"id"`
- AccessToken string `db:"access_token"`
- AccessTokenExpires time.Time `db:"access_token_expires"`
- RefreshToken string `db:"refresh_token"`
- Username string `db:"username"`
- UserID int32 `db:"user_id"`
- ArcgisID null.Val[string] `db:"arcgis_id"`
- ArcgisLicenseTypeID null.Val[string] `db:"arcgis_license_type_id"`
- RefreshTokenExpires time.Time `db:"refresh_token_expires"`
- InvalidatedAt null.Val[time.Time] `db:"invalidated_at"`
-}
-
-type oauthTokenByUserIdTransformer = bob.SliceTransformer[OauthTokenByUserIdRow, []OauthTokenByUserIdRow]
-
-type oauthTokenByUserId struct {
- UserID bob.Expression
-}
-
-func (o oauthTokenByUserId) args() iter.Seq[orm.ArgWithPosition] {
- return func(yield func(arg orm.ArgWithPosition) bool) {
- if !yield(orm.ArgWithPosition{
- Name: "userID",
- Start: 536,
- Stop: 538,
- Expression: o.UserID,
- }) {
- return
- }
- }
-}
-
-func (o oauthTokenByUserId) raw(from, to int) string {
- return oauthTokenByUserIdSQL[from:to]
-}
-
-func (o oauthTokenByUserId) subExpr(from, to int) bob.Expression {
- return orm.ArgsToExpression(oauthTokenByUserIdSQL, from, to, o.args())
-}
-
-func (o oauthTokenByUserId) WriteSQL(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- return o.subExpr(0, len(oauthTokenByUserIdSQL)).WriteSQL(ctx, w, d, start)
-}
diff --git a/db/sql/oauth_by_user_id.bob.sql b/db/sql/oauth_by_user_id.bob.sql
deleted file mode 100644
index ff32b8e7..00000000
--- a/db/sql/oauth_by_user_id.bob.sql
+++ /dev/null
@@ -1,6 +0,0 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
--- This file is meant to be re-generated in place and/or deleted at any time.
-
--- OauthTokenByUserId
-SELECT "oauth_token"."id" AS "id", "oauth_token"."access_token" AS "access_token", "oauth_token"."access_token_expires" AS "access_token_expires", "oauth_token"."refresh_token" AS "refresh_token", "oauth_token"."username" AS "username", "oauth_token"."user_id" AS "user_id", "oauth_token"."arcgis_id" AS "arcgis_id", "oauth_token"."arcgis_license_type_id" AS "arcgis_license_type_id", "oauth_token"."refresh_token_expires" AS "refresh_token_expires", "oauth_token"."invalidated_at" AS "invalidated_at" FROM oauth_token WHERE
- user_id = $1;
diff --git a/db/sql/oauth_by_user_id.sql b/db/sql/oauth_by_user_id.sql
deleted file mode 100644
index 40a297b2..00000000
--- a/db/sql/oauth_by_user_id.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- OauthTokenByUserId
-SELECT * FROM oauth_token WHERE
- user_id = $1;
diff --git a/db/sql/org_by_oauth_id.bob.go b/db/sql/org_by_oauth_id.bob.go
index 690b6ab9..f9b35ccd 100644
--- a/db/sql/org_by_oauth_id.bob.go
+++ b/db/sql/org_by_oauth_id.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -20,7 +20,7 @@ import (
//go:embed org_by_oauth_id.bob.sql
var formattedQueries_org_by_oauth_id string
-var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[185:398]
+var orgByOauthIdSQL = formattedQueries_org_by_oauth_id[150:363]
type OrgByOauthIdQuery = orm.ModQuery[*dialect.SelectQuery, orgByOauthId, OrgByOauthIdRow, []OrgByOauthIdRow, orgByOauthIdTransformer]
diff --git a/db/sql/org_by_oauth_id.bob.sql b/db/sql/org_by_oauth_id.bob.sql
index c7be4696..f0945529 100644
--- a/db/sql/org_by_oauth_id.bob.sql
+++ b/db/sql/org_by_oauth_id.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- OrgByOauthId
diff --git a/db/sql/publicreport_publicid_table.bob.go b/db/sql/publicreport_publicid_table.bob.go
index 9883cb40..f52b9b42 100644
--- a/db/sql/publicreport_publicid_table.bob.go
+++ b/db/sql/publicreport_publicid_table.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -20,7 +20,7 @@ import (
//go:embed publicreport_publicid_table.bob.sql
var formattedQueries_publicreport_publicid_table string
-var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[192:659]
+var publicreportIDTableSQL = formattedQueries_publicreport_publicid_table[157:624]
type PublicreportIDTableQuery = orm.ModQuery[*dialect.SelectQuery, publicreportIDTable, PublicreportIDTableRow, []PublicreportIDTableRow, publicreportIDTableTransformer]
diff --git a/db/sql/publicreport_publicid_table.bob.sql b/db/sql/publicreport_publicid_table.bob.sql
index 8a6381d9..f9e1c4a6 100644
--- a/db/sql/publicreport_publicid_table.bob.sql
+++ b/db/sql/publicreport_publicid_table.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- PublicreportIDTable
diff --git a/db/sql/trapcount_by_location_id.bob.go b/db/sql/trapcount_by_location_id.bob.go
index 70a39347..73475582 100644
--- a/db/sql/trapcount_by_location_id.bob.go
+++ b/db/sql/trapcount_by_location_id.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -23,7 +23,7 @@ import (
//go:embed trapcount_by_location_id.bob.sql
var formattedQueries_trapcount_by_location_id string
-var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[194:644]
+var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[159:609]
type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]
diff --git a/db/sql/trapcount_by_location_id.bob.sql b/db/sql/trapcount_by_location_id.bob.sql
index 385e4c9e..6e76e700 100644
--- a/db/sql/trapcount_by_location_id.bob.sql
+++ b/db/sql/trapcount_by_location_id.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- TrapCountByLocationID
diff --git a/db/sql/trapdata_by_location_id_recent.bob.go b/db/sql/trapdata_by_location_id_recent.bob.go
index 38db78f9..704f722c 100644
--- a/db/sql/trapdata_by_location_id_recent.bob.go
+++ b/db/sql/trapdata_by_location_id_recent.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -22,7 +22,7 @@ import (
//go:embed trapdata_by_location_id_recent.bob.sql
var formattedQueries_trapdata_by_location_id_recent string
-var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[199:498]
+var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[164:463]
type TrapDataByLocationIDRecentQuery = orm.ModQuery[*dialect.SelectQuery, trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer]
diff --git a/db/sql/trapdata_by_location_id_recent.bob.sql b/db/sql/trapdata_by_location_id_recent.bob.sql
index c3326b69..917e2ee6 100644
--- a/db/sql/trapdata_by_location_id_recent.bob.sql
+++ b/db/sql/trapdata_by_location_id_recent.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- TrapDataByLocationIDRecent
diff --git a/db/sql/traplocation_by_source_id.bob.go b/db/sql/traplocation_by_source_id.bob.go
index 8f10bb55..d0b437e3 100644
--- a/db/sql/traplocation_by_source_id.bob.go
+++ b/db/sql/traplocation_by_source_id.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -20,7 +20,7 @@ import (
//go:embed traplocation_by_source_id.bob.sql
var formattedQueries_traplocation_by_source_id string
-var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[195:488]
+var trapLocationBySourceIDSQL = formattedQueries_traplocation_by_source_id[160:453]
type TrapLocationBySourceIDQuery = orm.ModQuery[*dialect.SelectQuery, trapLocationBySourceID, TrapLocationBySourceIDRow, []TrapLocationBySourceIDRow, trapLocationBySourceIDTransformer]
@@ -51,11 +51,11 @@ func TrapLocationBySourceID(OrganizationID int32, Globalid uuid.UUID) *TrapLocat
},
},
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
- q.CombinedLimit.SetLimit(psql.Raw("4"))
q.AppendSelect(expressionTypArgs.subExpr(9, 102))
q.SetTable(expressionTypArgs.subExpr(110, 178))
q.AppendWhere(expressionTypArgs.subExpr(187, 232))
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(244, 285))
+ q.CombinedLimit.SetLimit(expressionTypArgs.subExpr(292, 293))
}),
}
}
diff --git a/db/sql/traplocation_by_source_id.bob.sql b/db/sql/traplocation_by_source_id.bob.sql
index 9f788cef..b4610521 100644
--- a/db/sql/traplocation_by_source_id.bob.sql
+++ b/db/sql/traplocation_by_source_id.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- TrapLocationBySourceID
diff --git a/db/sql/update_oauth_org.bob.go b/db/sql/update_oauth_org.bob.go
index 6d8776d5..7bb34302 100644
--- a/db/sql/update_oauth_org.bob.go
+++ b/db/sql/update_oauth_org.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -18,7 +18,7 @@ import (
//go:embed update_oauth_org.bob.sql
var formattedQueries_update_oauth_org string
-var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[192:284]
+var updateOauthTokenOrgSQL = formattedQueries_update_oauth_org[157:249]
type UpdateOauthTokenOrgQuery = orm.ModExecQuery[*dialect.UpdateQuery, updateOauthTokenOrg]
diff --git a/db/sql/update_oauth_org.bob.sql b/db/sql/update_oauth_org.bob.sql
index 080766b8..64bdb6cb 100644
--- a/db/sql/update_oauth_org.bob.sql
+++ b/db/sql/update_oauth_org.bob.sql
@@ -1,4 +1,4 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- UpdateOauthTokenOrg
diff --git a/db/sql/user_by_username.bob.go b/db/sql/user_by_username.bob.go
index e3eef602..4ee9ec2f 100644
--- a/db/sql/user_by_username.bob.go
+++ b/db/sql/user_by_username.bob.go
@@ -1,4 +1,4 @@
-// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
@@ -22,7 +22,7 @@ import (
//go:embed user_by_username.bob.sql
var formattedQueries_user_by_username string
-var userByUsernameSQL = formattedQueries_user_by_username[187:808]
+var userByUsernameSQL = formattedQueries_user_by_username[152:780]
type UserByUsernameQuery = orm.ModQuery[*dialect.SelectQuery, userByUsername, UserByUsernameRow, []UserByUsernameRow, userByUsernameTransformer]
@@ -63,8 +63,8 @@ func UserByUsername(Username string) *UserByUsernameQuery {
},
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
q.AppendSelect(expressionTypArgs.subExpr(7, 551))
- q.SetTable(expressionTypArgs.subExpr(557, 562))
- q.AppendWhere(expressionTypArgs.subExpr(570, 621))
+ q.SetTable(expressionTypArgs.subExpr(557, 569))
+ q.AppendWhere(expressionTypArgs.subExpr(577, 628))
}),
}
}
@@ -94,8 +94,8 @@ func (o userByUsername) args() iter.Seq[orm.ArgWithPosition] {
return func(yield func(arg orm.ArgWithPosition) bool) {
if !yield(orm.ArgWithPosition{
Name: "username",
- Start: 581,
- Stop: 583,
+ Start: 588,
+ Stop: 590,
Expression: o.Username,
}) {
return
diff --git a/db/sql/user_by_username.bob.sql b/db/sql/user_by_username.bob.sql
index 596ef88d..9526a44e 100644
--- a/db/sql/user_by_username.bob.sql
+++ b/db/sql/user_by_username.bob.sql
@@ -1,7 +1,7 @@
--- Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
+-- Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-- This file is meant to be re-generated in place and/or deleted at any time.
-- UserByUsername
-SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash" FROM user_ WHERE
+SELECT "user_"."id" AS "id", "user_"."arcgis_access_token" AS "arcgis_access_token", "user_"."arcgis_license" AS "arcgis_license", "user_"."arcgis_refresh_token" AS "arcgis_refresh_token", "user_"."arcgis_refresh_token_expires" AS "arcgis_refresh_token_expires", "user_"."arcgis_role" AS "arcgis_role", "user_"."display_name" AS "display_name", "user_"."email" AS "email", "user_"."organization_id" AS "organization_id", "user_"."username" AS "username", "user_"."password_hash_type" AS "password_hash_type", "user_"."password_hash" AS "password_hash" FROM public.user_ WHERE
username = $1 AND
password_hash_type = 'bcrypt-14';
diff --git a/db/sql/user_by_username.sql b/db/sql/user_by_username.sql
index 64d96249..6de278cc 100644
--- a/db/sql/user_by_username.sql
+++ b/db/sql/user_by_username.sql
@@ -1,4 +1,4 @@
-- UserByUsername
-SELECT * FROM user_ WHERE
+SELECT * FROM public.user_ WHERE
username = $1 AND
password_hash_type = 'bcrypt-14';
From f50f3892f20b5ae459d07333b69868fdda09b02c Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 19:32:42 +0000
Subject: [PATCH 0037/1453] Switch to trap counts instead of inspections on the
dash
Because we can show those on a map.
---
sync/dash.go | 8 ++++----
sync/template/dashboard.html | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/sync/dash.go b/sync/dash.go
index 227f4b19..66e1f1f6 100644
--- a/sync/dash.go
+++ b/sync/dash.go
@@ -35,7 +35,7 @@ type Config struct {
type ContextDashboard struct {
Config Config
- CountInspections int
+ CountTraps int
CountMosquitoSources int
CountServiceRequests int
Geo template.JS
@@ -202,9 +202,9 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
lastSync = &sync.Created
}
is_syncing := background.IsSyncOngoing(org.ID)
- inspectionCount, err := org.Mosquitoinspections().Count(ctx, db.PGInstance.BobDB)
+ trapCount, err := org.Traplocations().Count(ctx, db.PGInstance.BobDB)
if err != nil {
- respondError(w, "Failed to get inspection count", err, http.StatusInternalServerError)
+ respondError(w, "Failed to get trap count", err, http.StatusInternalServerError)
return
}
sourceCount, err := org.Pointlocations().Count(ctx, db.PGInstance.BobDB)
@@ -240,7 +240,7 @@ func dashboard(ctx context.Context, w http.ResponseWriter, user *models.User) {
Config: Config{
URLTegola: config.URLTegola,
},
- CountInspections: int(inspectionCount),
+ CountTraps: int(trapCount),
CountMosquitoSources: int(sourceCount),
CountServiceRequests: int(serviceCount),
IsSyncOngoing: is_syncing,
diff --git a/sync/template/dashboard.html b/sync/template/dashboard.html
index 1479c335..3cfa0abd 100644
--- a/sync/template/dashboard.html
+++ b/sync/template/dashboard.html
@@ -249,11 +249,11 @@ body {
- Inspections
+ Traps
{{ if .IsSyncOngoing }}
- {{ .CountInspections | bigNumber }}...?
+ {{ .CountTraps | bigNumber }}...?
{{ else }}
- {{ .CountInspections | bigNumber }}
+ {{ .CountTraps | bigNumber }}
{{ end }}
+
+ {{ if gt (len .Traps) 0}}
+
+
+
+
+
+
+ ID
+ Active
+ Comments
+
+
+
+ {{ range .Traps }}
+
+ {{.GlobalID|uuidShort}}
+ {{.Active}}
+ {{.Comments}}
+
+ {{ end }}
+
+
+
+
+
+ {{ else }}
+
No traps
+ {{ end }}
+
diff --git a/sync/types.go b/sync/types.go
index b8435495..a31b3712 100644
--- a/sync/types.go
+++ b/sync/types.go
@@ -28,14 +28,6 @@ type ComponentMap struct {
type ContentAuthenticatedPlaceholder struct {
User User
}
-type ContentCell struct {
- BreedingSources []BreedingSourceSummary
- CellBoundary h3.CellBoundary
- Inspections []Inspection
- MapData ComponentMap
- Treatments []Treatment
- User User
-}
type ContentMockURLs struct {
Dispatch string
DispatchResults string
@@ -95,7 +87,7 @@ type Link struct {
Title string
}
type Organization struct {
- ID int
+ ID int
Name string
}
type ServiceRequestSummary struct {
@@ -104,9 +96,9 @@ type ServiceRequestSummary struct {
Status string
}
type User struct {
- DisplayName string
- Initials string
- Notifications []notification.Notification
- Organization Organization
- Username string
+ DisplayName string
+ Initials string
+ Notifications []notification.Notification
+ Organization Organization
+ Username string
}
diff --git a/sync/utils.go b/sync/utils.go
index 45c0d23b..7cba5560 100644
--- a/sync/utils.go
+++ b/sync/utils.go
@@ -100,11 +100,11 @@ func contentForUser(ctx context.Context, user *models.User) (User, error) {
DisplayName: user.DisplayName,
Initials: extractInitials(user.DisplayName),
Notifications: notifications,
- Organization: Organization {
- ID: int(org.ID),
+ Organization: Organization{
+ ID: int(org.ID),
Name: org.Name,
},
- Username: user.Username,
+ Username: user.Username,
}, nil
}
@@ -181,7 +181,7 @@ func trapsBySource(ctx context.Context, org *models.Organization, sourceID uuid.
return nil, fmt.Errorf("Failed to query trap counts: %w", err)
}
- traps, err := toTemplateTraps(locations, trap_data, counts)
+ traps, err := toTemplateTrapsNearby(locations, trap_data, counts)
if err != nil {
return nil, fmt.Errorf("Failed to convert trap data: %w", err)
}
@@ -203,6 +203,24 @@ func treatmentsBySource(ctx context.Context, org *models.Organization, sourceID
return toTemplateTreatment(rows)
}
+func trapsByCell(ctx context.Context, org *models.Organization, c h3.Cell) (results []Trap, err error) {
+ boundary, err := c.Boundary()
+ if err != nil {
+ return results, fmt.Errorf("Failed to get cell boundary: %w", err)
+ }
+ geom_query := gisStatement(boundary)
+ rows, err := org.Traplocations(
+ sm.Where(
+ psql.F("ST_Within", "geospatial", geom_query),
+ ),
+ sm.OrderBy("objectid"),
+ ).All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return results, fmt.Errorf("Failed to query rows: %w", err)
+ }
+ return toTemplateTrap(rows)
+}
+
func treatmentsByCell(ctx context.Context, org *models.Organization, c h3.Cell) ([]Treatment, error) {
var results []Treatment
boundary, err := c.Boundary()
From e2549f03171d6daf01e226dd29cff12a1d8b1f9e Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 22:12:35 +0000
Subject: [PATCH 0043/1453] Make trap page that shows collection information
---
sync/dash.go | 72 ++++++++++++++++++++-
sync/model_conversion.go | 74 +++++++++++++++++++---
sync/routes.go | 1 +
sync/template/trap.html | 131 +++++++++++++++++++++++++++++++++++++++
sync/types.go | 10 ---
sync/utils.go | 25 +++++++-
6 files changed, 293 insertions(+), 20 deletions(-)
create mode 100644 sync/template/trap.html
diff --git a/sync/dash.go b/sync/dash.go
index 04b464ac..11858361 100644
--- a/sync/dash.go
+++ b/sync/dash.go
@@ -27,18 +27,34 @@ var (
districtT = buildTemplate("district", "base")
settingsT = buildTemplate("settings", "authenticated")
sourceT = buildTemplate("source", "authenticated")
+ trapT = buildTemplate("trap", "authenticated")
)
type Config struct {
URLTegola string
}
+type ContentSource struct {
+ Inspections []Inspection
+ MapData ComponentMap
+ Source *BreedingSourceDetail
+ Traps []TrapNearby
+ Treatments []Treatment
+ //TreatmentCadence TreatmentCadence
+ TreatmentModels []TreatmentModel
+ User User
+}
+type ContentTrap struct {
+ MapData ComponentMap
+ Trap Trap
+ User User
+}
type ContextCell struct {
BreedingSources []BreedingSourceSummary
CellBoundary h3.CellBoundary
Inspections []Inspection
MapData ComponentMap
- Traps []Trap
+ Traps []TrapSummary
Treatments []Treatment
User User
}
@@ -133,6 +149,20 @@ func getSource(w http.ResponseWriter, r *http.Request, u *models.User) {
source(w, r, u, globalid)
}
+func getTrap(w http.ResponseWriter, r *http.Request, u *models.User) {
+ globalid_s := chi.URLParam(r, "globalid")
+ if globalid_s == "" {
+ respondError(w, "No globalid provided", nil, http.StatusBadRequest)
+ return
+ }
+ globalid, err := uuid.Parse(globalid_s)
+ if err != nil {
+ respondError(w, "globalid is not a UUID", nil, http.StatusBadRequest)
+ return
+ }
+ trap(w, r, u, globalid)
+}
+
func cell(ctx context.Context, w http.ResponseWriter, user *models.User, c int64) {
org, err := user.Organization().One(ctx, db.PGInstance.BobDB)
if err != nil {
@@ -342,3 +372,43 @@ func source(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.U
htmlpage.RenderOrError(w, sourceT, data)
}
+
+func trap(w http.ResponseWriter, r *http.Request, user *models.User, id uuid.UUID) {
+ org, err := user.Organization().One(r.Context(), db.PGInstance.BobDB)
+ if err != nil {
+ respondError(w, "Failed to get org", err, http.StatusInternalServerError)
+ return
+ }
+ userContent, err := contentForUser(r.Context(), user)
+ if err != nil {
+ respondError(w, "Failed to get user content", err, http.StatusInternalServerError)
+ return
+ }
+ t, err := trapByGlobalId(r.Context(), org, id)
+ if err != nil {
+ respondError(w, "Failed to get trap", err, http.StatusInternalServerError)
+ return
+ }
+ latlng, err := t.H3Cell.LatLng()
+ if err != nil {
+ respondError(w, "Failed to get latlng", err, http.StatusInternalServerError)
+ return
+ }
+ data := ContentTrap{
+ MapData: ComponentMap{
+ Center: latlng,
+ //GeoJSON:
+ MapboxToken: config.MapboxToken,
+ Markers: []MapMarker{
+ MapMarker{
+ LatLng: latlng,
+ },
+ },
+ Zoom: 13,
+ },
+ Trap: t,
+ User: userContent,
+ }
+
+ htmlpage.RenderOrError(w, trapT, data)
+}
diff --git a/sync/model_conversion.go b/sync/model_conversion.go
index 31156274..9b4fa373 100644
--- a/sync/model_conversion.go
+++ b/sync/model_conversion.go
@@ -76,10 +76,13 @@ type BreedingSourceDetail struct {
Comments string `json:"comments"`
}
-type TrapNearby struct {
- Counts []*TrapCount
- Distance string
- ID uuid.UUID
+type Trap struct {
+ Active bool
+ Comments string
+ Collections []TrapData
+ Description string
+ GlobalID uuid.UUID
+ H3Cell h3.Cell
}
type TrapCount struct {
@@ -152,9 +155,18 @@ type TrapData struct {
LastEditedDate *time.Time `json:"lastEditedDate"`
LastEditedUser string `json:"lastEditedUser"`
Comments string `json:"comments"`
+
+ // Stuff I actually use
+ Count TrapCount
}
-type Trap struct {
+type TrapNearby struct {
+ Counts []*TrapCount
+ Distance string
+ ID uuid.UUID
+}
+
+type TrapSummary struct {
Active bool
Comments string
Description string
@@ -169,9 +181,57 @@ type Treatment struct {
Product string
}
-func toTemplateTrap(traps models.FieldseekerTraplocationSlice) (results []Trap, err error) {
+func toTemplateTrap(trap *models.FieldseekerTraplocation, trap_data []sql.TrapDataByLocationIDRecentRow, count_slice []sql.TrapCountByLocationIDRow) (result Trap, err error) {
+ log.Debug().Str("globalid", trap.Globalid.String()).Msg("Working on trap")
+ cell, err := h3utils.ToCell(trap.H3cell.MustGet())
+ if err != nil {
+ return result, fmt.Errorf("Failed to convert h3 cell: %w", err)
+ }
+
+ count_by_trapdata_id := make(map[uuid.UUID]TrapCount, 0)
+ for _, count := range count_slice {
+ count_by_trapdata_id[count.TrapdataGlobalid] = TrapCount{
+ Ended: count.TrapdataEnddate.MustGet(),
+ Females: int(count.TotalFemales),
+ Males: int(count.TotalMales),
+ Total: int(count.Total),
+ }
+ }
+
+ data_by_id := make(map[uuid.UUID]TrapData, 0)
+ for _, dt := range trap_data {
+ if dt.LocID != trap.Globalid {
+ return result, fmt.Errorf("Bad query")
+ }
+ log.Debug().Str("trapdata", dt.Globalid.String()).Msg("Aggregating trapdata")
+ count, ok := count_by_trapdata_id[dt.Globalid]
+ if !ok {
+ count = TrapCount{}
+ }
+ data_by_id[dt.Globalid] = TrapData{
+ Count: count,
+ EndDateTime: &dt.Enddatetime,
+ GlobalID: dt.Globalid,
+ }
+ }
+ data := make([]TrapData, 0)
+ for _, v := range data_by_id {
+ data = append(data, v)
+ }
+
+ return Trap{
+ Active: toBool16Or(trap.Active, false),
+ Comments: trap.Comments.GetOr(""),
+ Collections: data,
+ Description: trap.Description.GetOr(""),
+ GlobalID: trap.Globalid,
+ H3Cell: cell,
+ }, nil
+}
+
+func toTemplateTrapSummary(traps models.FieldseekerTraplocationSlice) (results []TrapSummary, err error) {
for _, t := range traps {
- results = append(results, Trap{
+ results = append(results, TrapSummary{
Active: toBool16Or(t.Active, false),
Comments: t.Comments.GetOr(""),
Description: t.Description.GetOr(""),
diff --git a/sync/routes.go b/sync/routes.go
index 89cf6444..6fa8ae8d 100644
--- a/sync/routes.go
+++ b/sync/routes.go
@@ -66,6 +66,7 @@ func Router() chi.Router {
r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails))
r.Method("GET", "/settings", auth.NewEnsureAuth(getSettings))
r.Method("GET", "/source/{globalid}", auth.NewEnsureAuth(getSource))
+ r.Method("GET", "/trap/{globalid}", auth.NewEnsureAuth(getTrap))
htmlpage.AddStaticRoute(r, "/static")
return r
diff --git a/sync/template/trap.html b/sync/template/trap.html
new file mode 100644
index 00000000..3f22a94e
--- /dev/null
+++ b/sync/template/trap.html
@@ -0,0 +1,131 @@
+{{template "authenticated.html" .}}
+
+{{define "title"}}Dash{{end}}
+{{define "extraheader"}}
+{{template "map" .MapData}}
+
+{{end}}
+{{define "content"}}
+
+
+
+
+
+
+
+
+
+
Trap ID: {{ .Trap.GlobalID }}
+
+
+ Active:
+ {{ .Trap.Active }}
+
+
+ Comments:
+ {{ .Trap.Comments }}
+
+
+ Description:
+ {{ .Trap.Description }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Collection Date
+ Collection ID
+ Females
+ Male
+ Total
+
+
+
+
+ {{ range .Trap.Collections }}
+
+ {{ .EndDateTime|timeSince }}
+ {{ .GlobalID }}
+ {{ .Count.Females }}
+ {{ .Count.Males }}
+ {{ .Count.Total }}
+
+ {{ end }}
+
+
+
+
+
+
+{{end}}
diff --git a/sync/types.go b/sync/types.go
index a31b3712..8306d280 100644
--- a/sync/types.go
+++ b/sync/types.go
@@ -65,16 +65,6 @@ type ContentSignin struct {
InvalidCredentials bool
}
type ContentSignup struct{}
-type ContentSource struct {
- Inspections []Inspection
- MapData ComponentMap
- Source *BreedingSourceDetail
- Traps []TrapNearby
- Treatments []Treatment
- //TreatmentCadence TreatmentCadence
- TreatmentModels []TreatmentModel
- User User
-}
type Inspection struct {
Action string
Date *time.Time
diff --git a/sync/utils.go b/sync/utils.go
index 7cba5560..94f2dcd7 100644
--- a/sync/utils.go
+++ b/sync/utils.go
@@ -203,7 +203,28 @@ func treatmentsBySource(ctx context.Context, org *models.Organization, sourceID
return toTemplateTreatment(rows)
}
-func trapsByCell(ctx context.Context, org *models.Organization, c h3.Cell) (results []Trap, err error) {
+func trapByGlobalId(ctx context.Context, org *models.Organization, id uuid.UUID) (result Trap, err error) {
+ row, err := org.Traplocations(
+ sm.Where(models.FieldseekerTraplocations.Columns.Globalid.EQ(psql.Arg(id))),
+ ).One(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return result, fmt.Errorf("Failed to get trap location: %w", err)
+ }
+
+ trap_data, err := sql.TrapDataByLocationIDRecent(org.ID, []uuid.UUID{id}).All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return result, fmt.Errorf("Failed to query trap data: %w", err)
+ }
+
+ counts, err := sql.TrapCountByLocationID(org.ID, []uuid.UUID{id}).All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return result, fmt.Errorf("Failed to query trap counts: %w", err)
+ }
+
+ return toTemplateTrap(row, trap_data, counts)
+}
+
+func trapsByCell(ctx context.Context, org *models.Organization, c h3.Cell) (results []TrapSummary, err error) {
boundary, err := c.Boundary()
if err != nil {
return results, fmt.Errorf("Failed to get cell boundary: %w", err)
@@ -218,7 +239,7 @@ func trapsByCell(ctx context.Context, org *models.Organization, c h3.Cell) (resu
if err != nil {
return results, fmt.Errorf("Failed to query rows: %w", err)
}
- return toTemplateTrap(rows)
+ return toTemplateTrapSummary(rows)
}
func treatmentsByCell(ctx context.Context, org *models.Organization, c h3.Cell) ([]Treatment, error) {
From 0bb055b3915499b9335b85fd0db3d0e4f59b1e77 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 22:15:29 +0000
Subject: [PATCH 0044/1453] Allow clicks on cells without sources
---
htmlpage/static/js/map-aggregate.js | 32 ++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/htmlpage/static/js/map-aggregate.js b/htmlpage/static/js/map-aggregate.js
index 11175360..52146995 100644
--- a/htmlpage/static/js/map-aggregate.js
+++ b/htmlpage/static/js/map-aggregate.js
@@ -132,7 +132,7 @@ class MapAggregate extends HTMLElement {
'fill-color': '#0dcaf0'
}
});
- map.addInteraction("tegola-click-interaction", {
+ map.addInteraction("tegola-click-mosquito-source", {
type: "click",
target: { layerId: "mosquito_source" },
handler: (e) => {
@@ -147,6 +147,36 @@ class MapAggregate extends HTMLElement {
}));
}
});
+ map.addInteraction("tegola-click-service-request", {
+ type: "click",
+ target: { layerId: "service_request" },
+ handler: (e) => {
+ const coordinates = e.feature.geometry.coordinates.slice();
+ const properties = e.feature.properties;
+ this.dispatchEvent(new CustomEvent("cell-click", {
+ bubbles: true,
+ composed: true, // Allows event to cross shadow DOM boundary
+ detail: {
+ cell: properties.cell
+ }
+ }));
+ }
+ });
+ map.addInteraction("tegola-click-trap", {
+ type: "click",
+ target: { layerId: "trap" },
+ handler: (e) => {
+ const coordinates = e.feature.geometry.coordinates.slice();
+ const properties = e.feature.properties;
+ this.dispatchEvent(new CustomEvent("cell-click", {
+ bubbles: true,
+ composed: true, // Allows event to cross shadow DOM boundary
+ detail: {
+ cell: properties.cell
+ }
+ }));
+ }
+ });
});
}
From f6b5a1e580fc601f4eff8ba7386e15a702d80cce Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 22:56:32 +0000
Subject: [PATCH 0045/1453] Add API to query district by GPS location
---
api/api.go | 33 +++++++++++++++++++++++++++++++++
api/endpoint.go | 1 +
api/types.go | 8 ++++++++
platform/district.go | 31 +++++++++++++++++++++++++++++++
sync/template/district.html | 13 +++++++++++++
5 files changed, 86 insertions(+)
create mode 100644 platform/district.go
diff --git a/api/api.go b/api/api.go
index aff1bb40..2e0a268c 100644
--- a/api/api.go
+++ b/api/api.go
@@ -78,6 +78,39 @@ func apiAudioContentPost(w http.ResponseWriter, r *http.Request, u *models.User)
w.WriteHeader(http.StatusOK)
}
+func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
+ var latStr, lngStr string
+ err := r.ParseForm()
+ if err != nil {
+ render.Render(w, r, errRender(fmt.Errorf("Failed to parse GET form: %w", err)))
+ return
+ } else {
+ latStr = r.FormValue("lat")
+ lngStr = r.FormValue("lng")
+ }
+ lat, err := strconv.ParseFloat(latStr, 64)
+ if err != nil {
+ render.Render(w, r, errRender(fmt.Errorf("Failed to parse lat as float: %w", err)))
+ return
+ }
+ lng, err := strconv.ParseFloat(lngStr, 64)
+ if err != nil {
+ render.Render(w, r, errRender(fmt.Errorf("Failed to parse lng as float: %w", err)))
+ return
+ }
+ district, err := platform.DistrictForLocation(r.Context(), lng, lat)
+ if err != nil {
+ render.Render(w, r, errRender(fmt.Errorf("Failed to get district: %w", err)))
+ return
+ }
+ d := ResponseDistrict{
+ Agency: district.Agency.GetOr(""),
+ }
+ if err := render.Render(w, r, d); err != nil {
+ render.Render(w, r, errRender(err))
+ }
+}
+
func handleClientIos(w http.ResponseWriter, r *http.Request, u *models.User) {
var sinceStr string
err := r.ParseForm()
diff --git a/api/endpoint.go b/api/endpoint.go
index 6a9a3bbe..fd86109f 100644
--- a/api/endpoint.go
+++ b/api/endpoint.go
@@ -20,6 +20,7 @@ func AddRoutes(r chi.Router) {
r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost))
// Unauthenticated endpoints
+ r.Get("/district", apiGetDistrict)
r.Get("/webhook/fieldseeker", webhookFieldseeker)
r.Post("/webhook/fieldseeker", webhookFieldseeker)
}
diff --git a/api/types.go b/api/types.go
index 9ce61554..b511b456 100644
--- a/api/types.go
+++ b/api/types.go
@@ -62,6 +62,10 @@ type NoteAudioPayload struct {
Version int32 `json:"version"`
}
+type ResponseDistrict struct {
+ Agency string `json:"agency"`
+}
+
type ResponseMosquitoSource struct {
Access string `json:"access"`
Active *bool `json:"active"`
@@ -154,6 +158,10 @@ func NewResponseMosquitoInspections(inspections models.FieldseekerMosquitoinspec
return results
}
+func (rd ResponseDistrict) Render(w http.ResponseWriter, r *http.Request) error {
+ return nil
+}
+
func (rtd ResponseMosquitoSource) Render(w http.ResponseWriter, r *http.Request) error {
return nil
}
diff --git a/platform/district.go b/platform/district.go
new file mode 100644
index 00000000..fd3d76c7
--- /dev/null
+++ b/platform/district.go
@@ -0,0 +1,31 @@
+package platform
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/Gleipnir-Technology/nidus-sync/db"
+ "github.com/Gleipnir-Technology/nidus-sync/db/models"
+
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+)
+
+func DistrictForLocation(ctx context.Context, lng float64, lat float64) (*models.District, error) {
+ rows, err := models.Districts.Query(
+ sm.Where(
+ psql.F("ST_Contains", psql.Raw("geom_4326"), psql.F("ST_SetSRID", psql.F("ST_MakePoint", psql.Arg(lng), psql.Arg(lat)), psql.Arg(4326))),
+ ),
+ ).All(ctx, db.PGInstance.BobDB)
+ if err != nil {
+ return nil, fmt.Errorf("failed to query district: %w", err)
+ }
+ switch len(rows) {
+ case 0:
+ return nil, nil
+ case 1:
+ return rows[0], nil
+ default:
+ return nil, nil
+ }
+}
diff --git a/sync/template/district.html b/sync/template/district.html
index a75253cd..c9c6aaec 100644
--- a/sync/template/district.html
+++ b/sync/template/district.html
@@ -35,6 +35,18 @@ function setDistrictColors(map) {
//console.log("using fallback district coloring");
}
}
+
+async function fetchDistrict(lng, lat) {
+ try {
+ const url = `/api/district?lat=${lat}&lng=${lng}`
+ const response = await fetch(url);
+ const data = await response.json();
+ console.log("district", data);
+ } catch (error) {
+ console.error('Error fetching geocoding suggestions:', error);
+ }
+}
+
function onLoad() {
console.log("Setting up the map...");
mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN;
@@ -118,6 +130,7 @@ function onLoad() {
});*/
addressDisplay.show(l);
+ fetchDistrict(l.geometry.coordinates[0], l.geometry.coordinates[1]);
});
}
document.addEventListener("DOMContentLoaded", onLoad);
From 9b5140f0c2649dbf748092c675647e7693445b7a Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Thu, 15 Jan 2026 23:19:31 +0000
Subject: [PATCH 0046/1453] Show full district details on location search
---
api/api.go | 9 ++++-
api/types.go | 5 ++-
sync/template/district.html | 66 +++++++++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 9 deletions(-)
diff --git a/api/api.go b/api/api.go
index 2e0a268c..7e61ea0c 100644
--- a/api/api.go
+++ b/api/api.go
@@ -103,8 +103,15 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
render.Render(w, r, errRender(fmt.Errorf("Failed to get district: %w", err)))
return
}
+ if district == nil {
+ http.NotFound(w, r)
+ return
+ }
d := ResponseDistrict{
- Agency: district.Agency.GetOr(""),
+ Agency: district.Agency.GetOr(""),
+ Manager: district.GeneralMG.GetOr(""),
+ Phone: district.Phone1.GetOr(""),
+ Website: district.Website.GetOr(""),
}
if err := render.Render(w, r, d); err != nil {
render.Render(w, r, errRender(err))
diff --git a/api/types.go b/api/types.go
index b511b456..1f23fdc9 100644
--- a/api/types.go
+++ b/api/types.go
@@ -63,7 +63,10 @@ type NoteAudioPayload struct {
}
type ResponseDistrict struct {
- Agency string `json:"agency"`
+ Agency string `json:"agency"`
+ Manager string `json:"manager"`
+ Phone string `json:"phone"`
+ Website string `json:"website"`
}
type ResponseMosquitoSource struct {
diff --git a/sync/template/district.html b/sync/template/district.html
index c9c6aaec..b1cf612c 100644
--- a/sync/template/district.html
+++ b/sync/template/district.html
@@ -40,8 +40,23 @@ async function fetchDistrict(lng, lat) {
try {
const url = `/api/district?lat=${lat}&lng=${lng}`
const response = await fetch(url);
+ var agencyEl = document.querySelector("#district-agency");
+ var managerEl = document.querySelector("#district-manager");
+ var phoneEl = document.querySelector("#district-phone");
+ var websiteEl = document.querySelector("#district-website");
+ if (response.status == 404) {
+ agencyEl.innerHTML = "no matching district";
+ managerEl.innerHTML = "-";
+ phoneEl.innerHTML = "-";
+ websiteEl.innerHTML = "-";
+ return
+ }
const data = await response.json();
console.log("district", data);
+ agencyEl.innerHTML = data.agency;
+ managerEl.innerHTML = data.manager;
+ phoneEl.innerHTML = data.phone;
+ websiteEl.innerHTML = data.website;
} catch (error) {
console.error('Error fetching geocoding suggestions:', error);
}
@@ -117,17 +132,20 @@ function onLoad() {
addressSuggestionEnable(address, suggestionsContainer);*/
const addressDisplay = document.querySelector("address-display");
const addressInput = document.querySelector("address-input");
- const mapComponent = document.querySelector("map-component");
addressInput.addEventListener("address-selected", (event) => {
const l = event.detail.location;
// Center map on selected address
- //mapComponent.jumpTo(coordinates);
+ map.jumpTo({
+ center: l.geometry.coordinates,
+ zoom: 14,
+ });
// Add marker for selected address
- /*mapComponent.addMarker(coordinates, {
- title: event.detail.address
- });*/
+ const marker = new mapboxgl.Marker({
+ color: "#FF0000",
+ draggable: false
+ }).setLngLat(l.geometry.coordinates).addTo(map);
addressDisplay.show(l);
fetchDistrict(l.geometry.coordinates[0], l.geometry.coordinates[1]);
@@ -139,6 +157,13 @@ document.addEventListener("DOMContentLoaded", onLoad);
body {
background-color: #f8f9fa;
}
+.detail-label {
+ font-size: 0.8rem;
+ text-transform: uppercase;
+ color: #6c757d;
+ margin-bottom: 2px;
+ font-weight: 600;
+}
.dashboard-container {
padding: 20px 0;
}
@@ -225,8 +250,35 @@ body {
-
{{end}}
From 684c42413191deb6d50d9ad483d97472ecefa9a9 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 16 Jan 2026 14:43:26 +0000
Subject: [PATCH 0047/1453] Move imported districts to its own schema, add ref
from organization
This will make it possible to assign reports to an organization
---
db/bobgen.yaml | 1 +
...district.bob.go => import.district.bob.go} | 6 +-
db/dberrors/organization.bob.go | 18 +
...district.bob.go => import.district.bob.go} | 40 +-
db/dbinfo/organization.bob.go | 116 ++-
db/factory/bobfactory_context.bob.go | 74 +-
db/factory/bobfactory_main.bob.go | 120 ++--
...district.bob.go => import.district.bob.go} | 678 ++++++++++--------
db/factory/organization.bob.go | 267 ++++++-
db/migrations/00034_district.sql | 6 +
db/models/bob_joins.bob.go | 2 +
db/models/bob_loaders.bob.go | 4 +
db/models/bob_where.bob.go | 6 +-
...district.bob.go => import.district.bob.go} | 420 ++++++++---
db/models/organization.bob.go | 501 +++++++++----
platform/district.go | 4 +-
16 files changed, 1561 insertions(+), 702 deletions(-)
rename db/dberrors/{district.bob.go => import.district.bob.go} (75%)
rename db/dbinfo/{district.bob.go => import.district.bob.go} (89%)
rename db/factory/{district.bob.go => import.district.bob.go} (50%)
create mode 100644 db/migrations/00034_district.sql
rename db/models/{district.bob.go => import.district.bob.go} (60%)
diff --git a/db/bobgen.yaml b/db/bobgen.yaml
index b9f4c8d7..47f2dcc1 100644
--- a/db/bobgen.yaml
+++ b/db/bobgen.yaml
@@ -13,6 +13,7 @@ no_tests: true
psql:
schemas:
- "arcgis"
+ - "import"
- "public"
- "publicreport"
- "fieldseeker"
diff --git a/db/dberrors/district.bob.go b/db/dberrors/import.district.bob.go
similarity index 75%
rename from db/dberrors/district.bob.go
rename to db/dberrors/import.district.bob.go
index b564e22b..a69509a5 100644
--- a/db/dberrors/district.bob.go
+++ b/db/dberrors/import.district.bob.go
@@ -3,15 +3,15 @@
package dberrors
-var DistrictErrors = &districtErrors{
+var ImportDistrictErrors = &importDistrictErrors{
ErrUniqueDistrictPkey: &UniqueConstraintError{
- schema: "",
+ schema: "import",
table: "district",
columns: []string{"gid"},
s: "district_pkey",
},
}
-type districtErrors struct {
+type importDistrictErrors struct {
ErrUniqueDistrictPkey *UniqueConstraintError
}
diff --git a/db/dberrors/organization.bob.go b/db/dberrors/organization.bob.go
index d9bf3dbd..fee0219d 100644
--- a/db/dberrors/organization.bob.go
+++ b/db/dberrors/organization.bob.go
@@ -10,8 +10,26 @@ var OrganizationErrors = &organizationErrors{
columns: []string{"id"},
s: "organization_pkey",
},
+
+ ErrUniqueOrganizationImportDistrictGidKey: &UniqueConstraintError{
+ schema: "",
+ table: "organization",
+ columns: []string{"import_district_gid"},
+ s: "organization_import_district_gid_key",
+ },
+
+ ErrUniqueOrganizationWebsiteKey: &UniqueConstraintError{
+ schema: "",
+ table: "organization",
+ columns: []string{"website"},
+ s: "organization_website_key",
+ },
}
type organizationErrors struct {
ErrUniqueOrganizationPkey *UniqueConstraintError
+
+ ErrUniqueOrganizationImportDistrictGidKey *UniqueConstraintError
+
+ ErrUniqueOrganizationWebsiteKey *UniqueConstraintError
}
diff --git a/db/dbinfo/district.bob.go b/db/dbinfo/import.district.bob.go
similarity index 89%
rename from db/dbinfo/district.bob.go
rename to db/dbinfo/import.district.bob.go
index 1cbd0a70..e51c4fcb 100644
--- a/db/dbinfo/district.bob.go
+++ b/db/dbinfo/import.district.bob.go
@@ -5,20 +5,20 @@ package dbinfo
import "github.com/aarondl/opt/null"
-var Districts = Table[
- districtColumns,
- districtIndexes,
- districtForeignKeys,
- districtUniques,
- districtChecks,
+var ImportDistricts = Table[
+ importDistrictColumns,
+ importDistrictIndexes,
+ importDistrictForeignKeys,
+ importDistrictUniques,
+ importDistrictChecks,
]{
- Schema: "",
+ Schema: "import",
Name: "district",
- Columns: districtColumns{
+ Columns: importDistrictColumns{
Gid: column{
Name: "gid",
DBType: "integer",
- Default: "nextval('district_gid_seq'::regclass)",
+ Default: "nextval('import.district_gid_seq'::regclass)",
Comment: "",
Nullable: false,
Generated: false,
@@ -223,7 +223,7 @@ var Districts = Table[
AutoIncr: false,
},
},
- Indexes: districtIndexes{
+ Indexes: importDistrictIndexes{
DistrictPkey: index{
Type: "btree",
Name: "district_pkey",
@@ -268,7 +268,7 @@ var Districts = Table[
Comment: "",
}
-type districtColumns struct {
+type importDistrictColumns struct {
Gid column
ID column
Website column
@@ -294,37 +294,37 @@ type districtColumns struct {
Geom4326 column
}
-func (c districtColumns) AsSlice() []column {
+func (c importDistrictColumns) AsSlice() []column {
return []column{
c.Gid, c.ID, c.Website, c.Contact, c.Address, c.Regionid, c.PostalCod, c.Phone1, c.Fax1, c.Agency, c.Code1, c.City1, c.ShapeLeng, c.Address2, c.GeneralMG, c.City2, c.PostalC1, c.Fax2, c.Phone2, c.ShapeLe1, c.ShapeArea, c.Geom, c.Geom4326,
}
}
-type districtIndexes struct {
+type importDistrictIndexes struct {
DistrictPkey index
DistrictGeomIdx index
}
-func (i districtIndexes) AsSlice() []index {
+func (i importDistrictIndexes) AsSlice() []index {
return []index{
i.DistrictPkey, i.DistrictGeomIdx,
}
}
-type districtForeignKeys struct{}
+type importDistrictForeignKeys struct{}
-func (f districtForeignKeys) AsSlice() []foreignKey {
+func (f importDistrictForeignKeys) AsSlice() []foreignKey {
return []foreignKey{}
}
-type districtUniques struct{}
+type importDistrictUniques struct{}
-func (u districtUniques) AsSlice() []constraint {
+func (u importDistrictUniques) AsSlice() []constraint {
return []constraint{}
}
-type districtChecks struct{}
+type importDistrictChecks struct{}
-func (c districtChecks) AsSlice() []check {
+func (c importDistrictChecks) AsSlice() []check {
return []check{}
}
diff --git a/db/dbinfo/organization.bob.go b/db/dbinfo/organization.bob.go
index 3539999d..cd42ae32 100644
--- a/db/dbinfo/organization.bob.go
+++ b/db/dbinfo/organization.bob.go
@@ -60,6 +60,24 @@ var Organizations = Table[
Generated: false,
AutoIncr: false,
},
+ ImportDistrictGid: column{
+ Name: "import_district_gid",
+ DBType: "integer",
+ Default: "NULL",
+ Comment: "",
+ Nullable: true,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Website: column{
+ Name: "website",
+ DBType: "text",
+ Default: "NULL",
+ Comment: "",
+ Nullable: true,
+ Generated: false,
+ AutoIncr: false,
+ },
},
Indexes: organizationIndexes{
OrganizationPkey: index{
@@ -79,50 +97,120 @@ var Organizations = Table[
Where: "",
Include: []string{},
},
+ OrganizationImportDistrictGidKey: index{
+ Type: "btree",
+ Name: "organization_import_district_gid_key",
+ Columns: []indexColumn{
+ {
+ Name: "import_district_gid",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ OrganizationWebsiteKey: index{
+ Type: "btree",
+ Name: "organization_website_key",
+ Columns: []indexColumn{
+ {
+ Name: "website",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
},
PrimaryKey: &constraint{
Name: "organization_pkey",
Columns: []string{"id"},
Comment: "",
},
+ ForeignKeys: organizationForeignKeys{
+ OrganizationOrganizationImportDistrictGidFkey: foreignKey{
+ constraint: constraint{
+ Name: "organization.organization_import_district_gid_fkey",
+ Columns: []string{"import_district_gid"},
+ Comment: "",
+ },
+ ForeignTable: "import.district",
+ ForeignColumns: []string{"gid"},
+ },
+ },
+ Uniques: organizationUniques{
+ OrganizationImportDistrictGidKey: constraint{
+ Name: "organization_import_district_gid_key",
+ Columns: []string{"import_district_gid"},
+ Comment: "",
+ },
+ OrganizationWebsiteKey: constraint{
+ Name: "organization_website_key",
+ Columns: []string{"website"},
+ Comment: "",
+ },
+ },
Comment: "",
}
type organizationColumns struct {
- ID column
- Name column
- ArcgisID column
- ArcgisName column
- FieldseekerURL column
+ ID column
+ Name column
+ ArcgisID column
+ ArcgisName column
+ FieldseekerURL column
+ ImportDistrictGid column
+ Website column
}
func (c organizationColumns) AsSlice() []column {
return []column{
- c.ID, c.Name, c.ArcgisID, c.ArcgisName, c.FieldseekerURL,
+ c.ID, c.Name, c.ArcgisID, c.ArcgisName, c.FieldseekerURL, c.ImportDistrictGid, c.Website,
}
}
type organizationIndexes struct {
- OrganizationPkey index
+ OrganizationPkey index
+ OrganizationImportDistrictGidKey index
+ OrganizationWebsiteKey index
}
func (i organizationIndexes) AsSlice() []index {
return []index{
- i.OrganizationPkey,
+ i.OrganizationPkey, i.OrganizationImportDistrictGidKey, i.OrganizationWebsiteKey,
}
}
-type organizationForeignKeys struct{}
-
-func (f organizationForeignKeys) AsSlice() []foreignKey {
- return []foreignKey{}
+type organizationForeignKeys struct {
+ OrganizationOrganizationImportDistrictGidFkey foreignKey
}
-type organizationUniques struct{}
+func (f organizationForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.OrganizationOrganizationImportDistrictGidFkey,
+ }
+}
+
+type organizationUniques struct {
+ OrganizationImportDistrictGidKey constraint
+ OrganizationWebsiteKey constraint
+}
func (u organizationUniques) AsSlice() []constraint {
- return []constraint{}
+ return []constraint{
+ u.OrganizationImportDistrictGidKey, u.OrganizationWebsiteKey,
+ }
}
type organizationChecks struct{}
diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go
index f584a12c..289d2646 100644
--- a/db/factory/bobfactory_context.bob.go
+++ b/db/factory/bobfactory_context.bob.go
@@ -17,9 +17,6 @@ var (
arcgisUserPrivilegeWithParentsCascadingCtx = newContextual[bool]("arcgisUserPrivilegeWithParentsCascading")
arcgisUserPrivilegeRelUserUserCtx = newContextual[bool]("arcgis.user_.arcgis.user_privilege.arcgis.user_privilege.user_privilege_user_id_fkey")
- // Relationship Contexts for district
- districtWithParentsCascadingCtx = newContextual[bool]("districtWithParentsCascading")
-
// Relationship Contexts for fieldseeker.containerrelate
fieldseekerContainerrelateWithParentsCascadingCtx = newContextual[bool]("fieldseekerContainerrelateWithParentsCascading")
fieldseekerContainerrelateRelOrganizationCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey")
@@ -145,6 +142,10 @@ var (
h3AggregationWithParentsCascadingCtx = newContextual[bool]("h3AggregationWithParentsCascading")
h3AggregationRelOrganizationCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey")
+ // Relationship Contexts for import.district
+ importDistrictWithParentsCascadingCtx = newContextual[bool]("importDistrictWithParentsCascading")
+ importDistrictRelImportDistrictGidOrganizationCtx = newContextual[bool]("import.district.organization.organization.organization_import_district_gid_fkey")
+
// Relationship Contexts for note_audio
noteAudioWithParentsCascadingCtx = newContextual[bool]("noteAudioWithParentsCascading")
noteAudioRelCreatorUserCtx = newContextual[bool]("note_audio.user_.note_audio.note_audio_creator_id_fkey")
@@ -186,39 +187,40 @@ var (
oauthTokenRelUserUserCtx = newContextual[bool]("oauth_token.user_.oauth_token.oauth_token_user_id_fkey")
// Relationship Contexts for organization
- organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading")
- organizationRelContainerrelatesCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey")
- organizationRelFieldscoutinglogsCtx = newContextual[bool]("fieldseeker.fieldscoutinglog.organization.fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey")
- organizationRelHabitatrelatesCtx = newContextual[bool]("fieldseeker.habitatrelate.organization.fieldseeker.habitatrelate.habitatrelate_organization_id_fkey")
- organizationRelInspectionsamplesCtx = newContextual[bool]("fieldseeker.inspectionsample.organization.fieldseeker.inspectionsample.inspectionsample_organization_id_fkey")
- organizationRelInspectionsampledetailsCtx = newContextual[bool]("fieldseeker.inspectionsampledetail.organization.fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey")
- organizationRelLinelocationsCtx = newContextual[bool]("fieldseeker.linelocation.organization.fieldseeker.linelocation.linelocation_organization_id_fkey")
- organizationRelLocationtrackingsCtx = newContextual[bool]("fieldseeker.locationtracking.organization.fieldseeker.locationtracking.locationtracking_organization_id_fkey")
- organizationRelMosquitoinspectionsCtx = newContextual[bool]("fieldseeker.mosquitoinspection.organization.fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey")
- organizationRelPointlocationsCtx = newContextual[bool]("fieldseeker.pointlocation.organization.fieldseeker.pointlocation.pointlocation_organization_id_fkey")
- organizationRelPolygonlocationsCtx = newContextual[bool]("fieldseeker.polygonlocation.organization.fieldseeker.polygonlocation.polygonlocation_organization_id_fkey")
- organizationRelPoolsCtx = newContextual[bool]("fieldseeker.pool.organization.fieldseeker.pool.pool_organization_id_fkey")
- organizationRelPooldetailsCtx = newContextual[bool]("fieldseeker.pooldetail.organization.fieldseeker.pooldetail.pooldetail_organization_id_fkey")
- organizationRelProposedtreatmentareasCtx = newContextual[bool]("fieldseeker.proposedtreatmentarea.organization.fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey")
- organizationRelQamosquitoinspectionsCtx = newContextual[bool]("fieldseeker.qamosquitoinspection.organization.fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey")
- organizationRelRodentlocationsCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey")
- organizationRelSamplecollectionsCtx = newContextual[bool]("fieldseeker.samplecollection.organization.fieldseeker.samplecollection.samplecollection_organization_id_fkey")
- organizationRelSamplelocationsCtx = newContextual[bool]("fieldseeker.samplelocation.organization.fieldseeker.samplelocation.samplelocation_organization_id_fkey")
- organizationRelServicerequestsCtx = newContextual[bool]("fieldseeker.servicerequest.organization.fieldseeker.servicerequest.servicerequest_organization_id_fkey")
- organizationRelSpeciesabundancesCtx = newContextual[bool]("fieldseeker.speciesabundance.organization.fieldseeker.speciesabundance.speciesabundance_organization_id_fkey")
- organizationRelStormdrainsCtx = newContextual[bool]("fieldseeker.stormdrain.organization.fieldseeker.stormdrain.stormdrain_organization_id_fkey")
- organizationRelTimecardsCtx = newContextual[bool]("fieldseeker.timecard.organization.fieldseeker.timecard.timecard_organization_id_fkey")
- organizationRelTrapdataCtx = newContextual[bool]("fieldseeker.trapdata.organization.fieldseeker.trapdata.trapdata_organization_id_fkey")
- organizationRelTraplocationsCtx = newContextual[bool]("fieldseeker.traplocation.organization.fieldseeker.traplocation.traplocation_organization_id_fkey")
- organizationRelTreatmentsCtx = newContextual[bool]("fieldseeker.treatment.organization.fieldseeker.treatment.treatment_organization_id_fkey")
- organizationRelTreatmentareasCtx = newContextual[bool]("fieldseeker.treatmentarea.organization.fieldseeker.treatmentarea.treatmentarea_organization_id_fkey")
- organizationRelZonesCtx = newContextual[bool]("fieldseeker.zones.organization.fieldseeker.zones.zones_organization_id_fkey")
- organizationRelZones2sCtx = newContextual[bool]("fieldseeker.zones2.organization.fieldseeker.zones2.zones2_organization_id_fkey")
- organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey")
- organizationRelH3AggregationsCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey")
- organizationRelNoteAudiosCtx = newContextual[bool]("note_audio.organization.note_audio.note_audio_organization_id_fkey")
- organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey")
- organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey")
+ organizationWithParentsCascadingCtx = newContextual[bool]("organizationWithParentsCascading")
+ organizationRelContainerrelatesCtx = newContextual[bool]("fieldseeker.containerrelate.organization.fieldseeker.containerrelate.containerrelate_organization_id_fkey")
+ organizationRelFieldscoutinglogsCtx = newContextual[bool]("fieldseeker.fieldscoutinglog.organization.fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey")
+ organizationRelHabitatrelatesCtx = newContextual[bool]("fieldseeker.habitatrelate.organization.fieldseeker.habitatrelate.habitatrelate_organization_id_fkey")
+ organizationRelInspectionsamplesCtx = newContextual[bool]("fieldseeker.inspectionsample.organization.fieldseeker.inspectionsample.inspectionsample_organization_id_fkey")
+ organizationRelInspectionsampledetailsCtx = newContextual[bool]("fieldseeker.inspectionsampledetail.organization.fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey")
+ organizationRelLinelocationsCtx = newContextual[bool]("fieldseeker.linelocation.organization.fieldseeker.linelocation.linelocation_organization_id_fkey")
+ organizationRelLocationtrackingsCtx = newContextual[bool]("fieldseeker.locationtracking.organization.fieldseeker.locationtracking.locationtracking_organization_id_fkey")
+ organizationRelMosquitoinspectionsCtx = newContextual[bool]("fieldseeker.mosquitoinspection.organization.fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey")
+ organizationRelPointlocationsCtx = newContextual[bool]("fieldseeker.pointlocation.organization.fieldseeker.pointlocation.pointlocation_organization_id_fkey")
+ organizationRelPolygonlocationsCtx = newContextual[bool]("fieldseeker.polygonlocation.organization.fieldseeker.polygonlocation.polygonlocation_organization_id_fkey")
+ organizationRelPoolsCtx = newContextual[bool]("fieldseeker.pool.organization.fieldseeker.pool.pool_organization_id_fkey")
+ organizationRelPooldetailsCtx = newContextual[bool]("fieldseeker.pooldetail.organization.fieldseeker.pooldetail.pooldetail_organization_id_fkey")
+ organizationRelProposedtreatmentareasCtx = newContextual[bool]("fieldseeker.proposedtreatmentarea.organization.fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey")
+ organizationRelQamosquitoinspectionsCtx = newContextual[bool]("fieldseeker.qamosquitoinspection.organization.fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey")
+ organizationRelRodentlocationsCtx = newContextual[bool]("fieldseeker.rodentlocation.organization.fieldseeker.rodentlocation.rodentlocation_organization_id_fkey")
+ organizationRelSamplecollectionsCtx = newContextual[bool]("fieldseeker.samplecollection.organization.fieldseeker.samplecollection.samplecollection_organization_id_fkey")
+ organizationRelSamplelocationsCtx = newContextual[bool]("fieldseeker.samplelocation.organization.fieldseeker.samplelocation.samplelocation_organization_id_fkey")
+ organizationRelServicerequestsCtx = newContextual[bool]("fieldseeker.servicerequest.organization.fieldseeker.servicerequest.servicerequest_organization_id_fkey")
+ organizationRelSpeciesabundancesCtx = newContextual[bool]("fieldseeker.speciesabundance.organization.fieldseeker.speciesabundance.speciesabundance_organization_id_fkey")
+ organizationRelStormdrainsCtx = newContextual[bool]("fieldseeker.stormdrain.organization.fieldseeker.stormdrain.stormdrain_organization_id_fkey")
+ organizationRelTimecardsCtx = newContextual[bool]("fieldseeker.timecard.organization.fieldseeker.timecard.timecard_organization_id_fkey")
+ organizationRelTrapdataCtx = newContextual[bool]("fieldseeker.trapdata.organization.fieldseeker.trapdata.trapdata_organization_id_fkey")
+ organizationRelTraplocationsCtx = newContextual[bool]("fieldseeker.traplocation.organization.fieldseeker.traplocation.traplocation_organization_id_fkey")
+ organizationRelTreatmentsCtx = newContextual[bool]("fieldseeker.treatment.organization.fieldseeker.treatment.treatment_organization_id_fkey")
+ organizationRelTreatmentareasCtx = newContextual[bool]("fieldseeker.treatmentarea.organization.fieldseeker.treatmentarea.treatmentarea_organization_id_fkey")
+ organizationRelZonesCtx = newContextual[bool]("fieldseeker.zones.organization.fieldseeker.zones.zones_organization_id_fkey")
+ organizationRelZones2sCtx = newContextual[bool]("fieldseeker.zones2.organization.fieldseeker.zones2.zones2_organization_id_fkey")
+ organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey")
+ organizationRelH3AggregationsCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey")
+ organizationRelNoteAudiosCtx = newContextual[bool]("note_audio.organization.note_audio.note_audio_organization_id_fkey")
+ organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey")
+ organizationRelImportDistrictGidDistrictCtx = newContextual[bool]("import.district.organization.organization.organization_import_district_gid_fkey")
+ organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey")
// Relationship Contexts for publicreport.nuisance
publicreportNuisanceWithParentsCascadingCtx = newContextual[bool]("publicreportNuisanceWithParentsCascading")
diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go
index d3822ee8..eadbf506 100644
--- a/db/factory/bobfactory_main.bob.go
+++ b/db/factory/bobfactory_main.bob.go
@@ -20,7 +20,6 @@ import (
type Factory struct {
baseArcgisUserMods ArcgisUserModSlice
baseArcgisUserPrivilegeMods ArcgisUserPrivilegeModSlice
- baseDistrictMods DistrictModSlice
baseFieldseekerContainerrelateMods FieldseekerContainerrelateModSlice
baseFieldseekerFieldscoutinglogMods FieldseekerFieldscoutinglogModSlice
baseFieldseekerHabitatrelateMods FieldseekerHabitatrelateModSlice
@@ -53,6 +52,7 @@ type Factory struct {
baseGeometryColumnMods GeometryColumnModSlice
baseGooseDBVersionMods GooseDBVersionModSlice
baseH3AggregationMods H3AggregationModSlice
+ baseImportDistrictMods ImportDistrictModSlice
baseNoteAudioMods NoteAudioModSlice
baseNoteAudioBreadcrumbMods NoteAudioBreadcrumbModSlice
baseNoteAudioDatumMods NoteAudioDatumModSlice
@@ -154,52 +154,6 @@ func (f *Factory) FromExistingArcgisUserPrivilege(m *models.ArcgisUserPrivilege)
return o
}
-func (f *Factory) NewDistrict(mods ...DistrictMod) *DistrictTemplate {
- return f.NewDistrictWithContext(context.Background(), mods...)
-}
-
-func (f *Factory) NewDistrictWithContext(ctx context.Context, mods ...DistrictMod) *DistrictTemplate {
- o := &DistrictTemplate{f: f}
-
- if f != nil {
- f.baseDistrictMods.Apply(ctx, o)
- }
-
- DistrictModSlice(mods).Apply(ctx, o)
-
- return o
-}
-
-func (f *Factory) FromExistingDistrict(m *models.District) *DistrictTemplate {
- o := &DistrictTemplate{f: f, alreadyPersisted: true}
-
- o.Gid = func() int32 { return m.Gid }
- o.ID = func() null.Val[decimal.Decimal] { return m.ID }
- o.Website = func() null.Val[string] { return m.Website }
- o.Contact = func() null.Val[string] { return m.Contact }
- o.Address = func() null.Val[string] { return m.Address }
- o.Regionid = func() null.Val[decimal.Decimal] { return m.Regionid }
- o.PostalCod = func() null.Val[decimal.Decimal] { return m.PostalCod }
- o.Phone1 = func() null.Val[string] { return m.Phone1 }
- o.Fax1 = func() null.Val[string] { return m.Fax1 }
- o.Agency = func() null.Val[string] { return m.Agency }
- o.Code1 = func() null.Val[string] { return m.Code1 }
- o.City1 = func() null.Val[string] { return m.City1 }
- o.ShapeLeng = func() null.Val[decimal.Decimal] { return m.ShapeLeng }
- o.Address2 = func() null.Val[string] { return m.Address2 }
- o.GeneralMG = func() null.Val[string] { return m.GeneralMG }
- o.City2 = func() null.Val[string] { return m.City2 }
- o.PostalC1 = func() null.Val[decimal.Decimal] { return m.PostalC1 }
- o.Fax2 = func() null.Val[string] { return m.Fax2 }
- o.Phone2 = func() null.Val[string] { return m.Phone2 }
- o.ShapeLe1 = func() null.Val[decimal.Decimal] { return m.ShapeLe1 }
- o.ShapeArea = func() null.Val[decimal.Decimal] { return m.ShapeArea }
- o.Geom = func() null.Val[string] { return m.Geom }
- o.Geom4326 = func() null.Val[string] { return m.Geom4326 }
-
- return o
-}
-
func (f *Factory) NewFieldseekerContainerrelate(mods ...FieldseekerContainerrelateMod) *FieldseekerContainerrelateTemplate {
return f.NewFieldseekerContainerrelateWithContext(context.Background(), mods...)
}
@@ -2074,6 +2028,57 @@ func (f *Factory) FromExistingH3Aggregation(m *models.H3Aggregation) *H3Aggregat
return o
}
+func (f *Factory) NewImportDistrict(mods ...ImportDistrictMod) *ImportDistrictTemplate {
+ return f.NewImportDistrictWithContext(context.Background(), mods...)
+}
+
+func (f *Factory) NewImportDistrictWithContext(ctx context.Context, mods ...ImportDistrictMod) *ImportDistrictTemplate {
+ o := &ImportDistrictTemplate{f: f}
+
+ if f != nil {
+ f.baseImportDistrictMods.Apply(ctx, o)
+ }
+
+ ImportDistrictModSlice(mods).Apply(ctx, o)
+
+ return o
+}
+
+func (f *Factory) FromExistingImportDistrict(m *models.ImportDistrict) *ImportDistrictTemplate {
+ o := &ImportDistrictTemplate{f: f, alreadyPersisted: true}
+
+ o.Gid = func() int32 { return m.Gid }
+ o.ID = func() null.Val[decimal.Decimal] { return m.ID }
+ o.Website = func() null.Val[string] { return m.Website }
+ o.Contact = func() null.Val[string] { return m.Contact }
+ o.Address = func() null.Val[string] { return m.Address }
+ o.Regionid = func() null.Val[decimal.Decimal] { return m.Regionid }
+ o.PostalCod = func() null.Val[decimal.Decimal] { return m.PostalCod }
+ o.Phone1 = func() null.Val[string] { return m.Phone1 }
+ o.Fax1 = func() null.Val[string] { return m.Fax1 }
+ o.Agency = func() null.Val[string] { return m.Agency }
+ o.Code1 = func() null.Val[string] { return m.Code1 }
+ o.City1 = func() null.Val[string] { return m.City1 }
+ o.ShapeLeng = func() null.Val[decimal.Decimal] { return m.ShapeLeng }
+ o.Address2 = func() null.Val[string] { return m.Address2 }
+ o.GeneralMG = func() null.Val[string] { return m.GeneralMG }
+ o.City2 = func() null.Val[string] { return m.City2 }
+ o.PostalC1 = func() null.Val[decimal.Decimal] { return m.PostalC1 }
+ o.Fax2 = func() null.Val[string] { return m.Fax2 }
+ o.Phone2 = func() null.Val[string] { return m.Phone2 }
+ o.ShapeLe1 = func() null.Val[decimal.Decimal] { return m.ShapeLe1 }
+ o.ShapeArea = func() null.Val[decimal.Decimal] { return m.ShapeArea }
+ o.Geom = func() null.Val[string] { return m.Geom }
+ o.Geom4326 = func() null.Val[string] { return m.Geom4326 }
+
+ ctx := context.Background()
+ if m.R.ImportDistrictGidOrganization != nil {
+ ImportDistrictMods.WithExistingImportDistrictGidOrganization(m.R.ImportDistrictGidOrganization).Apply(ctx, o)
+ }
+
+ return o
+}
+
func (f *Factory) NewNoteAudio(mods ...NoteAudioMod) *NoteAudioTemplate {
return f.NewNoteAudioWithContext(context.Background(), mods...)
}
@@ -2400,6 +2405,8 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
o.ArcgisID = func() null.Val[string] { return m.ArcgisID }
o.ArcgisName = func() null.Val[string] { return m.ArcgisName }
o.FieldseekerURL = func() null.Val[string] { return m.FieldseekerURL }
+ o.ImportDistrictGid = func() null.Val[int32] { return m.ImportDistrictGid }
+ o.Website = func() null.Val[string] { return m.Website }
ctx := context.Background()
if len(m.R.Containerrelates) > 0 {
@@ -2495,6 +2502,9 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
if len(m.R.NoteImages) > 0 {
OrganizationMods.AddExistingNoteImages(m.R.NoteImages...).Apply(ctx, o)
}
+ if m.R.ImportDistrictGidDistrict != nil {
+ OrganizationMods.WithExistingImportDistrictGidDistrict(m.R.ImportDistrictGidDistrict).Apply(ctx, o)
+ }
if len(m.R.User) > 0 {
OrganizationMods.AddExistingUser(m.R.User...).Apply(ctx, o)
}
@@ -2947,14 +2957,6 @@ func (f *Factory) AddBaseArcgisUserPrivilegeMod(mods ...ArcgisUserPrivilegeMod)
f.baseArcgisUserPrivilegeMods = append(f.baseArcgisUserPrivilegeMods, mods...)
}
-func (f *Factory) ClearBaseDistrictMods() {
- f.baseDistrictMods = nil
-}
-
-func (f *Factory) AddBaseDistrictMod(mods ...DistrictMod) {
- f.baseDistrictMods = append(f.baseDistrictMods, mods...)
-}
-
func (f *Factory) ClearBaseFieldseekerContainerrelateMods() {
f.baseFieldseekerContainerrelateMods = nil
}
@@ -3211,6 +3213,14 @@ func (f *Factory) AddBaseH3AggregationMod(mods ...H3AggregationMod) {
f.baseH3AggregationMods = append(f.baseH3AggregationMods, mods...)
}
+func (f *Factory) ClearBaseImportDistrictMods() {
+ f.baseImportDistrictMods = nil
+}
+
+func (f *Factory) AddBaseImportDistrictMod(mods ...ImportDistrictMod) {
+ f.baseImportDistrictMods = append(f.baseImportDistrictMods, mods...)
+}
+
func (f *Factory) ClearBaseNoteAudioMods() {
f.baseNoteAudioMods = nil
}
diff --git a/db/factory/district.bob.go b/db/factory/import.district.bob.go
similarity index 50%
rename from db/factory/district.bob.go
rename to db/factory/import.district.bob.go
index fd5944c4..b2ebd11c 100644
--- a/db/factory/district.bob.go
+++ b/db/factory/import.district.bob.go
@@ -16,27 +16,27 @@ import (
"github.com/stephenafamo/bob"
)
-type DistrictMod interface {
- Apply(context.Context, *DistrictTemplate)
+type ImportDistrictMod interface {
+ Apply(context.Context, *ImportDistrictTemplate)
}
-type DistrictModFunc func(context.Context, *DistrictTemplate)
+type ImportDistrictModFunc func(context.Context, *ImportDistrictTemplate)
-func (f DistrictModFunc) Apply(ctx context.Context, n *DistrictTemplate) {
+func (f ImportDistrictModFunc) Apply(ctx context.Context, n *ImportDistrictTemplate) {
f(ctx, n)
}
-type DistrictModSlice []DistrictMod
+type ImportDistrictModSlice []ImportDistrictMod
-func (mods DistrictModSlice) Apply(ctx context.Context, n *DistrictTemplate) {
+func (mods ImportDistrictModSlice) Apply(ctx context.Context, n *ImportDistrictTemplate) {
for _, f := range mods {
f.Apply(ctx, n)
}
}
-// DistrictTemplate is an object representing the database table.
+// ImportDistrictTemplate is an object representing the database table.
// all columns are optional and should be set by mods
-type DistrictTemplate struct {
+type ImportDistrictTemplate struct {
Gid func() int32
ID func() null.Val[decimal.Decimal]
Website func() null.Val[string]
@@ -61,26 +61,42 @@ type DistrictTemplate struct {
Geom func() null.Val[string]
Geom4326 func() null.Val[string]
+ r importDistrictR
f *Factory
alreadyPersisted bool
}
-// Apply mods to the DistrictTemplate
-func (o *DistrictTemplate) Apply(ctx context.Context, mods ...DistrictMod) {
+type importDistrictR struct {
+ ImportDistrictGidOrganization *importDistrictRImportDistrictGidOrganizationR
+}
+
+type importDistrictRImportDistrictGidOrganizationR struct {
+ o *OrganizationTemplate
+}
+
+// Apply mods to the ImportDistrictTemplate
+func (o *ImportDistrictTemplate) Apply(ctx context.Context, mods ...ImportDistrictMod) {
for _, mod := range mods {
mod.Apply(ctx, o)
}
}
-// setModelRels creates and sets the relationships on *models.District
+// setModelRels creates and sets the relationships on *models.ImportDistrict
// according to the relationships in the template. Nothing is inserted into the db
-func (t DistrictTemplate) setModelRels(o *models.District) {}
+func (t ImportDistrictTemplate) setModelRels(o *models.ImportDistrict) {
+ if t.r.ImportDistrictGidOrganization != nil {
+ rel := t.r.ImportDistrictGidOrganization.o.Build()
+ rel.R.ImportDistrictGidDistrict = o
+ rel.ImportDistrictGid = null.From(o.Gid) // h2
+ o.R.ImportDistrictGidOrganization = rel
+ }
+}
-// BuildSetter returns an *models.DistrictSetter
+// BuildSetter returns an *models.ImportDistrictSetter
// this does nothing with the relationship templates
-func (o DistrictTemplate) BuildSetter() *models.DistrictSetter {
- m := &models.DistrictSetter{}
+func (o ImportDistrictTemplate) BuildSetter() *models.ImportDistrictSetter {
+ m := &models.ImportDistrictSetter{}
if o.Gid != nil {
val := o.Gid()
@@ -174,10 +190,10 @@ func (o DistrictTemplate) BuildSetter() *models.DistrictSetter {
return m
}
-// BuildManySetter returns an []*models.DistrictSetter
+// BuildManySetter returns an []*models.ImportDistrictSetter
// this does nothing with the relationship templates
-func (o DistrictTemplate) BuildManySetter(number int) []*models.DistrictSetter {
- m := make([]*models.DistrictSetter, number)
+func (o ImportDistrictTemplate) BuildManySetter(number int) []*models.ImportDistrictSetter {
+ m := make([]*models.ImportDistrictSetter, number)
for i := range m {
m[i] = o.BuildSetter()
@@ -186,11 +202,11 @@ func (o DistrictTemplate) BuildManySetter(number int) []*models.DistrictSetter {
return m
}
-// Build returns an *models.District
+// Build returns an *models.ImportDistrict
// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use DistrictTemplate.Create
-func (o DistrictTemplate) Build() *models.District {
- m := &models.District{}
+// NOTE: Objects are not inserted into the database. Use ImportDistrictTemplate.Create
+func (o ImportDistrictTemplate) Build() *models.ImportDistrict {
+ m := &models.ImportDistrict{}
if o.Gid != nil {
m.Gid = o.Gid()
@@ -267,11 +283,11 @@ func (o DistrictTemplate) Build() *models.District {
return m
}
-// BuildMany returns an models.DistrictSlice
+// BuildMany returns an models.ImportDistrictSlice
// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use DistrictTemplate.CreateMany
-func (o DistrictTemplate) BuildMany(number int) models.DistrictSlice {
- m := make(models.DistrictSlice, number)
+// NOTE: Objects are not inserted into the database. Use ImportDistrictTemplate.CreateMany
+func (o ImportDistrictTemplate) BuildMany(number int) models.ImportDistrictSlice {
+ m := make(models.ImportDistrictSlice, number)
for i := range m {
m[i] = o.Build()
@@ -280,26 +296,45 @@ func (o DistrictTemplate) BuildMany(number int) models.DistrictSlice {
return m
}
-func ensureCreatableDistrict(m *models.DistrictSetter) {
+func ensureCreatableImportDistrict(m *models.ImportDistrictSetter) {
}
-// insertOptRels creates and inserts any optional the relationships on *models.District
+// insertOptRels creates and inserts any optional the relationships on *models.ImportDistrict
// according to the relationships in the template.
// any required relationship should have already exist on the model
-func (o *DistrictTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.District) error {
+func (o *ImportDistrictTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ImportDistrict) error {
var err error
+ isImportDistrictGidOrganizationDone, _ := importDistrictRelImportDistrictGidOrganizationCtx.Value(ctx)
+ if !isImportDistrictGidOrganizationDone && o.r.ImportDistrictGidOrganization != nil {
+ ctx = importDistrictRelImportDistrictGidOrganizationCtx.WithValue(ctx, true)
+ if o.r.ImportDistrictGidOrganization.o.alreadyPersisted {
+ m.R.ImportDistrictGidOrganization = o.r.ImportDistrictGidOrganization.o.Build()
+ } else {
+ var rel0 *models.Organization
+ rel0, err = o.r.ImportDistrictGidOrganization.o.Create(ctx, exec)
+ if err != nil {
+ return err
+ }
+ err = m.AttachImportDistrictGidOrganization(ctx, exec, rel0)
+ if err != nil {
+ return err
+ }
+ }
+
+ }
+
return err
}
-// Create builds a district and inserts it into the database
+// Create builds a importDistrict and inserts it into the database
// Relations objects are also inserted and placed in the .R field
-func (o *DistrictTemplate) Create(ctx context.Context, exec bob.Executor) (*models.District, error) {
+func (o *ImportDistrictTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ImportDistrict, error) {
var err error
opt := o.BuildSetter()
- ensureCreatableDistrict(opt)
+ ensureCreatableImportDistrict(opt)
- m, err := models.Districts.Insert(opt).One(ctx, exec)
+ m, err := models.ImportDistricts.Insert(opt).One(ctx, exec)
if err != nil {
return nil, err
}
@@ -310,10 +345,10 @@ func (o *DistrictTemplate) Create(ctx context.Context, exec bob.Executor) (*mode
return m, err
}
-// MustCreate builds a district and inserts it into the database
+// MustCreate builds a importDistrict and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
-func (o *DistrictTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.District {
+func (o *ImportDistrictTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ImportDistrict {
m, err := o.Create(ctx, exec)
if err != nil {
panic(err)
@@ -321,10 +356,10 @@ func (o *DistrictTemplate) MustCreate(ctx context.Context, exec bob.Executor) *m
return m
}
-// CreateOrFail builds a district and inserts it into the database
+// CreateOrFail builds a importDistrict and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o *DistrictTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.District {
+func (o *ImportDistrictTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ImportDistrict {
tb.Helper()
m, err := o.Create(ctx, exec)
if err != nil {
@@ -334,11 +369,11 @@ func (o *DistrictTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec
return m
}
-// CreateMany builds multiple districts and inserts them into the database
+// CreateMany builds multiple importDistricts and inserts them into the database
// Relations objects are also inserted and placed in the .R field
-func (o DistrictTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.DistrictSlice, error) {
+func (o ImportDistrictTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ImportDistrictSlice, error) {
var err error
- m := make(models.DistrictSlice, number)
+ m := make(models.ImportDistrictSlice, number)
for i := range m {
m[i], err = o.Create(ctx, exec)
@@ -350,10 +385,10 @@ func (o DistrictTemplate) CreateMany(ctx context.Context, exec bob.Executor, num
return m, nil
}
-// MustCreateMany builds multiple districts and inserts them into the database
+// MustCreateMany builds multiple importDistricts and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
-func (o DistrictTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.DistrictSlice {
+func (o ImportDistrictTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ImportDistrictSlice {
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
panic(err)
@@ -361,10 +396,10 @@ func (o DistrictTemplate) MustCreateMany(ctx context.Context, exec bob.Executor,
return m
}
-// CreateManyOrFail builds multiple districts and inserts them into the database
+// CreateManyOrFail builds multiple importDistricts and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o DistrictTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.DistrictSlice {
+func (o ImportDistrictTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ImportDistrictSlice {
tb.Helper()
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
@@ -374,64 +409,64 @@ func (o DistrictTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, e
return m
}
-// District has methods that act as mods for the DistrictTemplate
-var DistrictMods districtMods
+// ImportDistrict has methods that act as mods for the ImportDistrictTemplate
+var ImportDistrictMods importDistrictMods
-type districtMods struct{}
+type importDistrictMods struct{}
-func (m districtMods) RandomizeAllColumns(f *faker.Faker) DistrictMod {
- return DistrictModSlice{
- DistrictMods.RandomGid(f),
- DistrictMods.RandomID(f),
- DistrictMods.RandomWebsite(f),
- DistrictMods.RandomContact(f),
- DistrictMods.RandomAddress(f),
- DistrictMods.RandomRegionid(f),
- DistrictMods.RandomPostalCod(f),
- DistrictMods.RandomPhone1(f),
- DistrictMods.RandomFax1(f),
- DistrictMods.RandomAgency(f),
- DistrictMods.RandomCode1(f),
- DistrictMods.RandomCity1(f),
- DistrictMods.RandomShapeLeng(f),
- DistrictMods.RandomAddress2(f),
- DistrictMods.RandomGeneralMG(f),
- DistrictMods.RandomCity2(f),
- DistrictMods.RandomPostalC1(f),
- DistrictMods.RandomFax2(f),
- DistrictMods.RandomPhone2(f),
- DistrictMods.RandomShapeLe1(f),
- DistrictMods.RandomShapeArea(f),
- DistrictMods.RandomGeom(f),
- DistrictMods.RandomGeom4326(f),
+func (m importDistrictMods) RandomizeAllColumns(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModSlice{
+ ImportDistrictMods.RandomGid(f),
+ ImportDistrictMods.RandomID(f),
+ ImportDistrictMods.RandomWebsite(f),
+ ImportDistrictMods.RandomContact(f),
+ ImportDistrictMods.RandomAddress(f),
+ ImportDistrictMods.RandomRegionid(f),
+ ImportDistrictMods.RandomPostalCod(f),
+ ImportDistrictMods.RandomPhone1(f),
+ ImportDistrictMods.RandomFax1(f),
+ ImportDistrictMods.RandomAgency(f),
+ ImportDistrictMods.RandomCode1(f),
+ ImportDistrictMods.RandomCity1(f),
+ ImportDistrictMods.RandomShapeLeng(f),
+ ImportDistrictMods.RandomAddress2(f),
+ ImportDistrictMods.RandomGeneralMG(f),
+ ImportDistrictMods.RandomCity2(f),
+ ImportDistrictMods.RandomPostalC1(f),
+ ImportDistrictMods.RandomFax2(f),
+ ImportDistrictMods.RandomPhone2(f),
+ ImportDistrictMods.RandomShapeLe1(f),
+ ImportDistrictMods.RandomShapeArea(f),
+ ImportDistrictMods.RandomGeom(f),
+ ImportDistrictMods.RandomGeom4326(f),
}
}
// Set the model columns to this value
-func (m districtMods) Gid(val int32) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Gid(val int32) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Gid = func() int32 { return val }
})
}
// Set the Column from the function
-func (m districtMods) GidFunc(f func() int32) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) GidFunc(f func() int32) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Gid = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetGid() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetGid() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Gid = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
-func (m districtMods) RandomGid(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGid(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Gid = func() int32 {
return random_int32(f)
}
@@ -439,22 +474,22 @@ func (m districtMods) RandomGid(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) ID(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ID(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ID = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) IDFunc(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) IDFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ID = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetID() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetID() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ID = nil
})
}
@@ -462,8 +497,8 @@ func (m districtMods) UnsetID() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomID(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomID(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ID = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -478,8 +513,8 @@ func (m districtMods) RandomID(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomIDNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomIDNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ID = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -492,22 +527,22 @@ func (m districtMods) RandomIDNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Website(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Website(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Website = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) WebsiteFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) WebsiteFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Website = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetWebsite() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetWebsite() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Website = nil
})
}
@@ -515,8 +550,8 @@ func (m districtMods) UnsetWebsite() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomWebsite(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomWebsite(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Website = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -531,8 +566,8 @@ func (m districtMods) RandomWebsite(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomWebsiteNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomWebsiteNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Website = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -545,22 +580,22 @@ func (m districtMods) RandomWebsiteNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Contact(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Contact(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Contact = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) ContactFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ContactFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Contact = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetContact() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetContact() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Contact = nil
})
}
@@ -568,8 +603,8 @@ func (m districtMods) UnsetContact() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomContact(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomContact(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Contact = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -584,8 +619,8 @@ func (m districtMods) RandomContact(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomContactNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomContactNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Contact = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -598,22 +633,22 @@ func (m districtMods) RandomContactNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Address(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Address(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) AddressFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) AddressFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetAddress() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetAddress() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address = nil
})
}
@@ -621,8 +656,8 @@ func (m districtMods) UnsetAddress() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomAddress(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAddress(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -637,8 +672,8 @@ func (m districtMods) RandomAddress(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomAddressNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAddressNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -651,22 +686,22 @@ func (m districtMods) RandomAddressNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Regionid(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Regionid(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Regionid = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) RegionidFunc(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RegionidFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Regionid = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetRegionid() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetRegionid() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Regionid = nil
})
}
@@ -674,8 +709,8 @@ func (m districtMods) UnsetRegionid() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomRegionid(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomRegionid(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Regionid = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -690,8 +725,8 @@ func (m districtMods) RandomRegionid(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomRegionidNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomRegionidNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Regionid = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -704,22 +739,22 @@ func (m districtMods) RandomRegionidNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) PostalCod(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) PostalCod(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalCod = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) PostalCodFunc(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) PostalCodFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalCod = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetPostalCod() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetPostalCod() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalCod = nil
})
}
@@ -727,8 +762,8 @@ func (m districtMods) UnsetPostalCod() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomPostalCod(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPostalCod(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalCod = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -743,8 +778,8 @@ func (m districtMods) RandomPostalCod(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomPostalCodNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPostalCodNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalCod = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -757,22 +792,22 @@ func (m districtMods) RandomPostalCodNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Phone1(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Phone1(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone1 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Phone1Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Phone1Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetPhone1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetPhone1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone1 = nil
})
}
@@ -780,8 +815,8 @@ func (m districtMods) UnsetPhone1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomPhone1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPhone1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -796,8 +831,8 @@ func (m districtMods) RandomPhone1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomPhone1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPhone1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -810,22 +845,22 @@ func (m districtMods) RandomPhone1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Fax1(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Fax1(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax1 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Fax1Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Fax1Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetFax1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetFax1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax1 = nil
})
}
@@ -833,8 +868,8 @@ func (m districtMods) UnsetFax1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomFax1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomFax1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -849,8 +884,8 @@ func (m districtMods) RandomFax1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomFax1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomFax1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -863,22 +898,22 @@ func (m districtMods) RandomFax1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Agency(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Agency(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Agency = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) AgencyFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) AgencyFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Agency = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetAgency() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetAgency() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Agency = nil
})
}
@@ -886,8 +921,8 @@ func (m districtMods) UnsetAgency() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomAgency(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAgency(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Agency = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -902,8 +937,8 @@ func (m districtMods) RandomAgency(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomAgencyNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAgencyNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Agency = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -916,22 +951,22 @@ func (m districtMods) RandomAgencyNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Code1(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Code1(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Code1 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Code1Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Code1Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Code1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetCode1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetCode1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Code1 = nil
})
}
@@ -939,8 +974,8 @@ func (m districtMods) UnsetCode1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomCode1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCode1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Code1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -955,8 +990,8 @@ func (m districtMods) RandomCode1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomCode1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCode1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Code1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -969,22 +1004,22 @@ func (m districtMods) RandomCode1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) City1(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) City1(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City1 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) City1Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) City1Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetCity1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetCity1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City1 = nil
})
}
@@ -992,8 +1027,8 @@ func (m districtMods) UnsetCity1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomCity1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCity1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1008,8 +1043,8 @@ func (m districtMods) RandomCity1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomCity1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCity1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City1 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1022,22 +1057,22 @@ func (m districtMods) RandomCity1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) ShapeLeng(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeLeng(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLeng = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) ShapeLengFunc(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeLengFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLeng = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetShapeLeng() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetShapeLeng() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLeng = nil
})
}
@@ -1045,8 +1080,8 @@ func (m districtMods) UnsetShapeLeng() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomShapeLeng(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeLeng(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLeng = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1061,8 +1096,8 @@ func (m districtMods) RandomShapeLeng(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomShapeLengNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeLengNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLeng = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1075,22 +1110,22 @@ func (m districtMods) RandomShapeLengNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Address2(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Address2(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address2 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Address2Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Address2Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address2 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetAddress2() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetAddress2() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address2 = nil
})
}
@@ -1098,8 +1133,8 @@ func (m districtMods) UnsetAddress2() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomAddress2(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAddress2(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1114,8 +1149,8 @@ func (m districtMods) RandomAddress2(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomAddress2NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomAddress2NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Address2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1128,22 +1163,22 @@ func (m districtMods) RandomAddress2NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) GeneralMG(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) GeneralMG(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.GeneralMG = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) GeneralMGFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) GeneralMGFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.GeneralMG = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetGeneralMG() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetGeneralMG() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.GeneralMG = nil
})
}
@@ -1151,8 +1186,8 @@ func (m districtMods) UnsetGeneralMG() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomGeneralMG(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeneralMG(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.GeneralMG = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1167,8 +1202,8 @@ func (m districtMods) RandomGeneralMG(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomGeneralMGNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeneralMGNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.GeneralMG = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1181,22 +1216,22 @@ func (m districtMods) RandomGeneralMGNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) City2(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) City2(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City2 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) City2Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) City2Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City2 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetCity2() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetCity2() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City2 = nil
})
}
@@ -1204,8 +1239,8 @@ func (m districtMods) UnsetCity2() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomCity2(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCity2(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1220,8 +1255,8 @@ func (m districtMods) RandomCity2(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomCity2NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomCity2NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.City2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1234,22 +1269,22 @@ func (m districtMods) RandomCity2NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) PostalC1(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) PostalC1(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalC1 = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) PostalC1Func(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) PostalC1Func(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalC1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetPostalC1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetPostalC1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalC1 = nil
})
}
@@ -1257,8 +1292,8 @@ func (m districtMods) UnsetPostalC1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomPostalC1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPostalC1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalC1 = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1273,8 +1308,8 @@ func (m districtMods) RandomPostalC1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomPostalC1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPostalC1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.PostalC1 = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1287,22 +1322,22 @@ func (m districtMods) RandomPostalC1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Fax2(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Fax2(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax2 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Fax2Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Fax2Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax2 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetFax2() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetFax2() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax2 = nil
})
}
@@ -1310,8 +1345,8 @@ func (m districtMods) UnsetFax2() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomFax2(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomFax2(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1326,8 +1361,8 @@ func (m districtMods) RandomFax2(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomFax2NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomFax2NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Fax2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1340,22 +1375,22 @@ func (m districtMods) RandomFax2NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Phone2(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Phone2(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone2 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Phone2Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Phone2Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone2 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetPhone2() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetPhone2() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone2 = nil
})
}
@@ -1363,8 +1398,8 @@ func (m districtMods) UnsetPhone2() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomPhone2(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPhone2(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1379,8 +1414,8 @@ func (m districtMods) RandomPhone2(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomPhone2NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomPhone2NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Phone2 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1393,22 +1428,22 @@ func (m districtMods) RandomPhone2NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) ShapeLe1(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeLe1(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLe1 = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) ShapeLe1Func(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeLe1Func(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLe1 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetShapeLe1() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetShapeLe1() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLe1 = nil
})
}
@@ -1416,8 +1451,8 @@ func (m districtMods) UnsetShapeLe1() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomShapeLe1(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeLe1(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLe1 = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1432,8 +1467,8 @@ func (m districtMods) RandomShapeLe1(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomShapeLe1NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeLe1NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeLe1 = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1446,22 +1481,22 @@ func (m districtMods) RandomShapeLe1NotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) ShapeArea(val null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeArea(val null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeArea = func() null.Val[decimal.Decimal] { return val }
})
}
// Set the Column from the function
-func (m districtMods) ShapeAreaFunc(f func() null.Val[decimal.Decimal]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) ShapeAreaFunc(f func() null.Val[decimal.Decimal]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeArea = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetShapeArea() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetShapeArea() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeArea = nil
})
}
@@ -1469,8 +1504,8 @@ func (m districtMods) UnsetShapeArea() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomShapeArea(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeArea(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeArea = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1485,8 +1520,8 @@ func (m districtMods) RandomShapeArea(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomShapeAreaNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomShapeAreaNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.ShapeArea = func() null.Val[decimal.Decimal] {
if f == nil {
f = &defaultFaker
@@ -1499,22 +1534,22 @@ func (m districtMods) RandomShapeAreaNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Geom(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Geom(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) GeomFunc(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) GeomFunc(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetGeom() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetGeom() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom = nil
})
}
@@ -1522,8 +1557,8 @@ func (m districtMods) UnsetGeom() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomGeom(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeom(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1538,8 +1573,8 @@ func (m districtMods) RandomGeom(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomGeomNotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeomNotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1552,22 +1587,22 @@ func (m districtMods) RandomGeomNotNull(f *faker.Faker) DistrictMod {
}
// Set the model columns to this value
-func (m districtMods) Geom4326(val null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Geom4326(val null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom4326 = func() null.Val[string] { return val }
})
}
// Set the Column from the function
-func (m districtMods) Geom4326Func(f func() null.Val[string]) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) Geom4326Func(f func() null.Val[string]) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom4326 = f
})
}
// Clear any values for the column
-func (m districtMods) UnsetGeom4326() DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) UnsetGeom4326() ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom4326 = nil
})
}
@@ -1575,8 +1610,8 @@ func (m districtMods) UnsetGeom4326() DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is sometimes null
-func (m districtMods) RandomGeom4326(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeom4326(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom4326 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1591,8 +1626,8 @@ func (m districtMods) RandomGeom4326(f *faker.Faker) DistrictMod {
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
// The generated value is never null
-func (m districtMods) RandomGeom4326NotNull(f *faker.Faker) DistrictMod {
- return DistrictModFunc(func(_ context.Context, o *DistrictTemplate) {
+func (m importDistrictMods) RandomGeom4326NotNull(f *faker.Faker) ImportDistrictMod {
+ return ImportDistrictModFunc(func(_ context.Context, o *ImportDistrictTemplate) {
o.Geom4326 = func() null.Val[string] {
if f == nil {
f = &defaultFaker
@@ -1604,11 +1639,46 @@ func (m districtMods) RandomGeom4326NotNull(f *faker.Faker) DistrictMod {
})
}
-func (m districtMods) WithParentsCascading() DistrictMod {
- return DistrictModFunc(func(ctx context.Context, o *DistrictTemplate) {
- if isDone, _ := districtWithParentsCascadingCtx.Value(ctx); isDone {
+func (m importDistrictMods) WithParentsCascading() ImportDistrictMod {
+ return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) {
+ if isDone, _ := importDistrictWithParentsCascadingCtx.Value(ctx); isDone {
return
}
- ctx = districtWithParentsCascadingCtx.WithValue(ctx, true)
+ ctx = importDistrictWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
+ m.WithImportDistrictGidOrganization(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m importDistrictMods) WithImportDistrictGidOrganization(rel *OrganizationTemplate) ImportDistrictMod {
+ return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) {
+ o.r.ImportDistrictGidOrganization = &importDistrictRImportDistrictGidOrganizationR{
+ o: rel,
+ }
+ })
+}
+
+func (m importDistrictMods) WithNewImportDistrictGidOrganization(mods ...OrganizationMod) ImportDistrictMod {
+ return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) {
+ related := o.f.NewOrganizationWithContext(ctx, mods...)
+
+ m.WithImportDistrictGidOrganization(related).Apply(ctx, o)
+ })
+}
+
+func (m importDistrictMods) WithExistingImportDistrictGidOrganization(em *models.Organization) ImportDistrictMod {
+ return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) {
+ o.r.ImportDistrictGidOrganization = &importDistrictRImportDistrictGidOrganizationR{
+ o: o.f.FromExistingOrganization(em),
+ }
+ })
+}
+
+func (m importDistrictMods) WithoutImportDistrictGidOrganization() ImportDistrictMod {
+ return ImportDistrictModFunc(func(ctx context.Context, o *ImportDistrictTemplate) {
+ o.r.ImportDistrictGidOrganization = nil
})
}
diff --git a/db/factory/organization.bob.go b/db/factory/organization.bob.go
index 73aa2bed..957d1c96 100644
--- a/db/factory/organization.bob.go
+++ b/db/factory/organization.bob.go
@@ -36,11 +36,13 @@ func (mods OrganizationModSlice) Apply(ctx context.Context, n *OrganizationTempl
// OrganizationTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type OrganizationTemplate struct {
- ID func() int32
- Name func() string
- ArcgisID func() null.Val[string]
- ArcgisName func() null.Val[string]
- FieldseekerURL func() null.Val[string]
+ ID func() int32
+ Name func() string
+ ArcgisID func() null.Val[string]
+ ArcgisName func() null.Val[string]
+ FieldseekerURL func() null.Val[string]
+ ImportDistrictGid func() null.Val[int32]
+ Website func() null.Val[string]
r organizationR
f *Factory
@@ -49,38 +51,39 @@ type OrganizationTemplate struct {
}
type organizationR struct {
- Containerrelates []*organizationRContainerrelatesR
- Fieldscoutinglogs []*organizationRFieldscoutinglogsR
- Habitatrelates []*organizationRHabitatrelatesR
- Inspectionsamples []*organizationRInspectionsamplesR
- Inspectionsampledetails []*organizationRInspectionsampledetailsR
- Linelocations []*organizationRLinelocationsR
- Locationtrackings []*organizationRLocationtrackingsR
- Mosquitoinspections []*organizationRMosquitoinspectionsR
- Pointlocations []*organizationRPointlocationsR
- Polygonlocations []*organizationRPolygonlocationsR
- Pools []*organizationRPoolsR
- Pooldetails []*organizationRPooldetailsR
- Proposedtreatmentareas []*organizationRProposedtreatmentareasR
- Qamosquitoinspections []*organizationRQamosquitoinspectionsR
- Rodentlocations []*organizationRRodentlocationsR
- Samplecollections []*organizationRSamplecollectionsR
- Samplelocations []*organizationRSamplelocationsR
- Servicerequests []*organizationRServicerequestsR
- Speciesabundances []*organizationRSpeciesabundancesR
- Stormdrains []*organizationRStormdrainsR
- Timecards []*organizationRTimecardsR
- Trapdata []*organizationRTrapdataR
- Traplocations []*organizationRTraplocationsR
- Treatments []*organizationRTreatmentsR
- Treatmentareas []*organizationRTreatmentareasR
- Zones []*organizationRZonesR
- Zones2s []*organizationRZones2sR
- FieldseekerSyncs []*organizationRFieldseekerSyncsR
- H3Aggregations []*organizationRH3AggregationsR
- NoteAudios []*organizationRNoteAudiosR
- NoteImages []*organizationRNoteImagesR
- User []*organizationRUserR
+ Containerrelates []*organizationRContainerrelatesR
+ Fieldscoutinglogs []*organizationRFieldscoutinglogsR
+ Habitatrelates []*organizationRHabitatrelatesR
+ Inspectionsamples []*organizationRInspectionsamplesR
+ Inspectionsampledetails []*organizationRInspectionsampledetailsR
+ Linelocations []*organizationRLinelocationsR
+ Locationtrackings []*organizationRLocationtrackingsR
+ Mosquitoinspections []*organizationRMosquitoinspectionsR
+ Pointlocations []*organizationRPointlocationsR
+ Polygonlocations []*organizationRPolygonlocationsR
+ Pools []*organizationRPoolsR
+ Pooldetails []*organizationRPooldetailsR
+ Proposedtreatmentareas []*organizationRProposedtreatmentareasR
+ Qamosquitoinspections []*organizationRQamosquitoinspectionsR
+ Rodentlocations []*organizationRRodentlocationsR
+ Samplecollections []*organizationRSamplecollectionsR
+ Samplelocations []*organizationRSamplelocationsR
+ Servicerequests []*organizationRServicerequestsR
+ Speciesabundances []*organizationRSpeciesabundancesR
+ Stormdrains []*organizationRStormdrainsR
+ Timecards []*organizationRTimecardsR
+ Trapdata []*organizationRTrapdataR
+ Traplocations []*organizationRTraplocationsR
+ Treatments []*organizationRTreatmentsR
+ Treatmentareas []*organizationRTreatmentareasR
+ Zones []*organizationRZonesR
+ Zones2s []*organizationRZones2sR
+ FieldseekerSyncs []*organizationRFieldseekerSyncsR
+ H3Aggregations []*organizationRH3AggregationsR
+ NoteAudios []*organizationRNoteAudiosR
+ NoteImages []*organizationRNoteImagesR
+ ImportDistrictGidDistrict *organizationRImportDistrictGidDistrictR
+ User []*organizationRUserR
}
type organizationRContainerrelatesR struct {
@@ -207,6 +210,9 @@ type organizationRNoteImagesR struct {
number int
o *NoteImageTemplate
}
+type organizationRImportDistrictGidDistrictR struct {
+ o *ImportDistrictTemplate
+}
type organizationRUserR struct {
number int
o *UserTemplate
@@ -625,6 +631,13 @@ func (t OrganizationTemplate) setModelRels(o *models.Organization) {
o.R.NoteImages = rel
}
+ if t.r.ImportDistrictGidDistrict != nil {
+ rel := t.r.ImportDistrictGidDistrict.o.Build()
+ rel.R.ImportDistrictGidOrganization = o
+ o.ImportDistrictGid = null.From(rel.Gid) // h2
+ o.R.ImportDistrictGidDistrict = rel
+ }
+
if t.r.User != nil {
rel := models.UserSlice{}
for _, r := range t.r.User {
@@ -664,6 +677,14 @@ func (o OrganizationTemplate) BuildSetter() *models.OrganizationSetter {
val := o.FieldseekerURL()
m.FieldseekerURL = omitnull.FromNull(val)
}
+ if o.ImportDistrictGid != nil {
+ val := o.ImportDistrictGid()
+ m.ImportDistrictGid = omitnull.FromNull(val)
+ }
+ if o.Website != nil {
+ val := o.Website()
+ m.Website = omitnull.FromNull(val)
+ }
return m
}
@@ -701,6 +722,12 @@ func (o OrganizationTemplate) Build() *models.Organization {
if o.FieldseekerURL != nil {
m.FieldseekerURL = o.FieldseekerURL()
}
+ if o.ImportDistrictGid != nil {
+ m.ImportDistrictGid = o.ImportDistrictGid()
+ }
+ if o.Website != nil {
+ m.Website = o.Website()
+ }
o.setModelRels(m)
@@ -1353,6 +1380,25 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
}
}
+ isImportDistrictGidDistrictDone, _ := organizationRelImportDistrictGidDistrictCtx.Value(ctx)
+ if !isImportDistrictGidDistrictDone && o.r.ImportDistrictGidDistrict != nil {
+ ctx = organizationRelImportDistrictGidDistrictCtx.WithValue(ctx, true)
+ if o.r.ImportDistrictGidDistrict.o.alreadyPersisted {
+ m.R.ImportDistrictGidDistrict = o.r.ImportDistrictGidDistrict.o.Build()
+ } else {
+ var rel31 *models.ImportDistrict
+ rel31, err = o.r.ImportDistrictGidDistrict.o.Create(ctx, exec)
+ if err != nil {
+ return err
+ }
+ err = m.AttachImportDistrictGidDistrict(ctx, exec, rel31)
+ if err != nil {
+ return err
+ }
+ }
+
+ }
+
isUserDone, _ := organizationRelUserCtx.Value(ctx)
if !isUserDone && o.r.User != nil {
ctx = organizationRelUserCtx.WithValue(ctx, true)
@@ -1360,12 +1406,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
if r.o.alreadyPersisted {
m.R.User = append(m.R.User, r.o.Build())
} else {
- rel31, err := r.o.CreateMany(ctx, exec, r.number)
+ rel32, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachUser(ctx, exec, rel31...)
+ err = m.AttachUser(ctx, exec, rel32...)
if err != nil {
return err
}
@@ -1470,6 +1516,8 @@ func (m organizationMods) RandomizeAllColumns(f *faker.Faker) OrganizationMod {
OrganizationMods.RandomArcgisID(f),
OrganizationMods.RandomArcgisName(f),
OrganizationMods.RandomFieldseekerURL(f),
+ OrganizationMods.RandomImportDistrictGid(f),
+ OrganizationMods.RandomWebsite(f),
}
}
@@ -1694,12 +1742,153 @@ func (m organizationMods) RandomFieldseekerURLNotNull(f *faker.Faker) Organizati
})
}
+// Set the model columns to this value
+func (m organizationMods) ImportDistrictGid(val null.Val[int32]) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.ImportDistrictGid = func() null.Val[int32] { return val }
+ })
+}
+
+// Set the Column from the function
+func (m organizationMods) ImportDistrictGidFunc(f func() null.Val[int32]) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.ImportDistrictGid = f
+ })
+}
+
+// Clear any values for the column
+func (m organizationMods) UnsetImportDistrictGid() OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.ImportDistrictGid = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is sometimes null
+func (m organizationMods) RandomImportDistrictGid(f *faker.Faker) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.ImportDistrictGid = func() null.Val[int32] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_int32(f)
+ return null.From(val)
+ }
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is never null
+func (m organizationMods) RandomImportDistrictGidNotNull(f *faker.Faker) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.ImportDistrictGid = func() null.Val[int32] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_int32(f)
+ return null.From(val)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m organizationMods) Website(val null.Val[string]) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.Website = func() null.Val[string] { return val }
+ })
+}
+
+// Set the Column from the function
+func (m organizationMods) WebsiteFunc(f func() null.Val[string]) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.Website = f
+ })
+}
+
+// Clear any values for the column
+func (m organizationMods) UnsetWebsite() OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.Website = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is sometimes null
+func (m organizationMods) RandomWebsite(f *faker.Faker) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.Website = func() null.Val[string] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_string(f)
+ return null.From(val)
+ }
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+// The generated value is never null
+func (m organizationMods) RandomWebsiteNotNull(f *faker.Faker) OrganizationMod {
+ return OrganizationModFunc(func(_ context.Context, o *OrganizationTemplate) {
+ o.Website = func() null.Val[string] {
+ if f == nil {
+ f = &defaultFaker
+ }
+
+ val := random_string(f)
+ return null.From(val)
+ }
+ })
+}
+
func (m organizationMods) WithParentsCascading() OrganizationMod {
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
if isDone, _ := organizationWithParentsCascadingCtx.Value(ctx); isDone {
return
}
ctx = organizationWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewImportDistrictWithContext(ctx, ImportDistrictMods.WithParentsCascading())
+ m.WithImportDistrictGidDistrict(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m organizationMods) WithImportDistrictGidDistrict(rel *ImportDistrictTemplate) OrganizationMod {
+ return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
+ o.r.ImportDistrictGidDistrict = &organizationRImportDistrictGidDistrictR{
+ o: rel,
+ }
+ })
+}
+
+func (m organizationMods) WithNewImportDistrictGidDistrict(mods ...ImportDistrictMod) OrganizationMod {
+ return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
+ related := o.f.NewImportDistrictWithContext(ctx, mods...)
+
+ m.WithImportDistrictGidDistrict(related).Apply(ctx, o)
+ })
+}
+
+func (m organizationMods) WithExistingImportDistrictGidDistrict(em *models.ImportDistrict) OrganizationMod {
+ return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
+ o.r.ImportDistrictGidDistrict = &organizationRImportDistrictGidDistrictR{
+ o: o.f.FromExistingImportDistrict(em),
+ }
+ })
+}
+
+func (m organizationMods) WithoutImportDistrictGidDistrict() OrganizationMod {
+ return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
+ o.r.ImportDistrictGidDistrict = nil
})
}
diff --git a/db/migrations/00034_district.sql b/db/migrations/00034_district.sql
new file mode 100644
index 00000000..603a0064
--- /dev/null
+++ b/db/migrations/00034_district.sql
@@ -0,0 +1,6 @@
+-- +goose Up
+ALTER TABLE public.organization ADD COLUMN import_district_gid INTEGER UNIQUE REFERENCES import.district(gid);
+ALTER TABLE public.organization ADD COLUMN website TEXT UNIQUE;
+-- +goose Down
+ALTER TABLE public.organization DROP COLUMN website;
+ALTER TABLE public.organization DROP COLUMN import_district_gid;
diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go
index 03d85cb1..ef21e961 100644
--- a/db/models/bob_joins.bob.go
+++ b/db/models/bob_joins.bob.go
@@ -63,6 +63,7 @@ type joins[Q dialect.Joinable] struct {
FieldseekerZones2s joinSet[fieldseekerZones2Joins[Q]]
FieldseekerSyncs joinSet[fieldseekerSyncJoins[Q]]
H3Aggregations joinSet[h3AggregationJoins[Q]]
+ ImportDistricts joinSet[importDistrictJoins[Q]]
NoteAudios joinSet[noteAudioJoins[Q]]
NoteAudioBreadcrumbs joinSet[noteAudioBreadcrumbJoins[Q]]
NoteAudioData joinSet[noteAudioDatumJoins[Q]]
@@ -120,6 +121,7 @@ func getJoins[Q dialect.Joinable]() joins[Q] {
FieldseekerZones2s: buildJoinSet[fieldseekerZones2Joins[Q]](FieldseekerZones2s.Columns, buildFieldseekerZones2Joins),
FieldseekerSyncs: buildJoinSet[fieldseekerSyncJoins[Q]](FieldseekerSyncs.Columns, buildFieldseekerSyncJoins),
H3Aggregations: buildJoinSet[h3AggregationJoins[Q]](H3Aggregations.Columns, buildH3AggregationJoins),
+ ImportDistricts: buildJoinSet[importDistrictJoins[Q]](ImportDistricts.Columns, buildImportDistrictJoins),
NoteAudios: buildJoinSet[noteAudioJoins[Q]](NoteAudios.Columns, buildNoteAudioJoins),
NoteAudioBreadcrumbs: buildJoinSet[noteAudioBreadcrumbJoins[Q]](NoteAudioBreadcrumbs.Columns, buildNoteAudioBreadcrumbJoins),
NoteAudioData: buildJoinSet[noteAudioDatumJoins[Q]](NoteAudioData.Columns, buildNoteAudioDatumJoins),
diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go
index 21748f91..50d02a99 100644
--- a/db/models/bob_loaders.bob.go
+++ b/db/models/bob_loaders.bob.go
@@ -48,6 +48,7 @@ type preloaders struct {
FieldseekerZones2 fieldseekerZones2Preloader
FieldseekerSync fieldseekerSyncPreloader
H3Aggregation h3AggregationPreloader
+ ImportDistrict importDistrictPreloader
NoteAudio noteAudioPreloader
NoteAudioBreadcrumb noteAudioBreadcrumbPreloader
NoteAudioDatum noteAudioDatumPreloader
@@ -97,6 +98,7 @@ func getPreloaders() preloaders {
FieldseekerZones2: buildFieldseekerZones2Preloader(),
FieldseekerSync: buildFieldseekerSyncPreloader(),
H3Aggregation: buildH3AggregationPreloader(),
+ ImportDistrict: buildImportDistrictPreloader(),
NoteAudio: buildNoteAudioPreloader(),
NoteAudioBreadcrumb: buildNoteAudioBreadcrumbPreloader(),
NoteAudioDatum: buildNoteAudioDatumPreloader(),
@@ -152,6 +154,7 @@ type thenLoaders[Q orm.Loadable] struct {
FieldseekerZones2 fieldseekerZones2ThenLoader[Q]
FieldseekerSync fieldseekerSyncThenLoader[Q]
H3Aggregation h3AggregationThenLoader[Q]
+ ImportDistrict importDistrictThenLoader[Q]
NoteAudio noteAudioThenLoader[Q]
NoteAudioBreadcrumb noteAudioBreadcrumbThenLoader[Q]
NoteAudioDatum noteAudioDatumThenLoader[Q]
@@ -201,6 +204,7 @@ func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] {
FieldseekerZones2: buildFieldseekerZones2ThenLoader[Q](),
FieldseekerSync: buildFieldseekerSyncThenLoader[Q](),
H3Aggregation: buildH3AggregationThenLoader[Q](),
+ ImportDistrict: buildImportDistrictThenLoader[Q](),
NoteAudio: buildNoteAudioThenLoader[Q](),
NoteAudioBreadcrumb: buildNoteAudioBreadcrumbThenLoader[Q](),
NoteAudioDatum: buildNoteAudioDatumThenLoader[Q](),
diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go
index 69ff2736..046968ad 100644
--- a/db/models/bob_where.bob.go
+++ b/db/models/bob_where.bob.go
@@ -19,7 +19,6 @@ var (
func Where[Q psql.Filterable]() struct {
ArcgisUsers arcgisuserWhere[Q]
ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q]
- Districts districtWhere[Q]
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q]
@@ -52,6 +51,7 @@ func Where[Q psql.Filterable]() struct {
GeometryColumns geometryColumnWhere[Q]
GooseDBVersions gooseDBVersionWhere[Q]
H3Aggregations h3AggregationWhere[Q]
+ ImportDistricts importDistrictWhere[Q]
NoteAudios noteAudioWhere[Q]
NoteAudioBreadcrumbs noteAudioBreadcrumbWhere[Q]
NoteAudioData noteAudioDatumWhere[Q]
@@ -76,7 +76,6 @@ func Where[Q psql.Filterable]() struct {
return struct {
ArcgisUsers arcgisuserWhere[Q]
ArcgisUserPrivileges arcgisUserPrivilegeWhere[Q]
- Districts districtWhere[Q]
FieldseekerContainerrelates fieldseekerContainerrelateWhere[Q]
FieldseekerFieldscoutinglogs fieldseekerFieldscoutinglogWhere[Q]
FieldseekerHabitatrelates fieldseekerHabitatrelateWhere[Q]
@@ -109,6 +108,7 @@ func Where[Q psql.Filterable]() struct {
GeometryColumns geometryColumnWhere[Q]
GooseDBVersions gooseDBVersionWhere[Q]
H3Aggregations h3AggregationWhere[Q]
+ ImportDistricts importDistrictWhere[Q]
NoteAudios noteAudioWhere[Q]
NoteAudioBreadcrumbs noteAudioBreadcrumbWhere[Q]
NoteAudioData noteAudioDatumWhere[Q]
@@ -132,7 +132,6 @@ func Where[Q psql.Filterable]() struct {
}{
ArcgisUsers: buildArcgisUserWhere[Q](ArcgisUsers.Columns),
ArcgisUserPrivileges: buildArcgisUserPrivilegeWhere[Q](ArcgisUserPrivileges.Columns),
- Districts: buildDistrictWhere[Q](Districts.Columns),
FieldseekerContainerrelates: buildFieldseekerContainerrelateWhere[Q](FieldseekerContainerrelates.Columns),
FieldseekerFieldscoutinglogs: buildFieldseekerFieldscoutinglogWhere[Q](FieldseekerFieldscoutinglogs.Columns),
FieldseekerHabitatrelates: buildFieldseekerHabitatrelateWhere[Q](FieldseekerHabitatrelates.Columns),
@@ -165,6 +164,7 @@ func Where[Q psql.Filterable]() struct {
GeometryColumns: buildGeometryColumnWhere[Q](GeometryColumns.Columns),
GooseDBVersions: buildGooseDBVersionWhere[Q](GooseDBVersions.Columns),
H3Aggregations: buildH3AggregationWhere[Q](H3Aggregations.Columns),
+ ImportDistricts: buildImportDistrictWhere[Q](ImportDistricts.Columns),
NoteAudios: buildNoteAudioWhere[Q](NoteAudios.Columns),
NoteAudioBreadcrumbs: buildNoteAudioBreadcrumbWhere[Q](NoteAudioBreadcrumbs.Columns),
NoteAudioData: buildNoteAudioDatumWhere[Q](NoteAudioData.Columns),
diff --git a/db/models/district.bob.go b/db/models/import.district.bob.go
similarity index 60%
rename from db/models/district.bob.go
rename to db/models/import.district.bob.go
index a0c3bb5b..6f922256 100644
--- a/db/models/district.bob.go
+++ b/db/models/import.district.bob.go
@@ -5,6 +5,7 @@ package models
import (
"context"
+ "fmt"
"io"
"github.com/aarondl/opt/null"
@@ -18,10 +19,13 @@ import (
"github.com/stephenafamo/bob/dialect/psql/sm"
"github.com/stephenafamo/bob/dialect/psql/um"
"github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
)
-// District is an object representing the database table.
-type District struct {
+// ImportDistrict is an object representing the database table.
+type ImportDistrict struct {
Gid int32 `db:"gid,pk" `
ID null.Val[decimal.Decimal] `db:"id" `
Website null.Val[string] `db:"website" `
@@ -45,23 +49,30 @@ type District struct {
ShapeArea null.Val[decimal.Decimal] `db:"shape_area" `
Geom null.Val[string] `db:"geom" `
Geom4326 null.Val[string] `db:"geom_4326,generated" `
+
+ R importDistrictR `db:"-" `
}
-// DistrictSlice is an alias for a slice of pointers to District.
-// This should almost always be used instead of []*District.
-type DistrictSlice []*District
+// ImportDistrictSlice is an alias for a slice of pointers to ImportDistrict.
+// This should almost always be used instead of []*ImportDistrict.
+type ImportDistrictSlice []*ImportDistrict
-// Districts contains methods to work with the district table
-var Districts = psql.NewTablex[*District, DistrictSlice, *DistrictSetter]("", "district", buildDistrictColumns("district"))
+// ImportDistricts contains methods to work with the district table
+var ImportDistricts = psql.NewTablex[*ImportDistrict, ImportDistrictSlice, *ImportDistrictSetter]("import", "district", buildImportDistrictColumns("import.district"))
-// DistrictsQuery is a query on the district table
-type DistrictsQuery = *psql.ViewQuery[*District, DistrictSlice]
+// ImportDistrictsQuery is a query on the district table
+type ImportDistrictsQuery = *psql.ViewQuery[*ImportDistrict, ImportDistrictSlice]
-func buildDistrictColumns(alias string) districtColumns {
- return districtColumns{
+// importDistrictR is where relationships are stored.
+type importDistrictR struct {
+ ImportDistrictGidOrganization *Organization // organization.organization_import_district_gid_fkey
+}
+
+func buildImportDistrictColumns(alias string) importDistrictColumns {
+ return importDistrictColumns{
ColumnsExpr: expr.NewColumnsExpr(
"gid", "id", "website", "contact", "address", "regionid", "postal_cod", "phone1", "fax1", "agency", "code1", "city1", "shape_leng", "address2", "general_mg", "city2", "postal_c_1", "fax2", "phone2", "shape_le_1", "shape_area", "geom", "geom_4326",
- ).WithParent("district"),
+ ).WithParent("import.district"),
tableAlias: alias,
Gid: psql.Quote(alias, "gid"),
ID: psql.Quote(alias, "id"),
@@ -89,7 +100,7 @@ func buildDistrictColumns(alias string) districtColumns {
}
}
-type districtColumns struct {
+type importDistrictColumns struct {
expr.ColumnsExpr
tableAlias string
Gid psql.Expression
@@ -117,18 +128,18 @@ type districtColumns struct {
Geom4326 psql.Expression
}
-func (c districtColumns) Alias() string {
+func (c importDistrictColumns) Alias() string {
return c.tableAlias
}
-func (districtColumns) AliasedAs(alias string) districtColumns {
- return buildDistrictColumns(alias)
+func (importDistrictColumns) AliasedAs(alias string) importDistrictColumns {
+ return buildImportDistrictColumns(alias)
}
-// DistrictSetter is used for insert/upsert/update operations
+// ImportDistrictSetter is used for insert/upsert/update operations
// All values are optional, and do not have to be set
// Generated columns are not included
-type DistrictSetter struct {
+type ImportDistrictSetter struct {
Gid omit.Val[int32] `db:"gid,pk" `
ID omitnull.Val[decimal.Decimal] `db:"id" `
Website omitnull.Val[string] `db:"website" `
@@ -153,7 +164,7 @@ type DistrictSetter struct {
Geom omitnull.Val[string] `db:"geom" `
}
-func (s DistrictSetter) SetColumns() []string {
+func (s ImportDistrictSetter) SetColumns() []string {
vals := make([]string, 0, 22)
if s.Gid.IsValue() {
vals = append(vals, "gid")
@@ -224,7 +235,7 @@ func (s DistrictSetter) SetColumns() []string {
return vals
}
-func (s DistrictSetter) Overwrite(t *District) {
+func (s ImportDistrictSetter) Overwrite(t *ImportDistrict) {
if s.Gid.IsValue() {
t.Gid = s.Gid.MustGet()
}
@@ -293,9 +304,9 @@ func (s DistrictSetter) Overwrite(t *District) {
}
}
-func (s *DistrictSetter) Apply(q *dialect.InsertQuery) {
+func (s *ImportDistrictSetter) Apply(q *dialect.InsertQuery) {
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return Districts.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ return ImportDistricts.BeforeInsertHooks.RunHooks(ctx, exec, s)
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
@@ -436,11 +447,11 @@ func (s *DistrictSetter) Apply(q *dialect.InsertQuery) {
}))
}
-func (s DistrictSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+func (s ImportDistrictSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
return um.Set(s.Expressions()...)
}
-func (s DistrictSetter) Expressions(prefix ...string) []bob.Expression {
+func (s ImportDistrictSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 22)
if s.Gid.IsValue() {
@@ -600,113 +611,114 @@ func (s DistrictSetter) Expressions(prefix ...string) []bob.Expression {
return exprs
}
-// FindDistrict retrieves a single record by primary key
+// FindImportDistrict retrieves a single record by primary key
// If cols is empty Find will return all columns.
-func FindDistrict(ctx context.Context, exec bob.Executor, GidPK int32, cols ...string) (*District, error) {
+func FindImportDistrict(ctx context.Context, exec bob.Executor, GidPK int32, cols ...string) (*ImportDistrict, error) {
if len(cols) == 0 {
- return Districts.Query(
- sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
+ return ImportDistricts.Query(
+ sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))),
).One(ctx, exec)
}
- return Districts.Query(
- sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
- sm.Columns(Districts.Columns.Only(cols...)),
+ return ImportDistricts.Query(
+ sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))),
+ sm.Columns(ImportDistricts.Columns.Only(cols...)),
).One(ctx, exec)
}
-// DistrictExists checks the presence of a single record by primary key
-func DistrictExists(ctx context.Context, exec bob.Executor, GidPK int32) (bool, error) {
- return Districts.Query(
- sm.Where(Districts.Columns.Gid.EQ(psql.Arg(GidPK))),
+// ImportDistrictExists checks the presence of a single record by primary key
+func ImportDistrictExists(ctx context.Context, exec bob.Executor, GidPK int32) (bool, error) {
+ return ImportDistricts.Query(
+ sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(GidPK))),
).Exists(ctx, exec)
}
-// AfterQueryHook is called after District is retrieved from the database
-func (o *District) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+// AfterQueryHook is called after ImportDistrict is retrieved from the database
+func (o *ImportDistrict) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
var err error
switch queryType {
case bob.QueryTypeSelect:
- ctx, err = Districts.AfterSelectHooks.RunHooks(ctx, exec, DistrictSlice{o})
+ ctx, err = ImportDistricts.AfterSelectHooks.RunHooks(ctx, exec, ImportDistrictSlice{o})
case bob.QueryTypeInsert:
- ctx, err = Districts.AfterInsertHooks.RunHooks(ctx, exec, DistrictSlice{o})
+ ctx, err = ImportDistricts.AfterInsertHooks.RunHooks(ctx, exec, ImportDistrictSlice{o})
case bob.QueryTypeUpdate:
- ctx, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, DistrictSlice{o})
+ ctx, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, ImportDistrictSlice{o})
case bob.QueryTypeDelete:
- ctx, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, DistrictSlice{o})
+ ctx, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, ImportDistrictSlice{o})
}
return err
}
-// primaryKeyVals returns the primary key values of the District
-func (o *District) primaryKeyVals() bob.Expression {
+// primaryKeyVals returns the primary key values of the ImportDistrict
+func (o *ImportDistrict) primaryKeyVals() bob.Expression {
return psql.Arg(o.Gid)
}
-func (o *District) pkEQ() dialect.Expression {
- return psql.Quote("district", "gid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+func (o *ImportDistrict) pkEQ() dialect.Expression {
+ return psql.Quote("import.district", "gid").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
}))
}
-// Update uses an executor to update the District
-func (o *District) Update(ctx context.Context, exec bob.Executor, s *DistrictSetter) error {
- v, err := Districts.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+// Update uses an executor to update the ImportDistrict
+func (o *ImportDistrict) Update(ctx context.Context, exec bob.Executor, s *ImportDistrictSetter) error {
+ v, err := ImportDistricts.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
if err != nil {
return err
}
+ o.R = v.R
*o = *v
return nil
}
-// Delete deletes a single District record with an executor
-func (o *District) Delete(ctx context.Context, exec bob.Executor) error {
- _, err := Districts.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+// Delete deletes a single ImportDistrict record with an executor
+func (o *ImportDistrict) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := ImportDistricts.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
return err
}
-// Reload refreshes the District using the executor
-func (o *District) Reload(ctx context.Context, exec bob.Executor) error {
- o2, err := Districts.Query(
- sm.Where(Districts.Columns.Gid.EQ(psql.Arg(o.Gid))),
+// Reload refreshes the ImportDistrict using the executor
+func (o *ImportDistrict) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := ImportDistricts.Query(
+ sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(o.Gid))),
).One(ctx, exec)
if err != nil {
return err
}
-
+ o2.R = o.R
*o = *o2
return nil
}
-// AfterQueryHook is called after DistrictSlice is retrieved from the database
-func (o DistrictSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+// AfterQueryHook is called after ImportDistrictSlice is retrieved from the database
+func (o ImportDistrictSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
var err error
switch queryType {
case bob.QueryTypeSelect:
- ctx, err = Districts.AfterSelectHooks.RunHooks(ctx, exec, o)
+ ctx, err = ImportDistricts.AfterSelectHooks.RunHooks(ctx, exec, o)
case bob.QueryTypeInsert:
- ctx, err = Districts.AfterInsertHooks.RunHooks(ctx, exec, o)
+ ctx, err = ImportDistricts.AfterInsertHooks.RunHooks(ctx, exec, o)
case bob.QueryTypeUpdate:
- ctx, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ ctx, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, o)
case bob.QueryTypeDelete:
- ctx, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ ctx, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, o)
}
return err
}
-func (o DistrictSlice) pkIN() dialect.Expression {
+func (o ImportDistrictSlice) pkIN() dialect.Expression {
if len(o) == 0 {
return psql.Raw("NULL")
}
- return psql.Quote("district", "gid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return psql.Quote("import.district", "gid").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
pkPairs := make([]bob.Expression, len(o))
for i, row := range o {
pkPairs[i] = row.primaryKeyVals()
@@ -718,13 +730,13 @@ func (o DistrictSlice) pkIN() dialect.Expression {
// copyMatchingRows finds models in the given slice that have the same primary key
// then it first copies the existing relationships from the old model to the new model
// and then replaces the old model in the slice with the new model
-func (o DistrictSlice) copyMatchingRows(from ...*District) {
+func (o ImportDistrictSlice) copyMatchingRows(from ...*ImportDistrict) {
for i, old := range o {
for _, new := range from {
if new.Gid != old.Gid {
continue
}
-
+ new.R = old.R
o[i] = new
break
}
@@ -732,25 +744,25 @@ func (o DistrictSlice) copyMatchingRows(from ...*District) {
}
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
-func (o DistrictSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+func (o ImportDistrictSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return Districts.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ return ImportDistricts.BeforeUpdateHooks.RunHooks(ctx, exec, o)
})
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
var err error
switch retrieved := retrieved.(type) {
- case *District:
+ case *ImportDistrict:
o.copyMatchingRows(retrieved)
- case []*District:
+ case []*ImportDistrict:
o.copyMatchingRows(retrieved...)
- case DistrictSlice:
+ case ImportDistrictSlice:
o.copyMatchingRows(retrieved...)
default:
- // If the retrieved value is not a District or a slice of District
+ // If the retrieved value is not a ImportDistrict or a slice of ImportDistrict
// then run the AfterUpdateHooks on the slice
- _, err = Districts.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ _, err = ImportDistricts.AfterUpdateHooks.RunHooks(ctx, exec, o)
}
return err
@@ -761,25 +773,25 @@ func (o DistrictSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
-func (o DistrictSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+func (o ImportDistrictSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return Districts.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ return ImportDistricts.BeforeDeleteHooks.RunHooks(ctx, exec, o)
})
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
var err error
switch retrieved := retrieved.(type) {
- case *District:
+ case *ImportDistrict:
o.copyMatchingRows(retrieved)
- case []*District:
+ case []*ImportDistrict:
o.copyMatchingRows(retrieved...)
- case DistrictSlice:
+ case ImportDistrictSlice:
o.copyMatchingRows(retrieved...)
default:
- // If the retrieved value is not a District or a slice of District
+ // If the retrieved value is not a ImportDistrict or a slice of ImportDistrict
// then run the AfterDeleteHooks on the slice
- _, err = Districts.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ _, err = ImportDistricts.AfterDeleteHooks.RunHooks(ctx, exec, o)
}
return err
@@ -789,30 +801,30 @@ func (o DistrictSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
})
}
-func (o DistrictSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals DistrictSetter) error {
+func (o ImportDistrictSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals ImportDistrictSetter) error {
if len(o) == 0 {
return nil
}
- _, err := Districts.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ _, err := ImportDistricts.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
return err
}
-func (o DistrictSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+func (o ImportDistrictSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
if len(o) == 0 {
return nil
}
- _, err := Districts.Delete(o.DeleteMod()).Exec(ctx, exec)
+ _, err := ImportDistricts.Delete(o.DeleteMod()).Exec(ctx, exec)
return err
}
-func (o DistrictSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+func (o ImportDistrictSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
if len(o) == 0 {
return nil
}
- o2, err := Districts.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ o2, err := ImportDistricts.Query(sm.Where(o.pkIN())).All(ctx, exec)
if err != nil {
return err
}
@@ -822,7 +834,85 @@ func (o DistrictSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
return nil
}
-type districtWhere[Q psql.Filterable] struct {
+// ImportDistrictGidOrganization starts a query for related objects on organization
+func (o *ImportDistrict) ImportDistrictGidOrganization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
+ return Organizations.Query(append(mods,
+ sm.Where(Organizations.Columns.ImportDistrictGid.EQ(psql.Arg(o.Gid))),
+ )...)
+}
+
+func (os ImportDistrictSlice) ImportDistrictGidOrganization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
+ pkGid := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkGid = append(pkGid, o.Gid)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkGid), "integer[]")),
+ ))
+
+ return Organizations.Query(append(mods,
+ sm.Where(psql.Group(Organizations.Columns.ImportDistrictGid).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func insertImportDistrictImportDistrictGidOrganization0(ctx context.Context, exec bob.Executor, organization1 *OrganizationSetter, importDistrict0 *ImportDistrict) (*Organization, error) {
+ organization1.ImportDistrictGid = omitnull.From(importDistrict0.Gid)
+
+ ret, err := Organizations.Insert(organization1).One(ctx, exec)
+ if err != nil {
+ return ret, fmt.Errorf("insertImportDistrictImportDistrictGidOrganization0: %w", err)
+ }
+
+ return ret, nil
+}
+
+func attachImportDistrictImportDistrictGidOrganization0(ctx context.Context, exec bob.Executor, count int, organization1 *Organization, importDistrict0 *ImportDistrict) (*Organization, error) {
+ setter := &OrganizationSetter{
+ ImportDistrictGid: omitnull.From(importDistrict0.Gid),
+ }
+
+ err := organization1.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachImportDistrictImportDistrictGidOrganization0: %w", err)
+ }
+
+ return organization1, nil
+}
+
+func (importDistrict0 *ImportDistrict) InsertImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
+ var err error
+
+ organization1, err := insertImportDistrictImportDistrictGidOrganization0(ctx, exec, related, importDistrict0)
+ if err != nil {
+ return err
+ }
+
+ importDistrict0.R.ImportDistrictGidOrganization = organization1
+
+ organization1.R.ImportDistrictGidDistrict = importDistrict0
+
+ return nil
+}
+
+func (importDistrict0 *ImportDistrict) AttachImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
+ var err error
+
+ _, err = attachImportDistrictImportDistrictGidOrganization0(ctx, exec, 1, organization1, importDistrict0)
+ if err != nil {
+ return err
+ }
+
+ importDistrict0.R.ImportDistrictGidOrganization = organization1
+
+ organization1.R.ImportDistrictGidDistrict = importDistrict0
+
+ return nil
+}
+
+type importDistrictWhere[Q psql.Filterable] struct {
Gid psql.WhereMod[Q, int32]
ID psql.WhereNullMod[Q, decimal.Decimal]
Website psql.WhereNullMod[Q, string]
@@ -848,12 +938,12 @@ type districtWhere[Q psql.Filterable] struct {
Geom4326 psql.WhereNullMod[Q, string]
}
-func (districtWhere[Q]) AliasedAs(alias string) districtWhere[Q] {
- return buildDistrictWhere[Q](buildDistrictColumns(alias))
+func (importDistrictWhere[Q]) AliasedAs(alias string) importDistrictWhere[Q] {
+ return buildImportDistrictWhere[Q](buildImportDistrictColumns(alias))
}
-func buildDistrictWhere[Q psql.Filterable](cols districtColumns) districtWhere[Q] {
- return districtWhere[Q]{
+func buildImportDistrictWhere[Q psql.Filterable](cols importDistrictColumns) importDistrictWhere[Q] {
+ return importDistrictWhere[Q]{
Gid: psql.Where[Q, int32](cols.Gid),
ID: psql.WhereNull[Q, decimal.Decimal](cols.ID),
Website: psql.WhereNull[Q, string](cols.Website),
@@ -879,3 +969,151 @@ func buildDistrictWhere[Q psql.Filterable](cols districtColumns) districtWhere[Q
Geom4326: psql.WhereNull[Q, string](cols.Geom4326),
}
}
+
+func (o *ImportDistrict) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "ImportDistrictGidOrganization":
+ rel, ok := retrieved.(*Organization)
+ if !ok {
+ return fmt.Errorf("importDistrict cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.ImportDistrictGidOrganization = rel
+
+ if rel != nil {
+ rel.R.ImportDistrictGidDistrict = o
+ }
+ return nil
+ default:
+ return fmt.Errorf("importDistrict has no relationship %q", name)
+ }
+}
+
+type importDistrictPreloader struct {
+ ImportDistrictGidOrganization func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildImportDistrictPreloader() importDistrictPreloader {
+ return importDistrictPreloader{
+ ImportDistrictGidOrganization: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
+ Name: "ImportDistrictGidOrganization",
+ Sides: []psql.PreloadSide{
+ {
+ From: ImportDistricts,
+ To: Organizations,
+ FromColumns: []string{"gid"},
+ ToColumns: []string{"import_district_gid"},
+ },
+ },
+ }, Organizations.Columns.Names(), opts...)
+ },
+ }
+}
+
+type importDistrictThenLoader[Q orm.Loadable] struct {
+ ImportDistrictGidOrganization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildImportDistrictThenLoader[Q orm.Loadable]() importDistrictThenLoader[Q] {
+ type ImportDistrictGidOrganizationLoadInterface interface {
+ LoadImportDistrictGidOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return importDistrictThenLoader[Q]{
+ ImportDistrictGidOrganization: thenLoadBuilder[Q](
+ "ImportDistrictGidOrganization",
+ func(ctx context.Context, exec bob.Executor, retrieved ImportDistrictGidOrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImportDistrictGidOrganization(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadImportDistrictGidOrganization loads the importDistrict's ImportDistrictGidOrganization into the .R struct
+func (o *ImportDistrict) LoadImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.ImportDistrictGidOrganization = nil
+
+ related, err := o.ImportDistrictGidOrganization(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ related.R.ImportDistrictGidDistrict = o
+
+ o.R.ImportDistrictGidOrganization = related
+ return nil
+}
+
+// LoadImportDistrictGidOrganization loads the importDistrict's ImportDistrictGidOrganization into the .R struct
+func (os ImportDistrictSlice) LoadImportDistrictGidOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ organizations, err := os.ImportDistrictGidOrganization(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range organizations {
+
+ if !rel.ImportDistrictGid.IsValue() {
+ continue
+ }
+ if !(rel.ImportDistrictGid.IsValue() && o.Gid == rel.ImportDistrictGid.MustGet()) {
+ continue
+ }
+
+ rel.R.ImportDistrictGidDistrict = o
+
+ o.R.ImportDistrictGidOrganization = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+type importDistrictJoins[Q dialect.Joinable] struct {
+ typ string
+ ImportDistrictGidOrganization modAs[Q, organizationColumns]
+}
+
+func (j importDistrictJoins[Q]) aliasedAs(alias string) importDistrictJoins[Q] {
+ return buildImportDistrictJoins[Q](buildImportDistrictColumns(alias), j.typ)
+}
+
+func buildImportDistrictJoins[Q dialect.Joinable](cols importDistrictColumns, typ string) importDistrictJoins[Q] {
+ return importDistrictJoins[Q]{
+ typ: typ,
+ ImportDistrictGidOrganization: modAs[Q, organizationColumns]{
+ c: Organizations.Columns,
+ f: func(to organizationColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
+ to.ImportDistrictGid.EQ(cols.Gid),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/organization.bob.go b/db/models/organization.bob.go
index 256a8f90..c735bef2 100644
--- a/db/models/organization.bob.go
+++ b/db/models/organization.bob.go
@@ -25,11 +25,13 @@ import (
// Organization is an object representing the database table.
type Organization struct {
- ID int32 `db:"id,pk" `
- Name string `db:"name" `
- ArcgisID null.Val[string] `db:"arcgis_id" `
- ArcgisName null.Val[string] `db:"arcgis_name" `
- FieldseekerURL null.Val[string] `db:"fieldseeker_url" `
+ ID int32 `db:"id,pk" `
+ Name string `db:"name" `
+ ArcgisID null.Val[string] `db:"arcgis_id" `
+ ArcgisName null.Val[string] `db:"arcgis_name" `
+ FieldseekerURL null.Val[string] `db:"fieldseeker_url" `
+ ImportDistrictGid null.Val[int32] `db:"import_district_gid" `
+ Website null.Val[string] `db:"website" `
R organizationR `db:"-" `
@@ -48,62 +50,67 @@ type OrganizationsQuery = *psql.ViewQuery[*Organization, OrganizationSlice]
// organizationR is where relationships are stored.
type organizationR struct {
- Containerrelates FieldseekerContainerrelateSlice // fieldseeker.containerrelate.containerrelate_organization_id_fkey
- Fieldscoutinglogs FieldseekerFieldscoutinglogSlice // fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey
- Habitatrelates FieldseekerHabitatrelateSlice // fieldseeker.habitatrelate.habitatrelate_organization_id_fkey
- Inspectionsamples FieldseekerInspectionsampleSlice // fieldseeker.inspectionsample.inspectionsample_organization_id_fkey
- Inspectionsampledetails FieldseekerInspectionsampledetailSlice // fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey
- Linelocations FieldseekerLinelocationSlice // fieldseeker.linelocation.linelocation_organization_id_fkey
- Locationtrackings FieldseekerLocationtrackingSlice // fieldseeker.locationtracking.locationtracking_organization_id_fkey
- Mosquitoinspections FieldseekerMosquitoinspectionSlice // fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey
- Pointlocations FieldseekerPointlocationSlice // fieldseeker.pointlocation.pointlocation_organization_id_fkey
- Polygonlocations FieldseekerPolygonlocationSlice // fieldseeker.polygonlocation.polygonlocation_organization_id_fkey
- Pools FieldseekerPoolSlice // fieldseeker.pool.pool_organization_id_fkey
- Pooldetails FieldseekerPooldetailSlice // fieldseeker.pooldetail.pooldetail_organization_id_fkey
- Proposedtreatmentareas FieldseekerProposedtreatmentareaSlice // fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey
- Qamosquitoinspections FieldseekerQamosquitoinspectionSlice // fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey
- Rodentlocations FieldseekerRodentlocationSlice // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey
- Samplecollections FieldseekerSamplecollectionSlice // fieldseeker.samplecollection.samplecollection_organization_id_fkey
- Samplelocations FieldseekerSamplelocationSlice // fieldseeker.samplelocation.samplelocation_organization_id_fkey
- Servicerequests FieldseekerServicerequestSlice // fieldseeker.servicerequest.servicerequest_organization_id_fkey
- Speciesabundances FieldseekerSpeciesabundanceSlice // fieldseeker.speciesabundance.speciesabundance_organization_id_fkey
- Stormdrains FieldseekerStormdrainSlice // fieldseeker.stormdrain.stormdrain_organization_id_fkey
- Timecards FieldseekerTimecardSlice // fieldseeker.timecard.timecard_organization_id_fkey
- Trapdata FieldseekerTrapdatumSlice // fieldseeker.trapdata.trapdata_organization_id_fkey
- Traplocations FieldseekerTraplocationSlice // fieldseeker.traplocation.traplocation_organization_id_fkey
- Treatments FieldseekerTreatmentSlice // fieldseeker.treatment.treatment_organization_id_fkey
- Treatmentareas FieldseekerTreatmentareaSlice // fieldseeker.treatmentarea.treatmentarea_organization_id_fkey
- Zones FieldseekerZoneSlice // fieldseeker.zones.zones_organization_id_fkey
- Zones2s FieldseekerZones2Slice // fieldseeker.zones2.zones2_organization_id_fkey
- FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey
- H3Aggregations H3AggregationSlice // h3_aggregation.h3_aggregation_organization_id_fkey
- NoteAudios NoteAudioSlice // note_audio.note_audio_organization_id_fkey
- NoteImages NoteImageSlice // note_image.note_image_organization_id_fkey
- User UserSlice // user_.user__organization_id_fkey
+ Containerrelates FieldseekerContainerrelateSlice // fieldseeker.containerrelate.containerrelate_organization_id_fkey
+ Fieldscoutinglogs FieldseekerFieldscoutinglogSlice // fieldseeker.fieldscoutinglog.fieldscoutinglog_organization_id_fkey
+ Habitatrelates FieldseekerHabitatrelateSlice // fieldseeker.habitatrelate.habitatrelate_organization_id_fkey
+ Inspectionsamples FieldseekerInspectionsampleSlice // fieldseeker.inspectionsample.inspectionsample_organization_id_fkey
+ Inspectionsampledetails FieldseekerInspectionsampledetailSlice // fieldseeker.inspectionsampledetail.inspectionsampledetail_organization_id_fkey
+ Linelocations FieldseekerLinelocationSlice // fieldseeker.linelocation.linelocation_organization_id_fkey
+ Locationtrackings FieldseekerLocationtrackingSlice // fieldseeker.locationtracking.locationtracking_organization_id_fkey
+ Mosquitoinspections FieldseekerMosquitoinspectionSlice // fieldseeker.mosquitoinspection.mosquitoinspection_organization_id_fkey
+ Pointlocations FieldseekerPointlocationSlice // fieldseeker.pointlocation.pointlocation_organization_id_fkey
+ Polygonlocations FieldseekerPolygonlocationSlice // fieldseeker.polygonlocation.polygonlocation_organization_id_fkey
+ Pools FieldseekerPoolSlice // fieldseeker.pool.pool_organization_id_fkey
+ Pooldetails FieldseekerPooldetailSlice // fieldseeker.pooldetail.pooldetail_organization_id_fkey
+ Proposedtreatmentareas FieldseekerProposedtreatmentareaSlice // fieldseeker.proposedtreatmentarea.proposedtreatmentarea_organization_id_fkey
+ Qamosquitoinspections FieldseekerQamosquitoinspectionSlice // fieldseeker.qamosquitoinspection.qamosquitoinspection_organization_id_fkey
+ Rodentlocations FieldseekerRodentlocationSlice // fieldseeker.rodentlocation.rodentlocation_organization_id_fkey
+ Samplecollections FieldseekerSamplecollectionSlice // fieldseeker.samplecollection.samplecollection_organization_id_fkey
+ Samplelocations FieldseekerSamplelocationSlice // fieldseeker.samplelocation.samplelocation_organization_id_fkey
+ Servicerequests FieldseekerServicerequestSlice // fieldseeker.servicerequest.servicerequest_organization_id_fkey
+ Speciesabundances FieldseekerSpeciesabundanceSlice // fieldseeker.speciesabundance.speciesabundance_organization_id_fkey
+ Stormdrains FieldseekerStormdrainSlice // fieldseeker.stormdrain.stormdrain_organization_id_fkey
+ Timecards FieldseekerTimecardSlice // fieldseeker.timecard.timecard_organization_id_fkey
+ Trapdata FieldseekerTrapdatumSlice // fieldseeker.trapdata.trapdata_organization_id_fkey
+ Traplocations FieldseekerTraplocationSlice // fieldseeker.traplocation.traplocation_organization_id_fkey
+ Treatments FieldseekerTreatmentSlice // fieldseeker.treatment.treatment_organization_id_fkey
+ Treatmentareas FieldseekerTreatmentareaSlice // fieldseeker.treatmentarea.treatmentarea_organization_id_fkey
+ Zones FieldseekerZoneSlice // fieldseeker.zones.zones_organization_id_fkey
+ Zones2s FieldseekerZones2Slice // fieldseeker.zones2.zones2_organization_id_fkey
+ FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey
+ H3Aggregations H3AggregationSlice // h3_aggregation.h3_aggregation_organization_id_fkey
+ NoteAudios NoteAudioSlice // note_audio.note_audio_organization_id_fkey
+ NoteImages NoteImageSlice // note_image.note_image_organization_id_fkey
+ ImportDistrictGidDistrict *ImportDistrict // organization.organization_import_district_gid_fkey
+ User UserSlice // user_.user__organization_id_fkey
}
func buildOrganizationColumns(alias string) organizationColumns {
return organizationColumns{
ColumnsExpr: expr.NewColumnsExpr(
- "id", "name", "arcgis_id", "arcgis_name", "fieldseeker_url",
+ "id", "name", "arcgis_id", "arcgis_name", "fieldseeker_url", "import_district_gid", "website",
).WithParent("organization"),
- tableAlias: alias,
- ID: psql.Quote(alias, "id"),
- Name: psql.Quote(alias, "name"),
- ArcgisID: psql.Quote(alias, "arcgis_id"),
- ArcgisName: psql.Quote(alias, "arcgis_name"),
- FieldseekerURL: psql.Quote(alias, "fieldseeker_url"),
+ tableAlias: alias,
+ ID: psql.Quote(alias, "id"),
+ Name: psql.Quote(alias, "name"),
+ ArcgisID: psql.Quote(alias, "arcgis_id"),
+ ArcgisName: psql.Quote(alias, "arcgis_name"),
+ FieldseekerURL: psql.Quote(alias, "fieldseeker_url"),
+ ImportDistrictGid: psql.Quote(alias, "import_district_gid"),
+ Website: psql.Quote(alias, "website"),
}
}
type organizationColumns struct {
expr.ColumnsExpr
- tableAlias string
- ID psql.Expression
- Name psql.Expression
- ArcgisID psql.Expression
- ArcgisName psql.Expression
- FieldseekerURL psql.Expression
+ tableAlias string
+ ID psql.Expression
+ Name psql.Expression
+ ArcgisID psql.Expression
+ ArcgisName psql.Expression
+ FieldseekerURL psql.Expression
+ ImportDistrictGid psql.Expression
+ Website psql.Expression
}
func (c organizationColumns) Alias() string {
@@ -118,15 +125,17 @@ func (organizationColumns) AliasedAs(alias string) organizationColumns {
// All values are optional, and do not have to be set
// Generated columns are not included
type OrganizationSetter struct {
- ID omit.Val[int32] `db:"id,pk" `
- Name omit.Val[string] `db:"name" `
- ArcgisID omitnull.Val[string] `db:"arcgis_id" `
- ArcgisName omitnull.Val[string] `db:"arcgis_name" `
- FieldseekerURL omitnull.Val[string] `db:"fieldseeker_url" `
+ ID omit.Val[int32] `db:"id,pk" `
+ Name omit.Val[string] `db:"name" `
+ ArcgisID omitnull.Val[string] `db:"arcgis_id" `
+ ArcgisName omitnull.Val[string] `db:"arcgis_name" `
+ FieldseekerURL omitnull.Val[string] `db:"fieldseeker_url" `
+ ImportDistrictGid omitnull.Val[int32] `db:"import_district_gid" `
+ Website omitnull.Val[string] `db:"website" `
}
func (s OrganizationSetter) SetColumns() []string {
- vals := make([]string, 0, 5)
+ vals := make([]string, 0, 7)
if s.ID.IsValue() {
vals = append(vals, "id")
}
@@ -142,6 +151,12 @@ func (s OrganizationSetter) SetColumns() []string {
if !s.FieldseekerURL.IsUnset() {
vals = append(vals, "fieldseeker_url")
}
+ if !s.ImportDistrictGid.IsUnset() {
+ vals = append(vals, "import_district_gid")
+ }
+ if !s.Website.IsUnset() {
+ vals = append(vals, "website")
+ }
return vals
}
@@ -161,6 +176,12 @@ func (s OrganizationSetter) Overwrite(t *Organization) {
if !s.FieldseekerURL.IsUnset() {
t.FieldseekerURL = s.FieldseekerURL.MustGetNull()
}
+ if !s.ImportDistrictGid.IsUnset() {
+ t.ImportDistrictGid = s.ImportDistrictGid.MustGetNull()
+ }
+ if !s.Website.IsUnset() {
+ t.Website = s.Website.MustGetNull()
+ }
}
func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) {
@@ -169,7 +190,7 @@ func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- vals := make([]bob.Expression, 5)
+ vals := make([]bob.Expression, 7)
if s.ID.IsValue() {
vals[0] = psql.Arg(s.ID.MustGet())
} else {
@@ -200,6 +221,18 @@ func (s *OrganizationSetter) Apply(q *dialect.InsertQuery) {
vals[4] = psql.Raw("DEFAULT")
}
+ if !s.ImportDistrictGid.IsUnset() {
+ vals[5] = psql.Arg(s.ImportDistrictGid.MustGetNull())
+ } else {
+ vals[5] = psql.Raw("DEFAULT")
+ }
+
+ if !s.Website.IsUnset() {
+ vals[6] = psql.Arg(s.Website.MustGetNull())
+ } else {
+ vals[6] = psql.Raw("DEFAULT")
+ }
+
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@@ -209,7 +242,7 @@ func (s OrganizationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s OrganizationSetter) Expressions(prefix ...string) []bob.Expression {
- exprs := make([]bob.Expression, 0, 5)
+ exprs := make([]bob.Expression, 0, 7)
if s.ID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@@ -246,6 +279,20 @@ func (s OrganizationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
+ if !s.ImportDistrictGid.IsUnset() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "import_district_gid")...),
+ psql.Arg(s.ImportDistrictGid),
+ }})
+ }
+
+ if !s.Website.IsUnset() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "website")...),
+ psql.Arg(s.Website),
+ }})
+ }
+
return exprs
}
@@ -1216,6 +1263,30 @@ func (os OrganizationSlice) NoteImages(mods ...bob.Mod[*dialect.SelectQuery]) No
)...)
}
+// ImportDistrictGidDistrict starts a query for related objects on import.district
+func (o *Organization) ImportDistrictGidDistrict(mods ...bob.Mod[*dialect.SelectQuery]) ImportDistrictsQuery {
+ return ImportDistricts.Query(append(mods,
+ sm.Where(ImportDistricts.Columns.Gid.EQ(psql.Arg(o.ImportDistrictGid))),
+ )...)
+}
+
+func (os OrganizationSlice) ImportDistrictGidDistrict(mods ...bob.Mod[*dialect.SelectQuery]) ImportDistrictsQuery {
+ pkImportDistrictGid := make(pgtypes.Array[null.Val[int32]], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkImportDistrictGid = append(pkImportDistrictGid, o.ImportDistrictGid)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkImportDistrictGid), "integer[]")),
+ ))
+
+ return ImportDistricts.Query(append(mods,
+ sm.Where(psql.Group(ImportDistricts.Columns.Gid).OP("IN", PKArgExpr)),
+ )...)
+}
+
// User starts a query for related objects on user_
func (o *Organization) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQuery {
return Users.Query(append(mods,
@@ -3348,6 +3419,54 @@ func (organization0 *Organization) AttachNoteImages(ctx context.Context, exec bo
return nil
}
+func attachOrganizationImportDistrictGidDistrict0(ctx context.Context, exec bob.Executor, count int, organization0 *Organization, importDistrict1 *ImportDistrict) (*Organization, error) {
+ setter := &OrganizationSetter{
+ ImportDistrictGid: omitnull.From(importDistrict1.Gid),
+ }
+
+ err := organization0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachOrganizationImportDistrictGidDistrict0: %w", err)
+ }
+
+ return organization0, nil
+}
+
+func (organization0 *Organization) InsertImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, related *ImportDistrictSetter) error {
+ var err error
+
+ importDistrict1, err := ImportDistricts.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachOrganizationImportDistrictGidDistrict0(ctx, exec, 1, organization0, importDistrict1)
+ if err != nil {
+ return err
+ }
+
+ organization0.R.ImportDistrictGidDistrict = importDistrict1
+
+ importDistrict1.R.ImportDistrictGidOrganization = organization0
+
+ return nil
+}
+
+func (organization0 *Organization) AttachImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, importDistrict1 *ImportDistrict) error {
+ var err error
+
+ _, err = attachOrganizationImportDistrictGidDistrict0(ctx, exec, 1, organization0, importDistrict1)
+ if err != nil {
+ return err
+ }
+
+ organization0.R.ImportDistrictGidDistrict = importDistrict1
+
+ importDistrict1.R.ImportDistrictGidOrganization = organization0
+
+ return nil
+}
+
func insertOrganizationUser0(ctx context.Context, exec bob.Executor, users1 []*UserSetter, organization0 *Organization) (UserSlice, error) {
for i := range users1 {
users1[i].OrganizationID = omit.From(organization0.ID)
@@ -3417,11 +3536,13 @@ func (organization0 *Organization) AttachUser(ctx context.Context, exec bob.Exec
}
type organizationWhere[Q psql.Filterable] struct {
- ID psql.WhereMod[Q, int32]
- Name psql.WhereMod[Q, string]
- ArcgisID psql.WhereNullMod[Q, string]
- ArcgisName psql.WhereNullMod[Q, string]
- FieldseekerURL psql.WhereNullMod[Q, string]
+ ID psql.WhereMod[Q, int32]
+ Name psql.WhereMod[Q, string]
+ ArcgisID psql.WhereNullMod[Q, string]
+ ArcgisName psql.WhereNullMod[Q, string]
+ FieldseekerURL psql.WhereNullMod[Q, string]
+ ImportDistrictGid psql.WhereNullMod[Q, int32]
+ Website psql.WhereNullMod[Q, string]
}
func (organizationWhere[Q]) AliasedAs(alias string) organizationWhere[Q] {
@@ -3430,11 +3551,13 @@ func (organizationWhere[Q]) AliasedAs(alias string) organizationWhere[Q] {
func buildOrganizationWhere[Q psql.Filterable](cols organizationColumns) organizationWhere[Q] {
return organizationWhere[Q]{
- ID: psql.Where[Q, int32](cols.ID),
- Name: psql.Where[Q, string](cols.Name),
- ArcgisID: psql.WhereNull[Q, string](cols.ArcgisID),
- ArcgisName: psql.WhereNull[Q, string](cols.ArcgisName),
- FieldseekerURL: psql.WhereNull[Q, string](cols.FieldseekerURL),
+ ID: psql.Where[Q, int32](cols.ID),
+ Name: psql.Where[Q, string](cols.Name),
+ ArcgisID: psql.WhereNull[Q, string](cols.ArcgisID),
+ ArcgisName: psql.WhereNull[Q, string](cols.ArcgisName),
+ FieldseekerURL: psql.WhereNull[Q, string](cols.FieldseekerURL),
+ ImportDistrictGid: psql.WhereNull[Q, int32](cols.ImportDistrictGid),
+ Website: psql.WhereNull[Q, string](cols.Website),
}
}
@@ -3878,6 +4001,18 @@ func (o *Organization) Preload(name string, retrieved any) error {
}
}
return nil
+ case "ImportDistrictGidDistrict":
+ rel, ok := retrieved.(*ImportDistrict)
+ if !ok {
+ return fmt.Errorf("organization cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.ImportDistrictGidDistrict = rel
+
+ if rel != nil {
+ rel.R.ImportDistrictGidOrganization = o
+ }
+ return nil
case "User":
rels, ok := retrieved.(UserSlice)
if !ok {
@@ -3897,45 +4032,62 @@ func (o *Organization) Preload(name string, retrieved any) error {
}
}
-type organizationPreloader struct{}
+type organizationPreloader struct {
+ ImportDistrictGidDistrict func(...psql.PreloadOption) psql.Preloader
+}
func buildOrganizationPreloader() organizationPreloader {
- return organizationPreloader{}
+ return organizationPreloader{
+ ImportDistrictGidDistrict: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*ImportDistrict, ImportDistrictSlice](psql.PreloadRel{
+ Name: "ImportDistrictGidDistrict",
+ Sides: []psql.PreloadSide{
+ {
+ From: Organizations,
+ To: ImportDistricts,
+ FromColumns: []string{"import_district_gid"},
+ ToColumns: []string{"gid"},
+ },
+ },
+ }, ImportDistricts.Columns.Names(), opts...)
+ },
+ }
}
type organizationThenLoader[Q orm.Loadable] struct {
- Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
- User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Containerrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Fieldscoutinglogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Habitatrelates func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Inspectionsamples func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Inspectionsampledetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Linelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Locationtrackings func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Mosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pointlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Polygonlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pooldetails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Proposedtreatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Qamosquitoinspections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Rodentlocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Samplecollections func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Samplelocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Servicerequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Speciesabundances func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Stormdrains func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Timecards func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Trapdata func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Traplocations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Treatments func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Treatmentareas func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Zones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ ImportDistrictGidDistrict func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ User func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
@@ -4032,6 +4184,9 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
type NoteImagesLoadInterface interface {
LoadNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
+ type ImportDistrictGidDistrictLoadInterface interface {
+ LoadImportDistrictGidDistrict(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
type UserLoadInterface interface {
LoadUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
@@ -4223,6 +4378,12 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
return retrieved.LoadNoteImages(ctx, exec, mods...)
},
),
+ ImportDistrictGidDistrict: thenLoadBuilder[Q](
+ "ImportDistrictGidDistrict",
+ func(ctx context.Context, exec bob.Executor, retrieved ImportDistrictGidDistrictLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImportDistrictGidDistrict(ctx, exec, mods...)
+ },
+ ),
User: thenLoadBuilder[Q](
"User",
func(ctx context.Context, exec bob.Executor, retrieved UserLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
@@ -6123,6 +6284,61 @@ func (os OrganizationSlice) LoadNoteImages(ctx context.Context, exec bob.Executo
return nil
}
+// LoadImportDistrictGidDistrict loads the organization's ImportDistrictGidDistrict into the .R struct
+func (o *Organization) LoadImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.ImportDistrictGidDistrict = nil
+
+ related, err := o.ImportDistrictGidDistrict(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ related.R.ImportDistrictGidOrganization = o
+
+ o.R.ImportDistrictGidDistrict = related
+ return nil
+}
+
+// LoadImportDistrictGidDistrict loads the organization's ImportDistrictGidDistrict into the .R struct
+func (os OrganizationSlice) LoadImportDistrictGidDistrict(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ importDistricts, err := os.ImportDistrictGidDistrict(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range importDistricts {
+ if !o.ImportDistrictGid.IsValue() {
+ continue
+ }
+
+ if !(o.ImportDistrictGid.IsValue() && o.ImportDistrictGid.MustGet() == rel.Gid) {
+ continue
+ }
+
+ rel.R.ImportDistrictGidOrganization = o
+
+ o.R.ImportDistrictGidDistrict = rel
+ break
+ }
+ }
+
+ return nil
+}
+
// LoadUser loads the organization's User into the .R struct
func (o *Organization) LoadUser(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
@@ -8169,39 +8385,40 @@ func (os OrganizationSlice) LoadCountUser(ctx context.Context, exec bob.Executor
}
type organizationJoins[Q dialect.Joinable] struct {
- typ string
- Containerrelates modAs[Q, fieldseekerContainerrelateColumns]
- Fieldscoutinglogs modAs[Q, fieldseekerFieldscoutinglogColumns]
- Habitatrelates modAs[Q, fieldseekerHabitatrelateColumns]
- Inspectionsamples modAs[Q, fieldseekerInspectionsampleColumns]
- Inspectionsampledetails modAs[Q, fieldseekerInspectionsampledetailColumns]
- Linelocations modAs[Q, fieldseekerLinelocationColumns]
- Locationtrackings modAs[Q, fieldseekerLocationtrackingColumns]
- Mosquitoinspections modAs[Q, fieldseekerMosquitoinspectionColumns]
- Pointlocations modAs[Q, fieldseekerPointlocationColumns]
- Polygonlocations modAs[Q, fieldseekerPolygonlocationColumns]
- Pools modAs[Q, fieldseekerPoolColumns]
- Pooldetails modAs[Q, fieldseekerPooldetailColumns]
- Proposedtreatmentareas modAs[Q, fieldseekerProposedtreatmentareaColumns]
- Qamosquitoinspections modAs[Q, fieldseekerQamosquitoinspectionColumns]
- Rodentlocations modAs[Q, fieldseekerRodentlocationColumns]
- Samplecollections modAs[Q, fieldseekerSamplecollectionColumns]
- Samplelocations modAs[Q, fieldseekerSamplelocationColumns]
- Servicerequests modAs[Q, fieldseekerServicerequestColumns]
- Speciesabundances modAs[Q, fieldseekerSpeciesabundanceColumns]
- Stormdrains modAs[Q, fieldseekerStormdrainColumns]
- Timecards modAs[Q, fieldseekerTimecardColumns]
- Trapdata modAs[Q, fieldseekerTrapdatumColumns]
- Traplocations modAs[Q, fieldseekerTraplocationColumns]
- Treatments modAs[Q, fieldseekerTreatmentColumns]
- Treatmentareas modAs[Q, fieldseekerTreatmentareaColumns]
- Zones modAs[Q, fieldseekerZoneColumns]
- Zones2s modAs[Q, fieldseekerZones2Columns]
- FieldseekerSyncs modAs[Q, fieldseekerSyncColumns]
- H3Aggregations modAs[Q, h3AggregationColumns]
- NoteAudios modAs[Q, noteAudioColumns]
- NoteImages modAs[Q, noteImageColumns]
- User modAs[Q, userColumns]
+ typ string
+ Containerrelates modAs[Q, fieldseekerContainerrelateColumns]
+ Fieldscoutinglogs modAs[Q, fieldseekerFieldscoutinglogColumns]
+ Habitatrelates modAs[Q, fieldseekerHabitatrelateColumns]
+ Inspectionsamples modAs[Q, fieldseekerInspectionsampleColumns]
+ Inspectionsampledetails modAs[Q, fieldseekerInspectionsampledetailColumns]
+ Linelocations modAs[Q, fieldseekerLinelocationColumns]
+ Locationtrackings modAs[Q, fieldseekerLocationtrackingColumns]
+ Mosquitoinspections modAs[Q, fieldseekerMosquitoinspectionColumns]
+ Pointlocations modAs[Q, fieldseekerPointlocationColumns]
+ Polygonlocations modAs[Q, fieldseekerPolygonlocationColumns]
+ Pools modAs[Q, fieldseekerPoolColumns]
+ Pooldetails modAs[Q, fieldseekerPooldetailColumns]
+ Proposedtreatmentareas modAs[Q, fieldseekerProposedtreatmentareaColumns]
+ Qamosquitoinspections modAs[Q, fieldseekerQamosquitoinspectionColumns]
+ Rodentlocations modAs[Q, fieldseekerRodentlocationColumns]
+ Samplecollections modAs[Q, fieldseekerSamplecollectionColumns]
+ Samplelocations modAs[Q, fieldseekerSamplelocationColumns]
+ Servicerequests modAs[Q, fieldseekerServicerequestColumns]
+ Speciesabundances modAs[Q, fieldseekerSpeciesabundanceColumns]
+ Stormdrains modAs[Q, fieldseekerStormdrainColumns]
+ Timecards modAs[Q, fieldseekerTimecardColumns]
+ Trapdata modAs[Q, fieldseekerTrapdatumColumns]
+ Traplocations modAs[Q, fieldseekerTraplocationColumns]
+ Treatments modAs[Q, fieldseekerTreatmentColumns]
+ Treatmentareas modAs[Q, fieldseekerTreatmentareaColumns]
+ Zones modAs[Q, fieldseekerZoneColumns]
+ Zones2s modAs[Q, fieldseekerZones2Columns]
+ FieldseekerSyncs modAs[Q, fieldseekerSyncColumns]
+ H3Aggregations modAs[Q, h3AggregationColumns]
+ NoteAudios modAs[Q, noteAudioColumns]
+ NoteImages modAs[Q, noteImageColumns]
+ ImportDistrictGidDistrict modAs[Q, importDistrictColumns]
+ User modAs[Q, userColumns]
}
func (j organizationJoins[Q]) aliasedAs(alias string) organizationJoins[Q] {
@@ -8645,6 +8862,20 @@ func buildOrganizationJoins[Q dialect.Joinable](cols organizationColumns, typ st
return mods
},
},
+ ImportDistrictGidDistrict: modAs[Q, importDistrictColumns]{
+ c: ImportDistricts.Columns,
+ f: func(to importDistrictColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, ImportDistricts.Name().As(to.Alias())).On(
+ to.Gid.EQ(cols.ImportDistrictGid),
+ ))
+ }
+
+ return mods
+ },
+ },
User: modAs[Q, userColumns]{
c: Users.Columns,
f: func(to userColumns) bob.Mod[Q] {
diff --git a/platform/district.go b/platform/district.go
index fd3d76c7..d9c821ba 100644
--- a/platform/district.go
+++ b/platform/district.go
@@ -11,8 +11,8 @@ import (
"github.com/stephenafamo/bob/dialect/psql/sm"
)
-func DistrictForLocation(ctx context.Context, lng float64, lat float64) (*models.District, error) {
- rows, err := models.Districts.Query(
+func DistrictForLocation(ctx context.Context, lng float64, lat float64) (*models.ImportDistrict, error) {
+ rows, err := models.ImportDistricts.Query(
sm.Where(
psql.F("ST_Contains", psql.Raw("geom_4326"), psql.F("ST_SetSRID", psql.F("ST_MakePoint", psql.Arg(lng), psql.Arg(lat)), psql.Arg(4326))),
),
From b95a3275ff49ff342844081249a83220f22b89db Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 16 Jan 2026 14:51:50 +0000
Subject: [PATCH 0048/1453] Set address to empty in quick report upload
Fixes a null value error
---
public-report/quick.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/public-report/quick.go b/public-report/quick.go
index c6498920..1509df56 100644
--- a/public-report/quick.go
+++ b/public-report/quick.go
@@ -54,7 +54,6 @@ func postQuick(w http.ResponseWriter, r *http.Request) {
lat := r.FormValue("latitude")
lng := r.FormValue("longitude")
comments := r.FormValue("comments")
- //photos := r.FormValue("photos")
latitude, err := strconv.ParseFloat(lat, 64)
if err != nil {
@@ -73,6 +72,7 @@ func postQuick(w http.ResponseWriter, r *http.Request) {
}
c, err := h3utils.GetCell(longitude, latitude, 15)
setter := models.PublicreportQuickSetter{
+ Address: omit.From(""),
Created: omit.From(time.Now()),
Comments: omit.From(comments),
//Location: omitnull.From(fmt.Sprintf("ST_GeometryFromText(Point(%s %s))", longitude, latitude)),
From 079d20c086e337986e22cd824e124928921551d6 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 16 Jan 2026 14:52:11 +0000
Subject: [PATCH 0049/1453] Extract EXIF data from images
This required a schema change and actually dumps all existing photo data
from the public reports page. That's probably fine since it's not
deployed to any customers so all data is currently test data.
---
background/arcgis.go | 4 +
db/dberrors/publicreport.image.bob.go | 17 +
db/dberrors/publicreport.image_exif.bob.go | 17 +
db/dberrors/publicreport.pool_image.bob.go | 17 +
db/dberrors/publicreport.pool_photo.bob.go | 17 -
db/dberrors/publicreport.quick_image.bob.go | 17 +
db/dberrors/publicreport.quick_photo.bob.go | 17 -
db/dbinfo/publicreport.image.bob.go | 162 +++
db/dbinfo/publicreport.image_exif.bob.go | 137 ++
db/dbinfo/publicreport.pool_image.bob.go | 132 ++
db/dbinfo/publicreport.pool_photo.bob.go | 147 --
db/dbinfo/publicreport.quick_image.bob.go | 132 ++
db/dbinfo/publicreport.quick_photo.bob.go | 147 --
db/factory/bobfactory_context.bob.go | 28 +-
db/factory/bobfactory_main.bob.go | 171 ++-
db/factory/publicreport.image.bob.go | 822 +++++++++++
db/factory/publicreport.image_exif.bob.go | 413 ++++++
db/factory/publicreport.pool.bob.go | 59 +-
db/factory/publicreport.pool_image.bob.go | 431 ++++++
db/factory/publicreport.pool_photo.bob.go | 498 -------
db/factory/publicreport.quick.bob.go | 59 +-
db/factory/publicreport.quick_image.bob.go | 431 ++++++
db/factory/publicreport.quick_photo.bob.go | 498 -------
db/migrations/00035_photo_content_type.sql | 37 +
db/models/bob_counts.bob.go | 4 +
db/models/bob_joins.bob.go | 12 +-
db/models/bob_loaders.bob.go | 24 +-
db/models/bob_where.bob.go | 18 +-
db/models/publicreport.image.bob.go | 1440 +++++++++++++++++++
db/models/publicreport.image_exif.bob.go | 645 +++++++++
db/models/publicreport.pool.bob.go | 235 +--
db/models/publicreport.pool_image.bob.go | 766 ++++++++++
db/models/publicreport.pool_photo.bob.go | 678 ---------
db/models/publicreport.quick.bob.go | 235 +--
db/models/publicreport.quick_image.bob.go | 766 ++++++++++
db/models/publicreport.quick_photo.bob.go | 678 ---------
go.mod | 10 +
go.sum | 55 +
public-report/image-upload.go | 182 +++
public-report/photo-upload.go | 59 -
public-report/pool.go | 34 +-
public-report/quick.go | 41 +-
userfile/userfile.go | 10 +-
43 files changed, 7208 insertions(+), 3094 deletions(-)
create mode 100644 db/dberrors/publicreport.image.bob.go
create mode 100644 db/dberrors/publicreport.image_exif.bob.go
create mode 100644 db/dberrors/publicreport.pool_image.bob.go
delete mode 100644 db/dberrors/publicreport.pool_photo.bob.go
create mode 100644 db/dberrors/publicreport.quick_image.bob.go
delete mode 100644 db/dberrors/publicreport.quick_photo.bob.go
create mode 100644 db/dbinfo/publicreport.image.bob.go
create mode 100644 db/dbinfo/publicreport.image_exif.bob.go
create mode 100644 db/dbinfo/publicreport.pool_image.bob.go
delete mode 100644 db/dbinfo/publicreport.pool_photo.bob.go
create mode 100644 db/dbinfo/publicreport.quick_image.bob.go
delete mode 100644 db/dbinfo/publicreport.quick_photo.bob.go
create mode 100644 db/factory/publicreport.image.bob.go
create mode 100644 db/factory/publicreport.image_exif.bob.go
create mode 100644 db/factory/publicreport.pool_image.bob.go
delete mode 100644 db/factory/publicreport.pool_photo.bob.go
create mode 100644 db/factory/publicreport.quick_image.bob.go
delete mode 100644 db/factory/publicreport.quick_photo.bob.go
create mode 100644 db/migrations/00035_photo_content_type.sql
create mode 100644 db/models/publicreport.image.bob.go
create mode 100644 db/models/publicreport.image_exif.bob.go
create mode 100644 db/models/publicreport.pool_image.bob.go
delete mode 100644 db/models/publicreport.pool_photo.bob.go
create mode 100644 db/models/publicreport.quick_image.bob.go
delete mode 100644 db/models/publicreport.quick_photo.bob.go
create mode 100644 public-report/image-upload.go
delete mode 100644 public-report/photo-upload.go
diff --git a/background/arcgis.go b/background/arcgis.go
index 901fda63..d53177da 100644
--- a/background/arcgis.go
+++ b/background/arcgis.go
@@ -338,6 +338,10 @@ func updatePortalData(ctx context.Context, client *arcgis.ArcGIS, user_id int32)
}
tx, err := db.PGInstance.BobDB.BeginTx(ctx, nil)
+ if err != nil {
+ return nil, fmt.Errorf("Failed to create transaction: %w", err)
+ }
+
_, err = models.ArcgisUserPrivileges.Delete(
dm.Where(
models.ArcgisUserPrivileges.Columns.UserID.EQ(psql.Arg(p.User.ID)),
diff --git a/db/dberrors/publicreport.image.bob.go b/db/dberrors/publicreport.image.bob.go
new file mode 100644
index 00000000..4986333c
--- /dev/null
+++ b/db/dberrors/publicreport.image.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var PublicreportImageErrors = &publicreportImageErrors{
+ ErrUniqueImagePkey: &UniqueConstraintError{
+ schema: "publicreport",
+ table: "image",
+ columns: []string{"id"},
+ s: "image_pkey",
+ },
+}
+
+type publicreportImageErrors struct {
+ ErrUniqueImagePkey *UniqueConstraintError
+}
diff --git a/db/dberrors/publicreport.image_exif.bob.go b/db/dberrors/publicreport.image_exif.bob.go
new file mode 100644
index 00000000..28ab3ada
--- /dev/null
+++ b/db/dberrors/publicreport.image_exif.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var PublicreportImageExifErrors = &publicreportImageExifErrors{
+ ErrUniqueImageExifPkey: &UniqueConstraintError{
+ schema: "publicreport",
+ table: "image_exif",
+ columns: []string{"image_id", "name", "value"},
+ s: "image_exif_pkey",
+ },
+}
+
+type publicreportImageExifErrors struct {
+ ErrUniqueImageExifPkey *UniqueConstraintError
+}
diff --git a/db/dberrors/publicreport.pool_image.bob.go b/db/dberrors/publicreport.pool_image.bob.go
new file mode 100644
index 00000000..5317ef9f
--- /dev/null
+++ b/db/dberrors/publicreport.pool_image.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var PublicreportPoolImageErrors = &publicreportPoolImageErrors{
+ ErrUniquePoolImagePkey: &UniqueConstraintError{
+ schema: "publicreport",
+ table: "pool_image",
+ columns: []string{"image_id", "pool_id"},
+ s: "pool_image_pkey",
+ },
+}
+
+type publicreportPoolImageErrors struct {
+ ErrUniquePoolImagePkey *UniqueConstraintError
+}
diff --git a/db/dberrors/publicreport.pool_photo.bob.go b/db/dberrors/publicreport.pool_photo.bob.go
deleted file mode 100644
index 0a5310e6..00000000
--- a/db/dberrors/publicreport.pool_photo.bob.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package dberrors
-
-var PublicreportPoolPhotoErrors = &publicreportPoolPhotoErrors{
- ErrUniquePoolPhotoPkey: &UniqueConstraintError{
- schema: "publicreport",
- table: "pool_photo",
- columns: []string{"id"},
- s: "pool_photo_pkey",
- },
-}
-
-type publicreportPoolPhotoErrors struct {
- ErrUniquePoolPhotoPkey *UniqueConstraintError
-}
diff --git a/db/dberrors/publicreport.quick_image.bob.go b/db/dberrors/publicreport.quick_image.bob.go
new file mode 100644
index 00000000..d0bb4097
--- /dev/null
+++ b/db/dberrors/publicreport.quick_image.bob.go
@@ -0,0 +1,17 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dberrors
+
+var PublicreportQuickImageErrors = &publicreportQuickImageErrors{
+ ErrUniqueQuickImagePkey: &UniqueConstraintError{
+ schema: "publicreport",
+ table: "quick_image",
+ columns: []string{"image_id", "quick_id"},
+ s: "quick_image_pkey",
+ },
+}
+
+type publicreportQuickImageErrors struct {
+ ErrUniqueQuickImagePkey *UniqueConstraintError
+}
diff --git a/db/dberrors/publicreport.quick_photo.bob.go b/db/dberrors/publicreport.quick_photo.bob.go
deleted file mode 100644
index 4dd54714..00000000
--- a/db/dberrors/publicreport.quick_photo.bob.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package dberrors
-
-var PublicreportQuickPhotoErrors = &publicreportQuickPhotoErrors{
- ErrUniqueQuickPhotoPkey: &UniqueConstraintError{
- schema: "publicreport",
- table: "quick_photo",
- columns: []string{"id"},
- s: "quick_photo_pkey",
- },
-}
-
-type publicreportQuickPhotoErrors struct {
- ErrUniqueQuickPhotoPkey *UniqueConstraintError
-}
diff --git a/db/dbinfo/publicreport.image.bob.go b/db/dbinfo/publicreport.image.bob.go
new file mode 100644
index 00000000..aca07c41
--- /dev/null
+++ b/db/dbinfo/publicreport.image.bob.go
@@ -0,0 +1,162 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var PublicreportImages = Table[
+ publicreportImageColumns,
+ publicreportImageIndexes,
+ publicreportImageForeignKeys,
+ publicreportImageUniques,
+ publicreportImageChecks,
+]{
+ Schema: "publicreport",
+ Name: "image",
+ Columns: publicreportImageColumns{
+ ID: column{
+ Name: "id",
+ DBType: "integer",
+ Default: "nextval('publicreport.image_id_seq'::regclass)",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ ContentType: column{
+ Name: "content_type",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Created: column{
+ Name: "created",
+ DBType: "timestamp without time zone",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ ResolutionX: column{
+ Name: "resolution_x",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ ResolutionY: column{
+ Name: "resolution_y",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ StorageUUID: column{
+ Name: "storage_uuid",
+ DBType: "uuid",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ StorageSize: column{
+ Name: "storage_size",
+ DBType: "bigint",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ UploadedFilename: column{
+ Name: "uploaded_filename",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: publicreportImageIndexes{
+ ImagePkey: index{
+ Type: "btree",
+ Name: "image_pkey",
+ Columns: []indexColumn{
+ {
+ Name: "id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "image_pkey",
+ Columns: []string{"id"},
+ Comment: "",
+ },
+
+ Comment: "",
+}
+
+type publicreportImageColumns struct {
+ ID column
+ ContentType column
+ Created column
+ ResolutionX column
+ ResolutionY column
+ StorageUUID column
+ StorageSize column
+ UploadedFilename column
+}
+
+func (c publicreportImageColumns) AsSlice() []column {
+ return []column{
+ c.ID, c.ContentType, c.Created, c.ResolutionX, c.ResolutionY, c.StorageUUID, c.StorageSize, c.UploadedFilename,
+ }
+}
+
+type publicreportImageIndexes struct {
+ ImagePkey index
+}
+
+func (i publicreportImageIndexes) AsSlice() []index {
+ return []index{
+ i.ImagePkey,
+ }
+}
+
+type publicreportImageForeignKeys struct{}
+
+func (f publicreportImageForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{}
+}
+
+type publicreportImageUniques struct{}
+
+func (u publicreportImageUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type publicreportImageChecks struct{}
+
+func (c publicreportImageChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/publicreport.image_exif.bob.go b/db/dbinfo/publicreport.image_exif.bob.go
new file mode 100644
index 00000000..97aa27b7
--- /dev/null
+++ b/db/dbinfo/publicreport.image_exif.bob.go
@@ -0,0 +1,137 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var PublicreportImageExifs = Table[
+ publicreportImageExifColumns,
+ publicreportImageExifIndexes,
+ publicreportImageExifForeignKeys,
+ publicreportImageExifUniques,
+ publicreportImageExifChecks,
+]{
+ Schema: "publicreport",
+ Name: "image_exif",
+ Columns: publicreportImageExifColumns{
+ ImageID: column{
+ Name: "image_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Name: column{
+ Name: "name",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ Value: column{
+ Name: "value",
+ DBType: "text",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: publicreportImageExifIndexes{
+ ImageExifPkey: index{
+ Type: "btree",
+ Name: "image_exif_pkey",
+ Columns: []indexColumn{
+ {
+ Name: "image_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ {
+ Name: "name",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ {
+ Name: "value",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false, false, false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "image_exif_pkey",
+ Columns: []string{"image_id", "name", "value"},
+ Comment: "",
+ },
+ ForeignKeys: publicreportImageExifForeignKeys{
+ PublicreportImageExifImageExifImageIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "publicreport.image_exif.image_exif_image_id_fkey",
+ Columns: []string{"image_id"},
+ Comment: "",
+ },
+ ForeignTable: "publicreport.image",
+ ForeignColumns: []string{"id"},
+ },
+ },
+
+ Comment: "",
+}
+
+type publicreportImageExifColumns struct {
+ ImageID column
+ Name column
+ Value column
+}
+
+func (c publicreportImageExifColumns) AsSlice() []column {
+ return []column{
+ c.ImageID, c.Name, c.Value,
+ }
+}
+
+type publicreportImageExifIndexes struct {
+ ImageExifPkey index
+}
+
+func (i publicreportImageExifIndexes) AsSlice() []index {
+ return []index{
+ i.ImageExifPkey,
+ }
+}
+
+type publicreportImageExifForeignKeys struct {
+ PublicreportImageExifImageExifImageIDFkey foreignKey
+}
+
+func (f publicreportImageExifForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.PublicreportImageExifImageExifImageIDFkey,
+ }
+}
+
+type publicreportImageExifUniques struct{}
+
+func (u publicreportImageExifUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type publicreportImageExifChecks struct{}
+
+func (c publicreportImageExifChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/publicreport.pool_image.bob.go b/db/dbinfo/publicreport.pool_image.bob.go
new file mode 100644
index 00000000..cb44e9b9
--- /dev/null
+++ b/db/dbinfo/publicreport.pool_image.bob.go
@@ -0,0 +1,132 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var PublicreportPoolImages = Table[
+ publicreportPoolImageColumns,
+ publicreportPoolImageIndexes,
+ publicreportPoolImageForeignKeys,
+ publicreportPoolImageUniques,
+ publicreportPoolImageChecks,
+]{
+ Schema: "publicreport",
+ Name: "pool_image",
+ Columns: publicreportPoolImageColumns{
+ ImageID: column{
+ Name: "image_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ PoolID: column{
+ Name: "pool_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: publicreportPoolImageIndexes{
+ PoolImagePkey: index{
+ Type: "btree",
+ Name: "pool_image_pkey",
+ Columns: []indexColumn{
+ {
+ Name: "image_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ {
+ Name: "pool_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false, false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "pool_image_pkey",
+ Columns: []string{"image_id", "pool_id"},
+ Comment: "",
+ },
+ ForeignKeys: publicreportPoolImageForeignKeys{
+ PublicreportPoolImagePoolImageImageIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "publicreport.pool_image.pool_image_image_id_fkey",
+ Columns: []string{"image_id"},
+ Comment: "",
+ },
+ ForeignTable: "publicreport.image",
+ ForeignColumns: []string{"id"},
+ },
+ PublicreportPoolImagePoolImagePoolIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "publicreport.pool_image.pool_image_pool_id_fkey",
+ Columns: []string{"pool_id"},
+ Comment: "",
+ },
+ ForeignTable: "publicreport.pool",
+ ForeignColumns: []string{"id"},
+ },
+ },
+
+ Comment: "",
+}
+
+type publicreportPoolImageColumns struct {
+ ImageID column
+ PoolID column
+}
+
+func (c publicreportPoolImageColumns) AsSlice() []column {
+ return []column{
+ c.ImageID, c.PoolID,
+ }
+}
+
+type publicreportPoolImageIndexes struct {
+ PoolImagePkey index
+}
+
+func (i publicreportPoolImageIndexes) AsSlice() []index {
+ return []index{
+ i.PoolImagePkey,
+ }
+}
+
+type publicreportPoolImageForeignKeys struct {
+ PublicreportPoolImagePoolImageImageIDFkey foreignKey
+ PublicreportPoolImagePoolImagePoolIDFkey foreignKey
+}
+
+func (f publicreportPoolImageForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.PublicreportPoolImagePoolImageImageIDFkey, f.PublicreportPoolImagePoolImagePoolIDFkey,
+ }
+}
+
+type publicreportPoolImageUniques struct{}
+
+func (u publicreportPoolImageUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type publicreportPoolImageChecks struct{}
+
+func (c publicreportPoolImageChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/publicreport.pool_photo.bob.go b/db/dbinfo/publicreport.pool_photo.bob.go
deleted file mode 100644
index 8b116463..00000000
--- a/db/dbinfo/publicreport.pool_photo.bob.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package dbinfo
-
-import "github.com/aarondl/opt/null"
-
-var PublicreportPoolPhotos = Table[
- publicreportPoolPhotoColumns,
- publicreportPoolPhotoIndexes,
- publicreportPoolPhotoForeignKeys,
- publicreportPoolPhotoUniques,
- publicreportPoolPhotoChecks,
-]{
- Schema: "publicreport",
- Name: "pool_photo",
- Columns: publicreportPoolPhotoColumns{
- ID: column{
- Name: "id",
- DBType: "integer",
- Default: "nextval('publicreport.pool_photo_id_seq'::regclass)",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- Size: column{
- Name: "size",
- DBType: "bigint",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- Filename: column{
- Name: "filename",
- DBType: "text",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- PoolID: column{
- Name: "pool_id",
- DBType: "integer",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- UUID: column{
- Name: "uuid",
- DBType: "uuid",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- },
- Indexes: publicreportPoolPhotoIndexes{
- PoolPhotoPkey: index{
- Type: "btree",
- Name: "pool_photo_pkey",
- Columns: []indexColumn{
- {
- Name: "id",
- Desc: null.FromCond(false, true),
- IsExpression: false,
- },
- },
- Unique: true,
- Comment: "",
- NullsFirst: []bool{false},
- NullsDistinct: false,
- Where: "",
- Include: []string{},
- },
- },
- PrimaryKey: &constraint{
- Name: "pool_photo_pkey",
- Columns: []string{"id"},
- Comment: "",
- },
- ForeignKeys: publicreportPoolPhotoForeignKeys{
- PublicreportPoolPhotoPoolPhotoPoolIDFkey: foreignKey{
- constraint: constraint{
- Name: "publicreport.pool_photo.pool_photo_pool_id_fkey",
- Columns: []string{"pool_id"},
- Comment: "",
- },
- ForeignTable: "publicreport.pool",
- ForeignColumns: []string{"id"},
- },
- },
-
- Comment: "",
-}
-
-type publicreportPoolPhotoColumns struct {
- ID column
- Size column
- Filename column
- PoolID column
- UUID column
-}
-
-func (c publicreportPoolPhotoColumns) AsSlice() []column {
- return []column{
- c.ID, c.Size, c.Filename, c.PoolID, c.UUID,
- }
-}
-
-type publicreportPoolPhotoIndexes struct {
- PoolPhotoPkey index
-}
-
-func (i publicreportPoolPhotoIndexes) AsSlice() []index {
- return []index{
- i.PoolPhotoPkey,
- }
-}
-
-type publicreportPoolPhotoForeignKeys struct {
- PublicreportPoolPhotoPoolPhotoPoolIDFkey foreignKey
-}
-
-func (f publicreportPoolPhotoForeignKeys) AsSlice() []foreignKey {
- return []foreignKey{
- f.PublicreportPoolPhotoPoolPhotoPoolIDFkey,
- }
-}
-
-type publicreportPoolPhotoUniques struct{}
-
-func (u publicreportPoolPhotoUniques) AsSlice() []constraint {
- return []constraint{}
-}
-
-type publicreportPoolPhotoChecks struct{}
-
-func (c publicreportPoolPhotoChecks) AsSlice() []check {
- return []check{}
-}
diff --git a/db/dbinfo/publicreport.quick_image.bob.go b/db/dbinfo/publicreport.quick_image.bob.go
new file mode 100644
index 00000000..d311615b
--- /dev/null
+++ b/db/dbinfo/publicreport.quick_image.bob.go
@@ -0,0 +1,132 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package dbinfo
+
+import "github.com/aarondl/opt/null"
+
+var PublicreportQuickImages = Table[
+ publicreportQuickImageColumns,
+ publicreportQuickImageIndexes,
+ publicreportQuickImageForeignKeys,
+ publicreportQuickImageUniques,
+ publicreportQuickImageChecks,
+]{
+ Schema: "publicreport",
+ Name: "quick_image",
+ Columns: publicreportQuickImageColumns{
+ ImageID: column{
+ Name: "image_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ QuickID: column{
+ Name: "quick_id",
+ DBType: "integer",
+ Default: "",
+ Comment: "",
+ Nullable: false,
+ Generated: false,
+ AutoIncr: false,
+ },
+ },
+ Indexes: publicreportQuickImageIndexes{
+ QuickImagePkey: index{
+ Type: "btree",
+ Name: "quick_image_pkey",
+ Columns: []indexColumn{
+ {
+ Name: "image_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ {
+ Name: "quick_id",
+ Desc: null.FromCond(false, true),
+ IsExpression: false,
+ },
+ },
+ Unique: true,
+ Comment: "",
+ NullsFirst: []bool{false, false},
+ NullsDistinct: false,
+ Where: "",
+ Include: []string{},
+ },
+ },
+ PrimaryKey: &constraint{
+ Name: "quick_image_pkey",
+ Columns: []string{"image_id", "quick_id"},
+ Comment: "",
+ },
+ ForeignKeys: publicreportQuickImageForeignKeys{
+ PublicreportQuickImageQuickImageImageIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "publicreport.quick_image.quick_image_image_id_fkey",
+ Columns: []string{"image_id"},
+ Comment: "",
+ },
+ ForeignTable: "publicreport.image",
+ ForeignColumns: []string{"id"},
+ },
+ PublicreportQuickImageQuickImageQuickIDFkey: foreignKey{
+ constraint: constraint{
+ Name: "publicreport.quick_image.quick_image_quick_id_fkey",
+ Columns: []string{"quick_id"},
+ Comment: "",
+ },
+ ForeignTable: "publicreport.quick",
+ ForeignColumns: []string{"id"},
+ },
+ },
+
+ Comment: "",
+}
+
+type publicreportQuickImageColumns struct {
+ ImageID column
+ QuickID column
+}
+
+func (c publicreportQuickImageColumns) AsSlice() []column {
+ return []column{
+ c.ImageID, c.QuickID,
+ }
+}
+
+type publicreportQuickImageIndexes struct {
+ QuickImagePkey index
+}
+
+func (i publicreportQuickImageIndexes) AsSlice() []index {
+ return []index{
+ i.QuickImagePkey,
+ }
+}
+
+type publicreportQuickImageForeignKeys struct {
+ PublicreportQuickImageQuickImageImageIDFkey foreignKey
+ PublicreportQuickImageQuickImageQuickIDFkey foreignKey
+}
+
+func (f publicreportQuickImageForeignKeys) AsSlice() []foreignKey {
+ return []foreignKey{
+ f.PublicreportQuickImageQuickImageImageIDFkey, f.PublicreportQuickImageQuickImageQuickIDFkey,
+ }
+}
+
+type publicreportQuickImageUniques struct{}
+
+func (u publicreportQuickImageUniques) AsSlice() []constraint {
+ return []constraint{}
+}
+
+type publicreportQuickImageChecks struct{}
+
+func (c publicreportQuickImageChecks) AsSlice() []check {
+ return []check{}
+}
diff --git a/db/dbinfo/publicreport.quick_photo.bob.go b/db/dbinfo/publicreport.quick_photo.bob.go
deleted file mode 100644
index f827d142..00000000
--- a/db/dbinfo/publicreport.quick_photo.bob.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package dbinfo
-
-import "github.com/aarondl/opt/null"
-
-var PublicreportQuickPhotos = Table[
- publicreportQuickPhotoColumns,
- publicreportQuickPhotoIndexes,
- publicreportQuickPhotoForeignKeys,
- publicreportQuickPhotoUniques,
- publicreportQuickPhotoChecks,
-]{
- Schema: "publicreport",
- Name: "quick_photo",
- Columns: publicreportQuickPhotoColumns{
- ID: column{
- Name: "id",
- DBType: "integer",
- Default: "nextval('publicreport.quick_photo_id_seq'::regclass)",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- Size: column{
- Name: "size",
- DBType: "bigint",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- Filename: column{
- Name: "filename",
- DBType: "text",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- QuickID: column{
- Name: "quick_id",
- DBType: "integer",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- UUID: column{
- Name: "uuid",
- DBType: "uuid",
- Default: "",
- Comment: "",
- Nullable: false,
- Generated: false,
- AutoIncr: false,
- },
- },
- Indexes: publicreportQuickPhotoIndexes{
- QuickPhotoPkey: index{
- Type: "btree",
- Name: "quick_photo_pkey",
- Columns: []indexColumn{
- {
- Name: "id",
- Desc: null.FromCond(false, true),
- IsExpression: false,
- },
- },
- Unique: true,
- Comment: "",
- NullsFirst: []bool{false},
- NullsDistinct: false,
- Where: "",
- Include: []string{},
- },
- },
- PrimaryKey: &constraint{
- Name: "quick_photo_pkey",
- Columns: []string{"id"},
- Comment: "",
- },
- ForeignKeys: publicreportQuickPhotoForeignKeys{
- PublicreportQuickPhotoQuickPhotoQuickIDFkey: foreignKey{
- constraint: constraint{
- Name: "publicreport.quick_photo.quick_photo_quick_id_fkey",
- Columns: []string{"quick_id"},
- Comment: "",
- },
- ForeignTable: "publicreport.quick",
- ForeignColumns: []string{"id"},
- },
- },
-
- Comment: "",
-}
-
-type publicreportQuickPhotoColumns struct {
- ID column
- Size column
- Filename column
- QuickID column
- UUID column
-}
-
-func (c publicreportQuickPhotoColumns) AsSlice() []column {
- return []column{
- c.ID, c.Size, c.Filename, c.QuickID, c.UUID,
- }
-}
-
-type publicreportQuickPhotoIndexes struct {
- QuickPhotoPkey index
-}
-
-func (i publicreportQuickPhotoIndexes) AsSlice() []index {
- return []index{
- i.QuickPhotoPkey,
- }
-}
-
-type publicreportQuickPhotoForeignKeys struct {
- PublicreportQuickPhotoQuickPhotoQuickIDFkey foreignKey
-}
-
-func (f publicreportQuickPhotoForeignKeys) AsSlice() []foreignKey {
- return []foreignKey{
- f.PublicreportQuickPhotoQuickPhotoQuickIDFkey,
- }
-}
-
-type publicreportQuickPhotoUniques struct{}
-
-func (u publicreportQuickPhotoUniques) AsSlice() []constraint {
- return []constraint{}
-}
-
-type publicreportQuickPhotoChecks struct{}
-
-func (c publicreportQuickPhotoChecks) AsSlice() []check {
- return []check{}
-}
diff --git a/db/factory/bobfactory_context.bob.go b/db/factory/bobfactory_context.bob.go
index 289d2646..7e9c7a84 100644
--- a/db/factory/bobfactory_context.bob.go
+++ b/db/factory/bobfactory_context.bob.go
@@ -222,24 +222,36 @@ var (
organizationRelImportDistrictGidDistrictCtx = newContextual[bool]("import.district.organization.organization.organization_import_district_gid_fkey")
organizationRelUserCtx = newContextual[bool]("organization.user_.user_.user__organization_id_fkey")
+ // Relationship Contexts for publicreport.image
+ publicreportImageWithParentsCascadingCtx = newContextual[bool]("publicreportImageWithParentsCascading")
+ publicreportImageRelImageExifsCtx = newContextual[bool]("publicreport.image.publicreport.image_exif.publicreport.image_exif.image_exif_image_id_fkey")
+ publicreportImageRelPoolsCtx = newContextual[bool]("publicreport.image.publicreport.pool.publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey")
+ publicreportImageRelQuicksCtx = newContextual[bool]("publicreport.image.publicreport.quick.publicreport.quick_image.quick_image_image_id_fkeypublicreport.quick_image.quick_image_quick_id_fkey")
+
+ // Relationship Contexts for publicreport.image_exif
+ publicreportImageExifWithParentsCascadingCtx = newContextual[bool]("publicreportImageExifWithParentsCascading")
+ publicreportImageExifRelImageCtx = newContextual[bool]("publicreport.image.publicreport.image_exif.publicreport.image_exif.image_exif_image_id_fkey")
+
// Relationship Contexts for publicreport.nuisance
publicreportNuisanceWithParentsCascadingCtx = newContextual[bool]("publicreportNuisanceWithParentsCascading")
// Relationship Contexts for publicreport.pool
publicreportPoolWithParentsCascadingCtx = newContextual[bool]("publicreportPoolWithParentsCascading")
- publicreportPoolRelPoolPhotosCtx = newContextual[bool]("publicreport.pool.publicreport.pool_photo.publicreport.pool_photo.pool_photo_pool_id_fkey")
+ publicreportPoolRelImagesCtx = newContextual[bool]("publicreport.image.publicreport.pool.publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey")
- // Relationship Contexts for publicreport.pool_photo
- publicreportPoolPhotoWithParentsCascadingCtx = newContextual[bool]("publicreportPoolPhotoWithParentsCascading")
- publicreportPoolPhotoRelPoolCtx = newContextual[bool]("publicreport.pool.publicreport.pool_photo.publicreport.pool_photo.pool_photo_pool_id_fkey")
+ // Relationship Contexts for publicreport.pool_image
+ publicreportPoolImageWithParentsCascadingCtx = newContextual[bool]("publicreportPoolImageWithParentsCascading")
+ publicreportPoolImageRelImageCtx = newContextual[bool]("publicreport.image.publicreport.pool_image.publicreport.pool_image.pool_image_image_id_fkey")
+ publicreportPoolImageRelPoolCtx = newContextual[bool]("publicreport.pool.publicreport.pool_image.publicreport.pool_image.pool_image_pool_id_fkey")
// Relationship Contexts for publicreport.quick
publicreportQuickWithParentsCascadingCtx = newContextual[bool]("publicreportQuickWithParentsCascading")
- publicreportQuickRelQuickPhotosCtx = newContextual[bool]("publicreport.quick.publicreport.quick_photo.publicreport.quick_photo.quick_photo_quick_id_fkey")
+ publicreportQuickRelImagesCtx = newContextual[bool]("publicreport.image.publicreport.quick.publicreport.quick_image.quick_image_image_id_fkeypublicreport.quick_image.quick_image_quick_id_fkey")
- // Relationship Contexts for publicreport.quick_photo
- publicreportQuickPhotoWithParentsCascadingCtx = newContextual[bool]("publicreportQuickPhotoWithParentsCascading")
- publicreportQuickPhotoRelQuickCtx = newContextual[bool]("publicreport.quick.publicreport.quick_photo.publicreport.quick_photo.quick_photo_quick_id_fkey")
+ // Relationship Contexts for publicreport.quick_image
+ publicreportQuickImageWithParentsCascadingCtx = newContextual[bool]("publicreportQuickImageWithParentsCascading")
+ publicreportQuickImageRelImageCtx = newContextual[bool]("publicreport.image.publicreport.quick_image.publicreport.quick_image.quick_image_image_id_fkey")
+ publicreportQuickImageRelQuickCtx = newContextual[bool]("publicreport.quick.publicreport.quick_image.publicreport.quick_image.quick_image_quick_id_fkey")
// Relationship Contexts for publicreport.report_location
publicreportReportLocationWithParentsCascadingCtx = newContextual[bool]("publicreportReportLocationWithParentsCascading")
diff --git a/db/factory/bobfactory_main.bob.go b/db/factory/bobfactory_main.bob.go
index eadbf506..d184b64e 100644
--- a/db/factory/bobfactory_main.bob.go
+++ b/db/factory/bobfactory_main.bob.go
@@ -62,11 +62,13 @@ type Factory struct {
baseNotificationMods NotificationModSlice
baseOauthTokenMods OauthTokenModSlice
baseOrganizationMods OrganizationModSlice
+ basePublicreportImageMods PublicreportImageModSlice
+ basePublicreportImageExifMods PublicreportImageExifModSlice
basePublicreportNuisanceMods PublicreportNuisanceModSlice
basePublicreportPoolMods PublicreportPoolModSlice
- basePublicreportPoolPhotoMods PublicreportPoolPhotoModSlice
+ basePublicreportPoolImageMods PublicreportPoolImageModSlice
basePublicreportQuickMods PublicreportQuickModSlice
- basePublicreportQuickPhotoMods PublicreportQuickPhotoModSlice
+ basePublicreportQuickImageMods PublicreportQuickImageModSlice
basePublicreportReportLocationMods PublicreportReportLocationModSlice
baseRasterColumnMods RasterColumnModSlice
baseRasterOverviewMods RasterOverviewModSlice
@@ -2512,6 +2514,79 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
return o
}
+func (f *Factory) NewPublicreportImage(mods ...PublicreportImageMod) *PublicreportImageTemplate {
+ return f.NewPublicreportImageWithContext(context.Background(), mods...)
+}
+
+func (f *Factory) NewPublicreportImageWithContext(ctx context.Context, mods ...PublicreportImageMod) *PublicreportImageTemplate {
+ o := &PublicreportImageTemplate{f: f}
+
+ if f != nil {
+ f.basePublicreportImageMods.Apply(ctx, o)
+ }
+
+ PublicreportImageModSlice(mods).Apply(ctx, o)
+
+ return o
+}
+
+func (f *Factory) FromExistingPublicreportImage(m *models.PublicreportImage) *PublicreportImageTemplate {
+ o := &PublicreportImageTemplate{f: f, alreadyPersisted: true}
+
+ o.ID = func() int32 { return m.ID }
+ o.ContentType = func() string { return m.ContentType }
+ o.Created = func() time.Time { return m.Created }
+ o.ResolutionX = func() int32 { return m.ResolutionX }
+ o.ResolutionY = func() int32 { return m.ResolutionY }
+ o.StorageUUID = func() uuid.UUID { return m.StorageUUID }
+ o.StorageSize = func() int64 { return m.StorageSize }
+ o.UploadedFilename = func() string { return m.UploadedFilename }
+
+ ctx := context.Background()
+ if len(m.R.ImageExifs) > 0 {
+ PublicreportImageMods.AddExistingImageExifs(m.R.ImageExifs...).Apply(ctx, o)
+ }
+ if len(m.R.Pools) > 0 {
+ PublicreportImageMods.AddExistingPools(m.R.Pools...).Apply(ctx, o)
+ }
+ if len(m.R.Quicks) > 0 {
+ PublicreportImageMods.AddExistingQuicks(m.R.Quicks...).Apply(ctx, o)
+ }
+
+ return o
+}
+
+func (f *Factory) NewPublicreportImageExif(mods ...PublicreportImageExifMod) *PublicreportImageExifTemplate {
+ return f.NewPublicreportImageExifWithContext(context.Background(), mods...)
+}
+
+func (f *Factory) NewPublicreportImageExifWithContext(ctx context.Context, mods ...PublicreportImageExifMod) *PublicreportImageExifTemplate {
+ o := &PublicreportImageExifTemplate{f: f}
+
+ if f != nil {
+ f.basePublicreportImageExifMods.Apply(ctx, o)
+ }
+
+ PublicreportImageExifModSlice(mods).Apply(ctx, o)
+
+ return o
+}
+
+func (f *Factory) FromExistingPublicreportImageExif(m *models.PublicreportImageExif) *PublicreportImageExifTemplate {
+ o := &PublicreportImageExifTemplate{f: f, alreadyPersisted: true}
+
+ o.ImageID = func() int32 { return m.ImageID }
+ o.Name = func() string { return m.Name }
+ o.Value = func() string { return m.Value }
+
+ ctx := context.Background()
+ if m.R.Image != nil {
+ PublicreportImageExifMods.WithExistingImage(m.R.Image).Apply(ctx, o)
+ }
+
+ return o
+}
+
func (f *Factory) NewPublicreportNuisance(mods ...PublicreportNuisanceMod) *PublicreportNuisanceTemplate {
return f.NewPublicreportNuisanceWithContext(context.Background(), mods...)
}
@@ -2613,41 +2688,41 @@ func (f *Factory) FromExistingPublicreportPool(m *models.PublicreportPool) *Publ
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
ctx := context.Background()
- if len(m.R.PoolPhotos) > 0 {
- PublicreportPoolMods.AddExistingPoolPhotos(m.R.PoolPhotos...).Apply(ctx, o)
+ if len(m.R.Images) > 0 {
+ PublicreportPoolMods.AddExistingImages(m.R.Images...).Apply(ctx, o)
}
return o
}
-func (f *Factory) NewPublicreportPoolPhoto(mods ...PublicreportPoolPhotoMod) *PublicreportPoolPhotoTemplate {
- return f.NewPublicreportPoolPhotoWithContext(context.Background(), mods...)
+func (f *Factory) NewPublicreportPoolImage(mods ...PublicreportPoolImageMod) *PublicreportPoolImageTemplate {
+ return f.NewPublicreportPoolImageWithContext(context.Background(), mods...)
}
-func (f *Factory) NewPublicreportPoolPhotoWithContext(ctx context.Context, mods ...PublicreportPoolPhotoMod) *PublicreportPoolPhotoTemplate {
- o := &PublicreportPoolPhotoTemplate{f: f}
+func (f *Factory) NewPublicreportPoolImageWithContext(ctx context.Context, mods ...PublicreportPoolImageMod) *PublicreportPoolImageTemplate {
+ o := &PublicreportPoolImageTemplate{f: f}
if f != nil {
- f.basePublicreportPoolPhotoMods.Apply(ctx, o)
+ f.basePublicreportPoolImageMods.Apply(ctx, o)
}
- PublicreportPoolPhotoModSlice(mods).Apply(ctx, o)
+ PublicreportPoolImageModSlice(mods).Apply(ctx, o)
return o
}
-func (f *Factory) FromExistingPublicreportPoolPhoto(m *models.PublicreportPoolPhoto) *PublicreportPoolPhotoTemplate {
- o := &PublicreportPoolPhotoTemplate{f: f, alreadyPersisted: true}
+func (f *Factory) FromExistingPublicreportPoolImage(m *models.PublicreportPoolImage) *PublicreportPoolImageTemplate {
+ o := &PublicreportPoolImageTemplate{f: f, alreadyPersisted: true}
- o.ID = func() int32 { return m.ID }
- o.Size = func() int64 { return m.Size }
- o.Filename = func() string { return m.Filename }
+ o.ImageID = func() int32 { return m.ImageID }
o.PoolID = func() int32 { return m.PoolID }
- o.UUID = func() uuid.UUID { return m.UUID }
ctx := context.Background()
+ if m.R.Image != nil {
+ PublicreportPoolImageMods.WithExistingImage(m.R.Image).Apply(ctx, o)
+ }
if m.R.Pool != nil {
- PublicreportPoolPhotoMods.WithExistingPool(m.R.Pool).Apply(ctx, o)
+ PublicreportPoolImageMods.WithExistingPool(m.R.Pool).Apply(ctx, o)
}
return o
@@ -2684,41 +2759,41 @@ func (f *Factory) FromExistingPublicreportQuick(m *models.PublicreportQuick) *Pu
o.Status = func() enums.PublicreportReportstatustype { return m.Status }
ctx := context.Background()
- if len(m.R.QuickPhotos) > 0 {
- PublicreportQuickMods.AddExistingQuickPhotos(m.R.QuickPhotos...).Apply(ctx, o)
+ if len(m.R.Images) > 0 {
+ PublicreportQuickMods.AddExistingImages(m.R.Images...).Apply(ctx, o)
}
return o
}
-func (f *Factory) NewPublicreportQuickPhoto(mods ...PublicreportQuickPhotoMod) *PublicreportQuickPhotoTemplate {
- return f.NewPublicreportQuickPhotoWithContext(context.Background(), mods...)
+func (f *Factory) NewPublicreportQuickImage(mods ...PublicreportQuickImageMod) *PublicreportQuickImageTemplate {
+ return f.NewPublicreportQuickImageWithContext(context.Background(), mods...)
}
-func (f *Factory) NewPublicreportQuickPhotoWithContext(ctx context.Context, mods ...PublicreportQuickPhotoMod) *PublicreportQuickPhotoTemplate {
- o := &PublicreportQuickPhotoTemplate{f: f}
+func (f *Factory) NewPublicreportQuickImageWithContext(ctx context.Context, mods ...PublicreportQuickImageMod) *PublicreportQuickImageTemplate {
+ o := &PublicreportQuickImageTemplate{f: f}
if f != nil {
- f.basePublicreportQuickPhotoMods.Apply(ctx, o)
+ f.basePublicreportQuickImageMods.Apply(ctx, o)
}
- PublicreportQuickPhotoModSlice(mods).Apply(ctx, o)
+ PublicreportQuickImageModSlice(mods).Apply(ctx, o)
return o
}
-func (f *Factory) FromExistingPublicreportQuickPhoto(m *models.PublicreportQuickPhoto) *PublicreportQuickPhotoTemplate {
- o := &PublicreportQuickPhotoTemplate{f: f, alreadyPersisted: true}
+func (f *Factory) FromExistingPublicreportQuickImage(m *models.PublicreportQuickImage) *PublicreportQuickImageTemplate {
+ o := &PublicreportQuickImageTemplate{f: f, alreadyPersisted: true}
- o.ID = func() int32 { return m.ID }
- o.Size = func() int64 { return m.Size }
- o.Filename = func() string { return m.Filename }
+ o.ImageID = func() int32 { return m.ImageID }
o.QuickID = func() int32 { return m.QuickID }
- o.UUID = func() uuid.UUID { return m.UUID }
ctx := context.Background()
+ if m.R.Image != nil {
+ PublicreportQuickImageMods.WithExistingImage(m.R.Image).Apply(ctx, o)
+ }
if m.R.Quick != nil {
- PublicreportQuickPhotoMods.WithExistingQuick(m.R.Quick).Apply(ctx, o)
+ PublicreportQuickImageMods.WithExistingQuick(m.R.Quick).Apply(ctx, o)
}
return o
@@ -3293,6 +3368,22 @@ func (f *Factory) AddBaseOrganizationMod(mods ...OrganizationMod) {
f.baseOrganizationMods = append(f.baseOrganizationMods, mods...)
}
+func (f *Factory) ClearBasePublicreportImageMods() {
+ f.basePublicreportImageMods = nil
+}
+
+func (f *Factory) AddBasePublicreportImageMod(mods ...PublicreportImageMod) {
+ f.basePublicreportImageMods = append(f.basePublicreportImageMods, mods...)
+}
+
+func (f *Factory) ClearBasePublicreportImageExifMods() {
+ f.basePublicreportImageExifMods = nil
+}
+
+func (f *Factory) AddBasePublicreportImageExifMod(mods ...PublicreportImageExifMod) {
+ f.basePublicreportImageExifMods = append(f.basePublicreportImageExifMods, mods...)
+}
+
func (f *Factory) ClearBasePublicreportNuisanceMods() {
f.basePublicreportNuisanceMods = nil
}
@@ -3309,12 +3400,12 @@ func (f *Factory) AddBasePublicreportPoolMod(mods ...PublicreportPoolMod) {
f.basePublicreportPoolMods = append(f.basePublicreportPoolMods, mods...)
}
-func (f *Factory) ClearBasePublicreportPoolPhotoMods() {
- f.basePublicreportPoolPhotoMods = nil
+func (f *Factory) ClearBasePublicreportPoolImageMods() {
+ f.basePublicreportPoolImageMods = nil
}
-func (f *Factory) AddBasePublicreportPoolPhotoMod(mods ...PublicreportPoolPhotoMod) {
- f.basePublicreportPoolPhotoMods = append(f.basePublicreportPoolPhotoMods, mods...)
+func (f *Factory) AddBasePublicreportPoolImageMod(mods ...PublicreportPoolImageMod) {
+ f.basePublicreportPoolImageMods = append(f.basePublicreportPoolImageMods, mods...)
}
func (f *Factory) ClearBasePublicreportQuickMods() {
@@ -3325,12 +3416,12 @@ func (f *Factory) AddBasePublicreportQuickMod(mods ...PublicreportQuickMod) {
f.basePublicreportQuickMods = append(f.basePublicreportQuickMods, mods...)
}
-func (f *Factory) ClearBasePublicreportQuickPhotoMods() {
- f.basePublicreportQuickPhotoMods = nil
+func (f *Factory) ClearBasePublicreportQuickImageMods() {
+ f.basePublicreportQuickImageMods = nil
}
-func (f *Factory) AddBasePublicreportQuickPhotoMod(mods ...PublicreportQuickPhotoMod) {
- f.basePublicreportQuickPhotoMods = append(f.basePublicreportQuickPhotoMods, mods...)
+func (f *Factory) AddBasePublicreportQuickImageMod(mods ...PublicreportQuickImageMod) {
+ f.basePublicreportQuickImageMods = append(f.basePublicreportQuickImageMods, mods...)
}
func (f *Factory) ClearBasePublicreportReportLocationMods() {
diff --git a/db/factory/publicreport.image.bob.go b/db/factory/publicreport.image.bob.go
new file mode 100644
index 00000000..3d292ad4
--- /dev/null
+++ b/db/factory/publicreport.image.bob.go
@@ -0,0 +1,822 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/google/uuid"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type PublicreportImageMod interface {
+ Apply(context.Context, *PublicreportImageTemplate)
+}
+
+type PublicreportImageModFunc func(context.Context, *PublicreportImageTemplate)
+
+func (f PublicreportImageModFunc) Apply(ctx context.Context, n *PublicreportImageTemplate) {
+ f(ctx, n)
+}
+
+type PublicreportImageModSlice []PublicreportImageMod
+
+func (mods PublicreportImageModSlice) Apply(ctx context.Context, n *PublicreportImageTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// PublicreportImageTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type PublicreportImageTemplate struct {
+ ID func() int32
+ ContentType func() string
+ Created func() time.Time
+ ResolutionX func() int32
+ ResolutionY func() int32
+ StorageUUID func() uuid.UUID
+ StorageSize func() int64
+ UploadedFilename func() string
+
+ r publicreportImageR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type publicreportImageR struct {
+ ImageExifs []*publicreportImageRImageExifsR
+ Pools []*publicreportImageRPoolsR
+ Quicks []*publicreportImageRQuicksR
+}
+
+type publicreportImageRImageExifsR struct {
+ number int
+ o *PublicreportImageExifTemplate
+}
+type publicreportImageRPoolsR struct {
+ number int
+ o *PublicreportPoolTemplate
+}
+type publicreportImageRQuicksR struct {
+ number int
+ o *PublicreportQuickTemplate
+}
+
+// Apply mods to the PublicreportImageTemplate
+func (o *PublicreportImageTemplate) Apply(ctx context.Context, mods ...PublicreportImageMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.PublicreportImage
+// according to the relationships in the template. Nothing is inserted into the db
+func (t PublicreportImageTemplate) setModelRels(o *models.PublicreportImage) {
+ if t.r.ImageExifs != nil {
+ rel := models.PublicreportImageExifSlice{}
+ for _, r := range t.r.ImageExifs {
+ related := r.o.BuildMany(r.number)
+ for _, rel := range related {
+ rel.ImageID = o.ID // h2
+ rel.R.Image = o
+ }
+ rel = append(rel, related...)
+ }
+ o.R.ImageExifs = rel
+ }
+
+ if t.r.Pools != nil {
+ rel := models.PublicreportPoolSlice{}
+ for _, r := range t.r.Pools {
+ related := r.o.BuildMany(r.number)
+ for _, rel := range related {
+ rel.R.Images = append(rel.R.Images, o)
+ }
+ rel = append(rel, related...)
+ }
+ o.R.Pools = rel
+ }
+
+ if t.r.Quicks != nil {
+ rel := models.PublicreportQuickSlice{}
+ for _, r := range t.r.Quicks {
+ related := r.o.BuildMany(r.number)
+ for _, rel := range related {
+ rel.R.Images = append(rel.R.Images, o)
+ }
+ rel = append(rel, related...)
+ }
+ o.R.Quicks = rel
+ }
+}
+
+// BuildSetter returns an *models.PublicreportImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportImageTemplate) BuildSetter() *models.PublicreportImageSetter {
+ m := &models.PublicreportImageSetter{}
+
+ if o.ID != nil {
+ val := o.ID()
+ m.ID = omit.From(val)
+ }
+ if o.ContentType != nil {
+ val := o.ContentType()
+ m.ContentType = omit.From(val)
+ }
+ if o.Created != nil {
+ val := o.Created()
+ m.Created = omit.From(val)
+ }
+ if o.ResolutionX != nil {
+ val := o.ResolutionX()
+ m.ResolutionX = omit.From(val)
+ }
+ if o.ResolutionY != nil {
+ val := o.ResolutionY()
+ m.ResolutionY = omit.From(val)
+ }
+ if o.StorageUUID != nil {
+ val := o.StorageUUID()
+ m.StorageUUID = omit.From(val)
+ }
+ if o.StorageSize != nil {
+ val := o.StorageSize()
+ m.StorageSize = omit.From(val)
+ }
+ if o.UploadedFilename != nil {
+ val := o.UploadedFilename()
+ m.UploadedFilename = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.PublicreportImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportImageTemplate) BuildManySetter(number int) []*models.PublicreportImageSetter {
+ m := make([]*models.PublicreportImageSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.PublicreportImage
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportImageTemplate.Create
+func (o PublicreportImageTemplate) Build() *models.PublicreportImage {
+ m := &models.PublicreportImage{}
+
+ if o.ID != nil {
+ m.ID = o.ID()
+ }
+ if o.ContentType != nil {
+ m.ContentType = o.ContentType()
+ }
+ if o.Created != nil {
+ m.Created = o.Created()
+ }
+ if o.ResolutionX != nil {
+ m.ResolutionX = o.ResolutionX()
+ }
+ if o.ResolutionY != nil {
+ m.ResolutionY = o.ResolutionY()
+ }
+ if o.StorageUUID != nil {
+ m.StorageUUID = o.StorageUUID()
+ }
+ if o.StorageSize != nil {
+ m.StorageSize = o.StorageSize()
+ }
+ if o.UploadedFilename != nil {
+ m.UploadedFilename = o.UploadedFilename()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.PublicreportImageSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportImageTemplate.CreateMany
+func (o PublicreportImageTemplate) BuildMany(number int) models.PublicreportImageSlice {
+ m := make(models.PublicreportImageSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatablePublicreportImage(m *models.PublicreportImageSetter) {
+ if !(m.ContentType.IsValue()) {
+ val := random_string(nil)
+ m.ContentType = omit.From(val)
+ }
+ if !(m.Created.IsValue()) {
+ val := random_time_Time(nil)
+ m.Created = omit.From(val)
+ }
+ if !(m.ResolutionX.IsValue()) {
+ val := random_int32(nil)
+ m.ResolutionX = omit.From(val)
+ }
+ if !(m.ResolutionY.IsValue()) {
+ val := random_int32(nil)
+ m.ResolutionY = omit.From(val)
+ }
+ if !(m.StorageUUID.IsValue()) {
+ val := random_uuid_UUID(nil)
+ m.StorageUUID = omit.From(val)
+ }
+ if !(m.StorageSize.IsValue()) {
+ val := random_int64(nil)
+ m.StorageSize = omit.From(val)
+ }
+ if !(m.UploadedFilename.IsValue()) {
+ val := random_string(nil)
+ m.UploadedFilename = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.PublicreportImage
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *PublicreportImageTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportImage) error {
+ var err error
+
+ isImageExifsDone, _ := publicreportImageRelImageExifsCtx.Value(ctx)
+ if !isImageExifsDone && o.r.ImageExifs != nil {
+ ctx = publicreportImageRelImageExifsCtx.WithValue(ctx, true)
+ for _, r := range o.r.ImageExifs {
+ if r.o.alreadyPersisted {
+ m.R.ImageExifs = append(m.R.ImageExifs, r.o.Build())
+ } else {
+ rel0, err := r.o.CreateMany(ctx, exec, r.number)
+ if err != nil {
+ return err
+ }
+
+ err = m.AttachImageExifs(ctx, exec, rel0...)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+
+ isPoolsDone, _ := publicreportImageRelPoolsCtx.Value(ctx)
+ if !isPoolsDone && o.r.Pools != nil {
+ ctx = publicreportImageRelPoolsCtx.WithValue(ctx, true)
+ for _, r := range o.r.Pools {
+ if r.o.alreadyPersisted {
+ m.R.Pools = append(m.R.Pools, r.o.Build())
+ } else {
+ rel1, err := r.o.CreateMany(ctx, exec, r.number)
+ if err != nil {
+ return err
+ }
+
+ err = m.AttachPools(ctx, exec, rel1...)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+
+ isQuicksDone, _ := publicreportImageRelQuicksCtx.Value(ctx)
+ if !isQuicksDone && o.r.Quicks != nil {
+ ctx = publicreportImageRelQuicksCtx.WithValue(ctx, true)
+ for _, r := range o.r.Quicks {
+ if r.o.alreadyPersisted {
+ m.R.Quicks = append(m.R.Quicks, r.o.Build())
+ } else {
+ rel2, err := r.o.CreateMany(ctx, exec, r.number)
+ if err != nil {
+ return err
+ }
+
+ err = m.AttachQuicks(ctx, exec, rel2...)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ }
+
+ return err
+}
+
+// Create builds a publicreportImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *PublicreportImageTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportImage, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatablePublicreportImage(opt)
+
+ m, err := models.PublicreportImages.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a publicreportImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *PublicreportImageTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportImage {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a publicreportImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *PublicreportImageTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportImage {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple publicreportImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o PublicreportImageTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportImageSlice, error) {
+ var err error
+ m := make(models.PublicreportImageSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple publicreportImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o PublicreportImageTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportImageSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple publicreportImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o PublicreportImageTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportImageSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// PublicreportImage has methods that act as mods for the PublicreportImageTemplate
+var PublicreportImageMods publicreportImageMods
+
+type publicreportImageMods struct{}
+
+func (m publicreportImageMods) RandomizeAllColumns(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModSlice{
+ PublicreportImageMods.RandomID(f),
+ PublicreportImageMods.RandomContentType(f),
+ PublicreportImageMods.RandomCreated(f),
+ PublicreportImageMods.RandomResolutionX(f),
+ PublicreportImageMods.RandomResolutionY(f),
+ PublicreportImageMods.RandomStorageUUID(f),
+ PublicreportImageMods.RandomStorageSize(f),
+ PublicreportImageMods.RandomUploadedFilename(f),
+ }
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) ID(val int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) IDFunc(f func() int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetID() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomID(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) ContentType(val string) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ContentType = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) ContentTypeFunc(f func() string) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ContentType = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetContentType() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ContentType = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomContentType(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ContentType = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) Created(val time.Time) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.Created = func() time.Time { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) CreatedFunc(f func() time.Time) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.Created = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetCreated() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.Created = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomCreated(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.Created = func() time.Time {
+ return random_time_Time(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) ResolutionX(val int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionX = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) ResolutionXFunc(f func() int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionX = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetResolutionX() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionX = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomResolutionX(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionX = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) ResolutionY(val int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionY = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) ResolutionYFunc(f func() int32) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionY = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetResolutionY() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionY = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomResolutionY(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.ResolutionY = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) StorageUUID(val uuid.UUID) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageUUID = func() uuid.UUID { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) StorageUUIDFunc(f func() uuid.UUID) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageUUID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetStorageUUID() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageUUID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomStorageUUID(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageUUID = func() uuid.UUID {
+ return random_uuid_UUID(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) StorageSize(val int64) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageSize = func() int64 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) StorageSizeFunc(f func() int64) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageSize = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetStorageSize() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageSize = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomStorageSize(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.StorageSize = func() int64 {
+ return random_int64(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageMods) UploadedFilename(val string) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.UploadedFilename = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageMods) UploadedFilenameFunc(f func() string) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.UploadedFilename = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageMods) UnsetUploadedFilename() PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.UploadedFilename = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageMods) RandomUploadedFilename(f *faker.Faker) PublicreportImageMod {
+ return PublicreportImageModFunc(func(_ context.Context, o *PublicreportImageTemplate) {
+ o.UploadedFilename = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+func (m publicreportImageMods) WithParentsCascading() PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ if isDone, _ := publicreportImageWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = publicreportImageWithParentsCascadingCtx.WithValue(ctx, true)
+ })
+}
+
+func (m publicreportImageMods) WithImageExifs(number int, related *PublicreportImageExifTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.ImageExifs = []*publicreportImageRImageExifsR{{
+ number: number,
+ o: related,
+ }}
+ })
+}
+
+func (m publicreportImageMods) WithNewImageExifs(number int, mods ...PublicreportImageExifMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportImageExifWithContext(ctx, mods...)
+ m.WithImageExifs(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddImageExifs(number int, related *PublicreportImageExifTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.ImageExifs = append(o.r.ImageExifs, &publicreportImageRImageExifsR{
+ number: number,
+ o: related,
+ })
+ })
+}
+
+func (m publicreportImageMods) AddNewImageExifs(number int, mods ...PublicreportImageExifMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportImageExifWithContext(ctx, mods...)
+ m.AddImageExifs(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddExistingImageExifs(existingModels ...*models.PublicreportImageExif) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ for _, em := range existingModels {
+ o.r.ImageExifs = append(o.r.ImageExifs, &publicreportImageRImageExifsR{
+ o: o.f.FromExistingPublicreportImageExif(em),
+ })
+ }
+ })
+}
+
+func (m publicreportImageMods) WithoutImageExifs() PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.ImageExifs = nil
+ })
+}
+
+func (m publicreportImageMods) WithPools(number int, related *PublicreportPoolTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Pools = []*publicreportImageRPoolsR{{
+ number: number,
+ o: related,
+ }}
+ })
+}
+
+func (m publicreportImageMods) WithNewPools(number int, mods ...PublicreportPoolMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
+ m.WithPools(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddPools(number int, related *PublicreportPoolTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Pools = append(o.r.Pools, &publicreportImageRPoolsR{
+ number: number,
+ o: related,
+ })
+ })
+}
+
+func (m publicreportImageMods) AddNewPools(number int, mods ...PublicreportPoolMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
+ m.AddPools(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddExistingPools(existingModels ...*models.PublicreportPool) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ for _, em := range existingModels {
+ o.r.Pools = append(o.r.Pools, &publicreportImageRPoolsR{
+ o: o.f.FromExistingPublicreportPool(em),
+ })
+ }
+ })
+}
+
+func (m publicreportImageMods) WithoutPools() PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Pools = nil
+ })
+}
+
+func (m publicreportImageMods) WithQuicks(number int, related *PublicreportQuickTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Quicks = []*publicreportImageRQuicksR{{
+ number: number,
+ o: related,
+ }}
+ })
+}
+
+func (m publicreportImageMods) WithNewQuicks(number int, mods ...PublicreportQuickMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
+ m.WithQuicks(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddQuicks(number int, related *PublicreportQuickTemplate) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Quicks = append(o.r.Quicks, &publicreportImageRQuicksR{
+ number: number,
+ o: related,
+ })
+ })
+}
+
+func (m publicreportImageMods) AddNewQuicks(number int, mods ...PublicreportQuickMod) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
+ m.AddQuicks(number, related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageMods) AddExistingQuicks(existingModels ...*models.PublicreportQuick) PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ for _, em := range existingModels {
+ o.r.Quicks = append(o.r.Quicks, &publicreportImageRQuicksR{
+ o: o.f.FromExistingPublicreportQuick(em),
+ })
+ }
+ })
+}
+
+func (m publicreportImageMods) WithoutQuicks() PublicreportImageMod {
+ return PublicreportImageModFunc(func(ctx context.Context, o *PublicreportImageTemplate) {
+ o.r.Quicks = nil
+ })
+}
diff --git a/db/factory/publicreport.image_exif.bob.go b/db/factory/publicreport.image_exif.bob.go
new file mode 100644
index 00000000..742829a4
--- /dev/null
+++ b/db/factory/publicreport.image_exif.bob.go
@@ -0,0 +1,413 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type PublicreportImageExifMod interface {
+ Apply(context.Context, *PublicreportImageExifTemplate)
+}
+
+type PublicreportImageExifModFunc func(context.Context, *PublicreportImageExifTemplate)
+
+func (f PublicreportImageExifModFunc) Apply(ctx context.Context, n *PublicreportImageExifTemplate) {
+ f(ctx, n)
+}
+
+type PublicreportImageExifModSlice []PublicreportImageExifMod
+
+func (mods PublicreportImageExifModSlice) Apply(ctx context.Context, n *PublicreportImageExifTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// PublicreportImageExifTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type PublicreportImageExifTemplate struct {
+ ImageID func() int32
+ Name func() string
+ Value func() string
+
+ r publicreportImageExifR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type publicreportImageExifR struct {
+ Image *publicreportImageExifRImageR
+}
+
+type publicreportImageExifRImageR struct {
+ o *PublicreportImageTemplate
+}
+
+// Apply mods to the PublicreportImageExifTemplate
+func (o *PublicreportImageExifTemplate) Apply(ctx context.Context, mods ...PublicreportImageExifMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.PublicreportImageExif
+// according to the relationships in the template. Nothing is inserted into the db
+func (t PublicreportImageExifTemplate) setModelRels(o *models.PublicreportImageExif) {
+ if t.r.Image != nil {
+ rel := t.r.Image.o.Build()
+ rel.R.ImageExifs = append(rel.R.ImageExifs, o)
+ o.ImageID = rel.ID // h2
+ o.R.Image = rel
+ }
+}
+
+// BuildSetter returns an *models.PublicreportImageExifSetter
+// this does nothing with the relationship templates
+func (o PublicreportImageExifTemplate) BuildSetter() *models.PublicreportImageExifSetter {
+ m := &models.PublicreportImageExifSetter{}
+
+ if o.ImageID != nil {
+ val := o.ImageID()
+ m.ImageID = omit.From(val)
+ }
+ if o.Name != nil {
+ val := o.Name()
+ m.Name = omit.From(val)
+ }
+ if o.Value != nil {
+ val := o.Value()
+ m.Value = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.PublicreportImageExifSetter
+// this does nothing with the relationship templates
+func (o PublicreportImageExifTemplate) BuildManySetter(number int) []*models.PublicreportImageExifSetter {
+ m := make([]*models.PublicreportImageExifSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.PublicreportImageExif
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportImageExifTemplate.Create
+func (o PublicreportImageExifTemplate) Build() *models.PublicreportImageExif {
+ m := &models.PublicreportImageExif{}
+
+ if o.ImageID != nil {
+ m.ImageID = o.ImageID()
+ }
+ if o.Name != nil {
+ m.Name = o.Name()
+ }
+ if o.Value != nil {
+ m.Value = o.Value()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.PublicreportImageExifSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportImageExifTemplate.CreateMany
+func (o PublicreportImageExifTemplate) BuildMany(number int) models.PublicreportImageExifSlice {
+ m := make(models.PublicreportImageExifSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatablePublicreportImageExif(m *models.PublicreportImageExifSetter) {
+ if !(m.ImageID.IsValue()) {
+ val := random_int32(nil)
+ m.ImageID = omit.From(val)
+ }
+ if !(m.Name.IsValue()) {
+ val := random_string(nil)
+ m.Name = omit.From(val)
+ }
+ if !(m.Value.IsValue()) {
+ val := random_string(nil)
+ m.Value = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.PublicreportImageExif
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *PublicreportImageExifTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportImageExif) error {
+ var err error
+
+ return err
+}
+
+// Create builds a publicreportImageExif and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *PublicreportImageExifTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportImageExif, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatablePublicreportImageExif(opt)
+
+ if o.r.Image == nil {
+ PublicreportImageExifMods.WithNewImage().Apply(ctx, o)
+ }
+
+ var rel0 *models.PublicreportImage
+
+ if o.r.Image.o.alreadyPersisted {
+ rel0 = o.r.Image.o.Build()
+ } else {
+ rel0, err = o.r.Image.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.ImageID = omit.From(rel0.ID)
+
+ m, err := models.PublicreportImageExifs.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ m.R.Image = rel0
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a publicreportImageExif and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *PublicreportImageExifTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportImageExif {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a publicreportImageExif and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *PublicreportImageExifTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportImageExif {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple publicreportImageExifs and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o PublicreportImageExifTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportImageExifSlice, error) {
+ var err error
+ m := make(models.PublicreportImageExifSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple publicreportImageExifs and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o PublicreportImageExifTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportImageExifSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple publicreportImageExifs and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o PublicreportImageExifTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportImageExifSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// PublicreportImageExif has methods that act as mods for the PublicreportImageExifTemplate
+var PublicreportImageExifMods publicreportImageExifMods
+
+type publicreportImageExifMods struct{}
+
+func (m publicreportImageExifMods) RandomizeAllColumns(f *faker.Faker) PublicreportImageExifMod {
+ return PublicreportImageExifModSlice{
+ PublicreportImageExifMods.RandomImageID(f),
+ PublicreportImageExifMods.RandomName(f),
+ PublicreportImageExifMods.RandomValue(f),
+ }
+}
+
+// Set the model columns to this value
+func (m publicreportImageExifMods) ImageID(val int32) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.ImageID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageExifMods) ImageIDFunc(f func() int32) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.ImageID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageExifMods) UnsetImageID() PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.ImageID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageExifMods) RandomImageID(f *faker.Faker) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.ImageID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageExifMods) Name(val string) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Name = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageExifMods) NameFunc(f func() string) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Name = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageExifMods) UnsetName() PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Name = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageExifMods) RandomName(f *faker.Faker) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Name = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportImageExifMods) Value(val string) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Value = func() string { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportImageExifMods) ValueFunc(f func() string) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Value = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportImageExifMods) UnsetValue() PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Value = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportImageExifMods) RandomValue(f *faker.Faker) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(_ context.Context, o *PublicreportImageExifTemplate) {
+ o.Value = func() string {
+ return random_string(f)
+ }
+ })
+}
+
+func (m publicreportImageExifMods) WithParentsCascading() PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(ctx context.Context, o *PublicreportImageExifTemplate) {
+ if isDone, _ := publicreportImageExifWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = publicreportImageExifWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewPublicreportImageWithContext(ctx, PublicreportImageMods.WithParentsCascading())
+ m.WithImage(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m publicreportImageExifMods) WithImage(rel *PublicreportImageTemplate) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(ctx context.Context, o *PublicreportImageExifTemplate) {
+ o.r.Image = &publicreportImageExifRImageR{
+ o: rel,
+ }
+ })
+}
+
+func (m publicreportImageExifMods) WithNewImage(mods ...PublicreportImageMod) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(ctx context.Context, o *PublicreportImageExifTemplate) {
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+
+ m.WithImage(related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportImageExifMods) WithExistingImage(em *models.PublicreportImage) PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(ctx context.Context, o *PublicreportImageExifTemplate) {
+ o.r.Image = &publicreportImageExifRImageR{
+ o: o.f.FromExistingPublicreportImage(em),
+ }
+ })
+}
+
+func (m publicreportImageExifMods) WithoutImage() PublicreportImageExifMod {
+ return PublicreportImageExifModFunc(func(ctx context.Context, o *PublicreportImageExifTemplate) {
+ o.r.Image = nil
+ })
+}
diff --git a/db/factory/publicreport.pool.bob.go b/db/factory/publicreport.pool.bob.go
index d35ac5c2..72b2f50e 100644
--- a/db/factory/publicreport.pool.bob.go
+++ b/db/factory/publicreport.pool.bob.go
@@ -76,12 +76,12 @@ type PublicreportPoolTemplate struct {
}
type publicreportPoolR struct {
- PoolPhotos []*publicreportPoolRPoolPhotosR
+ Images []*publicreportPoolRImagesR
}
-type publicreportPoolRPoolPhotosR struct {
+type publicreportPoolRImagesR struct {
number int
- o *PublicreportPoolPhotoTemplate
+ o *PublicreportImageTemplate
}
// Apply mods to the PublicreportPoolTemplate
@@ -94,17 +94,16 @@ func (o *PublicreportPoolTemplate) Apply(ctx context.Context, mods ...Publicrepo
// setModelRels creates and sets the relationships on *models.PublicreportPool
// according to the relationships in the template. Nothing is inserted into the db
func (t PublicreportPoolTemplate) setModelRels(o *models.PublicreportPool) {
- if t.r.PoolPhotos != nil {
- rel := models.PublicreportPoolPhotoSlice{}
- for _, r := range t.r.PoolPhotos {
+ if t.r.Images != nil {
+ rel := models.PublicreportImageSlice{}
+ for _, r := range t.r.Images {
related := r.o.BuildMany(r.number)
for _, rel := range related {
- rel.PoolID = o.ID // h2
- rel.R.Pool = o
+ rel.R.Pools = append(rel.R.Pools, o)
}
rel = append(rel, related...)
}
- o.R.PoolPhotos = rel
+ o.R.Images = rel
}
}
@@ -481,19 +480,19 @@ func ensureCreatablePublicreportPool(m *models.PublicreportPoolSetter) {
func (o *PublicreportPoolTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportPool) error {
var err error
- isPoolPhotosDone, _ := publicreportPoolRelPoolPhotosCtx.Value(ctx)
- if !isPoolPhotosDone && o.r.PoolPhotos != nil {
- ctx = publicreportPoolRelPoolPhotosCtx.WithValue(ctx, true)
- for _, r := range o.r.PoolPhotos {
+ isImagesDone, _ := publicreportPoolRelImagesCtx.Value(ctx)
+ if !isImagesDone && o.r.Images != nil {
+ ctx = publicreportPoolRelImagesCtx.WithValue(ctx, true)
+ for _, r := range o.r.Images {
if r.o.alreadyPersisted {
- m.R.PoolPhotos = append(m.R.PoolPhotos, r.o.Build())
+ m.R.Images = append(m.R.Images, r.o.Build())
} else {
rel0, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachPoolPhotos(ctx, exec, rel0...)
+ err = m.AttachImages(ctx, exec, rel0...)
if err != nil {
return err
}
@@ -1609,50 +1608,50 @@ func (m publicreportPoolMods) WithParentsCascading() PublicreportPoolMod {
})
}
-func (m publicreportPoolMods) WithPoolPhotos(number int, related *PublicreportPoolPhotoTemplate) PublicreportPoolMod {
+func (m publicreportPoolMods) WithImages(number int, related *PublicreportImageTemplate) PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
- o.r.PoolPhotos = []*publicreportPoolRPoolPhotosR{{
+ o.r.Images = []*publicreportPoolRImagesR{{
number: number,
o: related,
}}
})
}
-func (m publicreportPoolMods) WithNewPoolPhotos(number int, mods ...PublicreportPoolPhotoMod) PublicreportPoolMod {
+func (m publicreportPoolMods) WithNewImages(number int, mods ...PublicreportImageMod) PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
- related := o.f.NewPublicreportPoolPhotoWithContext(ctx, mods...)
- m.WithPoolPhotos(number, related).Apply(ctx, o)
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+ m.WithImages(number, related).Apply(ctx, o)
})
}
-func (m publicreportPoolMods) AddPoolPhotos(number int, related *PublicreportPoolPhotoTemplate) PublicreportPoolMod {
+func (m publicreportPoolMods) AddImages(number int, related *PublicreportImageTemplate) PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
- o.r.PoolPhotos = append(o.r.PoolPhotos, &publicreportPoolRPoolPhotosR{
+ o.r.Images = append(o.r.Images, &publicreportPoolRImagesR{
number: number,
o: related,
})
})
}
-func (m publicreportPoolMods) AddNewPoolPhotos(number int, mods ...PublicreportPoolPhotoMod) PublicreportPoolMod {
+func (m publicreportPoolMods) AddNewImages(number int, mods ...PublicreportImageMod) PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
- related := o.f.NewPublicreportPoolPhotoWithContext(ctx, mods...)
- m.AddPoolPhotos(number, related).Apply(ctx, o)
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+ m.AddImages(number, related).Apply(ctx, o)
})
}
-func (m publicreportPoolMods) AddExistingPoolPhotos(existingModels ...*models.PublicreportPoolPhoto) PublicreportPoolMod {
+func (m publicreportPoolMods) AddExistingImages(existingModels ...*models.PublicreportImage) PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
for _, em := range existingModels {
- o.r.PoolPhotos = append(o.r.PoolPhotos, &publicreportPoolRPoolPhotosR{
- o: o.f.FromExistingPublicreportPoolPhoto(em),
+ o.r.Images = append(o.r.Images, &publicreportPoolRImagesR{
+ o: o.f.FromExistingPublicreportImage(em),
})
}
})
}
-func (m publicreportPoolMods) WithoutPoolPhotos() PublicreportPoolMod {
+func (m publicreportPoolMods) WithoutImages() PublicreportPoolMod {
return PublicreportPoolModFunc(func(ctx context.Context, o *PublicreportPoolTemplate) {
- o.r.PoolPhotos = nil
+ o.r.Images = nil
})
}
diff --git a/db/factory/publicreport.pool_image.bob.go b/db/factory/publicreport.pool_image.bob.go
new file mode 100644
index 00000000..e7af585c
--- /dev/null
+++ b/db/factory/publicreport.pool_image.bob.go
@@ -0,0 +1,431 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type PublicreportPoolImageMod interface {
+ Apply(context.Context, *PublicreportPoolImageTemplate)
+}
+
+type PublicreportPoolImageModFunc func(context.Context, *PublicreportPoolImageTemplate)
+
+func (f PublicreportPoolImageModFunc) Apply(ctx context.Context, n *PublicreportPoolImageTemplate) {
+ f(ctx, n)
+}
+
+type PublicreportPoolImageModSlice []PublicreportPoolImageMod
+
+func (mods PublicreportPoolImageModSlice) Apply(ctx context.Context, n *PublicreportPoolImageTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// PublicreportPoolImageTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type PublicreportPoolImageTemplate struct {
+ ImageID func() int32
+ PoolID func() int32
+
+ r publicreportPoolImageR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type publicreportPoolImageR struct {
+ Image *publicreportPoolImageRImageR
+ Pool *publicreportPoolImageRPoolR
+}
+
+type publicreportPoolImageRImageR struct {
+ o *PublicreportImageTemplate
+}
+type publicreportPoolImageRPoolR struct {
+ o *PublicreportPoolTemplate
+}
+
+// Apply mods to the PublicreportPoolImageTemplate
+func (o *PublicreportPoolImageTemplate) Apply(ctx context.Context, mods ...PublicreportPoolImageMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.PublicreportPoolImage
+// according to the relationships in the template. Nothing is inserted into the db
+func (t PublicreportPoolImageTemplate) setModelRels(o *models.PublicreportPoolImage) {
+ if t.r.Image != nil {
+ rel := t.r.Image.o.Build()
+ o.ImageID = rel.ID // h2
+ o.R.Image = rel
+ }
+
+ if t.r.Pool != nil {
+ rel := t.r.Pool.o.Build()
+ o.PoolID = rel.ID // h2
+ o.R.Pool = rel
+ }
+}
+
+// BuildSetter returns an *models.PublicreportPoolImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportPoolImageTemplate) BuildSetter() *models.PublicreportPoolImageSetter {
+ m := &models.PublicreportPoolImageSetter{}
+
+ if o.ImageID != nil {
+ val := o.ImageID()
+ m.ImageID = omit.From(val)
+ }
+ if o.PoolID != nil {
+ val := o.PoolID()
+ m.PoolID = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.PublicreportPoolImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportPoolImageTemplate) BuildManySetter(number int) []*models.PublicreportPoolImageSetter {
+ m := make([]*models.PublicreportPoolImageSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.PublicreportPoolImage
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportPoolImageTemplate.Create
+func (o PublicreportPoolImageTemplate) Build() *models.PublicreportPoolImage {
+ m := &models.PublicreportPoolImage{}
+
+ if o.ImageID != nil {
+ m.ImageID = o.ImageID()
+ }
+ if o.PoolID != nil {
+ m.PoolID = o.PoolID()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.PublicreportPoolImageSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportPoolImageTemplate.CreateMany
+func (o PublicreportPoolImageTemplate) BuildMany(number int) models.PublicreportPoolImageSlice {
+ m := make(models.PublicreportPoolImageSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatablePublicreportPoolImage(m *models.PublicreportPoolImageSetter) {
+ if !(m.ImageID.IsValue()) {
+ val := random_int32(nil)
+ m.ImageID = omit.From(val)
+ }
+ if !(m.PoolID.IsValue()) {
+ val := random_int32(nil)
+ m.PoolID = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.PublicreportPoolImage
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *PublicreportPoolImageTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportPoolImage) error {
+ var err error
+
+ return err
+}
+
+// Create builds a publicreportPoolImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *PublicreportPoolImageTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportPoolImage, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatablePublicreportPoolImage(opt)
+
+ if o.r.Image == nil {
+ PublicreportPoolImageMods.WithNewImage().Apply(ctx, o)
+ }
+
+ var rel0 *models.PublicreportImage
+
+ if o.r.Image.o.alreadyPersisted {
+ rel0 = o.r.Image.o.Build()
+ } else {
+ rel0, err = o.r.Image.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.ImageID = omit.From(rel0.ID)
+
+ if o.r.Pool == nil {
+ PublicreportPoolImageMods.WithNewPool().Apply(ctx, o)
+ }
+
+ var rel1 *models.PublicreportPool
+
+ if o.r.Pool.o.alreadyPersisted {
+ rel1 = o.r.Pool.o.Build()
+ } else {
+ rel1, err = o.r.Pool.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.PoolID = omit.From(rel1.ID)
+
+ m, err := models.PublicreportPoolImages.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ m.R.Image = rel0
+ m.R.Pool = rel1
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a publicreportPoolImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *PublicreportPoolImageTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportPoolImage {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a publicreportPoolImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *PublicreportPoolImageTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportPoolImage {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple publicreportPoolImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o PublicreportPoolImageTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportPoolImageSlice, error) {
+ var err error
+ m := make(models.PublicreportPoolImageSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple publicreportPoolImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o PublicreportPoolImageTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportPoolImageSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple publicreportPoolImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o PublicreportPoolImageTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportPoolImageSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// PublicreportPoolImage has methods that act as mods for the PublicreportPoolImageTemplate
+var PublicreportPoolImageMods publicreportPoolImageMods
+
+type publicreportPoolImageMods struct{}
+
+func (m publicreportPoolImageMods) RandomizeAllColumns(f *faker.Faker) PublicreportPoolImageMod {
+ return PublicreportPoolImageModSlice{
+ PublicreportPoolImageMods.RandomImageID(f),
+ PublicreportPoolImageMods.RandomPoolID(f),
+ }
+}
+
+// Set the model columns to this value
+func (m publicreportPoolImageMods) ImageID(val int32) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.ImageID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportPoolImageMods) ImageIDFunc(f func() int32) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.ImageID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportPoolImageMods) UnsetImageID() PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.ImageID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportPoolImageMods) RandomImageID(f *faker.Faker) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.ImageID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportPoolImageMods) PoolID(val int32) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.PoolID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportPoolImageMods) PoolIDFunc(f func() int32) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.PoolID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportPoolImageMods) UnsetPoolID() PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.PoolID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportPoolImageMods) RandomPoolID(f *faker.Faker) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(_ context.Context, o *PublicreportPoolImageTemplate) {
+ o.PoolID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithParentsCascading() PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ if isDone, _ := publicreportPoolImageWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = publicreportPoolImageWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewPublicreportImageWithContext(ctx, PublicreportImageMods.WithParentsCascading())
+ m.WithImage(related).Apply(ctx, o)
+ }
+ {
+
+ related := o.f.NewPublicreportPoolWithContext(ctx, PublicreportPoolMods.WithParentsCascading())
+ m.WithPool(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithImage(rel *PublicreportImageTemplate) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Image = &publicreportPoolImageRImageR{
+ o: rel,
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithNewImage(mods ...PublicreportImageMod) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+
+ m.WithImage(related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportPoolImageMods) WithExistingImage(em *models.PublicreportImage) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Image = &publicreportPoolImageRImageR{
+ o: o.f.FromExistingPublicreportImage(em),
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithoutImage() PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Image = nil
+ })
+}
+
+func (m publicreportPoolImageMods) WithPool(rel *PublicreportPoolTemplate) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Pool = &publicreportPoolImageRPoolR{
+ o: rel,
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithNewPool(mods ...PublicreportPoolMod) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
+
+ m.WithPool(related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportPoolImageMods) WithExistingPool(em *models.PublicreportPool) PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Pool = &publicreportPoolImageRPoolR{
+ o: o.f.FromExistingPublicreportPool(em),
+ }
+ })
+}
+
+func (m publicreportPoolImageMods) WithoutPool() PublicreportPoolImageMod {
+ return PublicreportPoolImageModFunc(func(ctx context.Context, o *PublicreportPoolImageTemplate) {
+ o.r.Pool = nil
+ })
+}
diff --git a/db/factory/publicreport.pool_photo.bob.go b/db/factory/publicreport.pool_photo.bob.go
deleted file mode 100644
index d41bd538..00000000
--- a/db/factory/publicreport.pool_photo.bob.go
+++ /dev/null
@@ -1,498 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package factory
-
-import (
- "context"
- "testing"
-
- models "github.com/Gleipnir-Technology/nidus-sync/db/models"
- "github.com/aarondl/opt/omit"
- "github.com/google/uuid"
- "github.com/jaswdr/faker/v2"
- "github.com/stephenafamo/bob"
-)
-
-type PublicreportPoolPhotoMod interface {
- Apply(context.Context, *PublicreportPoolPhotoTemplate)
-}
-
-type PublicreportPoolPhotoModFunc func(context.Context, *PublicreportPoolPhotoTemplate)
-
-func (f PublicreportPoolPhotoModFunc) Apply(ctx context.Context, n *PublicreportPoolPhotoTemplate) {
- f(ctx, n)
-}
-
-type PublicreportPoolPhotoModSlice []PublicreportPoolPhotoMod
-
-func (mods PublicreportPoolPhotoModSlice) Apply(ctx context.Context, n *PublicreportPoolPhotoTemplate) {
- for _, f := range mods {
- f.Apply(ctx, n)
- }
-}
-
-// PublicreportPoolPhotoTemplate is an object representing the database table.
-// all columns are optional and should be set by mods
-type PublicreportPoolPhotoTemplate struct {
- ID func() int32
- Size func() int64
- Filename func() string
- PoolID func() int32
- UUID func() uuid.UUID
-
- r publicreportPoolPhotoR
- f *Factory
-
- alreadyPersisted bool
-}
-
-type publicreportPoolPhotoR struct {
- Pool *publicreportPoolPhotoRPoolR
-}
-
-type publicreportPoolPhotoRPoolR struct {
- o *PublicreportPoolTemplate
-}
-
-// Apply mods to the PublicreportPoolPhotoTemplate
-func (o *PublicreportPoolPhotoTemplate) Apply(ctx context.Context, mods ...PublicreportPoolPhotoMod) {
- for _, mod := range mods {
- mod.Apply(ctx, o)
- }
-}
-
-// setModelRels creates and sets the relationships on *models.PublicreportPoolPhoto
-// according to the relationships in the template. Nothing is inserted into the db
-func (t PublicreportPoolPhotoTemplate) setModelRels(o *models.PublicreportPoolPhoto) {
- if t.r.Pool != nil {
- rel := t.r.Pool.o.Build()
- rel.R.PoolPhotos = append(rel.R.PoolPhotos, o)
- o.PoolID = rel.ID // h2
- o.R.Pool = rel
- }
-}
-
-// BuildSetter returns an *models.PublicreportPoolPhotoSetter
-// this does nothing with the relationship templates
-func (o PublicreportPoolPhotoTemplate) BuildSetter() *models.PublicreportPoolPhotoSetter {
- m := &models.PublicreportPoolPhotoSetter{}
-
- if o.ID != nil {
- val := o.ID()
- m.ID = omit.From(val)
- }
- if o.Size != nil {
- val := o.Size()
- m.Size = omit.From(val)
- }
- if o.Filename != nil {
- val := o.Filename()
- m.Filename = omit.From(val)
- }
- if o.PoolID != nil {
- val := o.PoolID()
- m.PoolID = omit.From(val)
- }
- if o.UUID != nil {
- val := o.UUID()
- m.UUID = omit.From(val)
- }
-
- return m
-}
-
-// BuildManySetter returns an []*models.PublicreportPoolPhotoSetter
-// this does nothing with the relationship templates
-func (o PublicreportPoolPhotoTemplate) BuildManySetter(number int) []*models.PublicreportPoolPhotoSetter {
- m := make([]*models.PublicreportPoolPhotoSetter, number)
-
- for i := range m {
- m[i] = o.BuildSetter()
- }
-
- return m
-}
-
-// Build returns an *models.PublicreportPoolPhoto
-// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use PublicreportPoolPhotoTemplate.Create
-func (o PublicreportPoolPhotoTemplate) Build() *models.PublicreportPoolPhoto {
- m := &models.PublicreportPoolPhoto{}
-
- if o.ID != nil {
- m.ID = o.ID()
- }
- if o.Size != nil {
- m.Size = o.Size()
- }
- if o.Filename != nil {
- m.Filename = o.Filename()
- }
- if o.PoolID != nil {
- m.PoolID = o.PoolID()
- }
- if o.UUID != nil {
- m.UUID = o.UUID()
- }
-
- o.setModelRels(m)
-
- return m
-}
-
-// BuildMany returns an models.PublicreportPoolPhotoSlice
-// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use PublicreportPoolPhotoTemplate.CreateMany
-func (o PublicreportPoolPhotoTemplate) BuildMany(number int) models.PublicreportPoolPhotoSlice {
- m := make(models.PublicreportPoolPhotoSlice, number)
-
- for i := range m {
- m[i] = o.Build()
- }
-
- return m
-}
-
-func ensureCreatablePublicreportPoolPhoto(m *models.PublicreportPoolPhotoSetter) {
- if !(m.Size.IsValue()) {
- val := random_int64(nil)
- m.Size = omit.From(val)
- }
- if !(m.Filename.IsValue()) {
- val := random_string(nil)
- m.Filename = omit.From(val)
- }
- if !(m.PoolID.IsValue()) {
- val := random_int32(nil)
- m.PoolID = omit.From(val)
- }
- if !(m.UUID.IsValue()) {
- val := random_uuid_UUID(nil)
- m.UUID = omit.From(val)
- }
-}
-
-// insertOptRels creates and inserts any optional the relationships on *models.PublicreportPoolPhoto
-// according to the relationships in the template.
-// any required relationship should have already exist on the model
-func (o *PublicreportPoolPhotoTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportPoolPhoto) error {
- var err error
-
- return err
-}
-
-// Create builds a publicreportPoolPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-func (o *PublicreportPoolPhotoTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportPoolPhoto, error) {
- var err error
- opt := o.BuildSetter()
- ensureCreatablePublicreportPoolPhoto(opt)
-
- if o.r.Pool == nil {
- PublicreportPoolPhotoMods.WithNewPool().Apply(ctx, o)
- }
-
- var rel0 *models.PublicreportPool
-
- if o.r.Pool.o.alreadyPersisted {
- rel0 = o.r.Pool.o.Build()
- } else {
- rel0, err = o.r.Pool.o.Create(ctx, exec)
- if err != nil {
- return nil, err
- }
- }
-
- opt.PoolID = omit.From(rel0.ID)
-
- m, err := models.PublicreportPoolPhotos.Insert(opt).One(ctx, exec)
- if err != nil {
- return nil, err
- }
-
- m.R.Pool = rel0
-
- if err := o.insertOptRels(ctx, exec, m); err != nil {
- return nil, err
- }
- return m, err
-}
-
-// MustCreate builds a publicreportPoolPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-// panics if an error occurs
-func (o *PublicreportPoolPhotoTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportPoolPhoto {
- m, err := o.Create(ctx, exec)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-// CreateOrFail builds a publicreportPoolPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o *PublicreportPoolPhotoTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportPoolPhoto {
- tb.Helper()
- m, err := o.Create(ctx, exec)
- if err != nil {
- tb.Fatal(err)
- return nil
- }
- return m
-}
-
-// CreateMany builds multiple publicreportPoolPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-func (o PublicreportPoolPhotoTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportPoolPhotoSlice, error) {
- var err error
- m := make(models.PublicreportPoolPhotoSlice, number)
-
- for i := range m {
- m[i], err = o.Create(ctx, exec)
- if err != nil {
- return nil, err
- }
- }
-
- return m, nil
-}
-
-// MustCreateMany builds multiple publicreportPoolPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-// panics if an error occurs
-func (o PublicreportPoolPhotoTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportPoolPhotoSlice {
- m, err := o.CreateMany(ctx, exec, number)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-// CreateManyOrFail builds multiple publicreportPoolPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o PublicreportPoolPhotoTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportPoolPhotoSlice {
- tb.Helper()
- m, err := o.CreateMany(ctx, exec, number)
- if err != nil {
- tb.Fatal(err)
- return nil
- }
- return m
-}
-
-// PublicreportPoolPhoto has methods that act as mods for the PublicreportPoolPhotoTemplate
-var PublicreportPoolPhotoMods publicreportPoolPhotoMods
-
-type publicreportPoolPhotoMods struct{}
-
-func (m publicreportPoolPhotoMods) RandomizeAllColumns(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModSlice{
- PublicreportPoolPhotoMods.RandomID(f),
- PublicreportPoolPhotoMods.RandomSize(f),
- PublicreportPoolPhotoMods.RandomFilename(f),
- PublicreportPoolPhotoMods.RandomPoolID(f),
- PublicreportPoolPhotoMods.RandomUUID(f),
- }
-}
-
-// Set the model columns to this value
-func (m publicreportPoolPhotoMods) ID(val int32) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.ID = func() int32 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportPoolPhotoMods) IDFunc(f func() int32) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.ID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportPoolPhotoMods) UnsetID() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.ID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportPoolPhotoMods) RandomID(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.ID = func() int32 {
- return random_int32(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportPoolPhotoMods) Size(val int64) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Size = func() int64 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportPoolPhotoMods) SizeFunc(f func() int64) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Size = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportPoolPhotoMods) UnsetSize() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Size = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportPoolPhotoMods) RandomSize(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Size = func() int64 {
- return random_int64(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportPoolPhotoMods) Filename(val string) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Filename = func() string { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportPoolPhotoMods) FilenameFunc(f func() string) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Filename = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportPoolPhotoMods) UnsetFilename() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Filename = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportPoolPhotoMods) RandomFilename(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.Filename = func() string {
- return random_string(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportPoolPhotoMods) PoolID(val int32) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.PoolID = func() int32 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportPoolPhotoMods) PoolIDFunc(f func() int32) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.PoolID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportPoolPhotoMods) UnsetPoolID() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.PoolID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportPoolPhotoMods) RandomPoolID(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.PoolID = func() int32 {
- return random_int32(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportPoolPhotoMods) UUID(val uuid.UUID) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.UUID = func() uuid.UUID { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportPoolPhotoMods) UUIDFunc(f func() uuid.UUID) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.UUID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportPoolPhotoMods) UnsetUUID() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.UUID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportPoolPhotoMods) RandomUUID(f *faker.Faker) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(_ context.Context, o *PublicreportPoolPhotoTemplate) {
- o.UUID = func() uuid.UUID {
- return random_uuid_UUID(f)
- }
- })
-}
-
-func (m publicreportPoolPhotoMods) WithParentsCascading() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(ctx context.Context, o *PublicreportPoolPhotoTemplate) {
- if isDone, _ := publicreportPoolPhotoWithParentsCascadingCtx.Value(ctx); isDone {
- return
- }
- ctx = publicreportPoolPhotoWithParentsCascadingCtx.WithValue(ctx, true)
- {
-
- related := o.f.NewPublicreportPoolWithContext(ctx, PublicreportPoolMods.WithParentsCascading())
- m.WithPool(related).Apply(ctx, o)
- }
- })
-}
-
-func (m publicreportPoolPhotoMods) WithPool(rel *PublicreportPoolTemplate) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(ctx context.Context, o *PublicreportPoolPhotoTemplate) {
- o.r.Pool = &publicreportPoolPhotoRPoolR{
- o: rel,
- }
- })
-}
-
-func (m publicreportPoolPhotoMods) WithNewPool(mods ...PublicreportPoolMod) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(ctx context.Context, o *PublicreportPoolPhotoTemplate) {
- related := o.f.NewPublicreportPoolWithContext(ctx, mods...)
-
- m.WithPool(related).Apply(ctx, o)
- })
-}
-
-func (m publicreportPoolPhotoMods) WithExistingPool(em *models.PublicreportPool) PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(ctx context.Context, o *PublicreportPoolPhotoTemplate) {
- o.r.Pool = &publicreportPoolPhotoRPoolR{
- o: o.f.FromExistingPublicreportPool(em),
- }
- })
-}
-
-func (m publicreportPoolPhotoMods) WithoutPool() PublicreportPoolPhotoMod {
- return PublicreportPoolPhotoModFunc(func(ctx context.Context, o *PublicreportPoolPhotoTemplate) {
- o.r.Pool = nil
- })
-}
diff --git a/db/factory/publicreport.quick.bob.go b/db/factory/publicreport.quick.bob.go
index 95a66d3a..9f372444 100644
--- a/db/factory/publicreport.quick.bob.go
+++ b/db/factory/publicreport.quick.bob.go
@@ -56,12 +56,12 @@ type PublicreportQuickTemplate struct {
}
type publicreportQuickR struct {
- QuickPhotos []*publicreportQuickRQuickPhotosR
+ Images []*publicreportQuickRImagesR
}
-type publicreportQuickRQuickPhotosR struct {
+type publicreportQuickRImagesR struct {
number int
- o *PublicreportQuickPhotoTemplate
+ o *PublicreportImageTemplate
}
// Apply mods to the PublicreportQuickTemplate
@@ -74,17 +74,16 @@ func (o *PublicreportQuickTemplate) Apply(ctx context.Context, mods ...Publicrep
// setModelRels creates and sets the relationships on *models.PublicreportQuick
// according to the relationships in the template. Nothing is inserted into the db
func (t PublicreportQuickTemplate) setModelRels(o *models.PublicreportQuick) {
- if t.r.QuickPhotos != nil {
- rel := models.PublicreportQuickPhotoSlice{}
- for _, r := range t.r.QuickPhotos {
+ if t.r.Images != nil {
+ rel := models.PublicreportImageSlice{}
+ for _, r := range t.r.Images {
related := r.o.BuildMany(r.number)
for _, rel := range related {
- rel.QuickID = o.ID // h2
- rel.R.Quick = o
+ rel.R.Quicks = append(rel.R.Quicks, o)
}
rel = append(rel, related...)
}
- o.R.QuickPhotos = rel
+ o.R.Images = rel
}
}
@@ -241,19 +240,19 @@ func ensureCreatablePublicreportQuick(m *models.PublicreportQuickSetter) {
func (o *PublicreportQuickTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportQuick) error {
var err error
- isQuickPhotosDone, _ := publicreportQuickRelQuickPhotosCtx.Value(ctx)
- if !isQuickPhotosDone && o.r.QuickPhotos != nil {
- ctx = publicreportQuickRelQuickPhotosCtx.WithValue(ctx, true)
- for _, r := range o.r.QuickPhotos {
+ isImagesDone, _ := publicreportQuickRelImagesCtx.Value(ctx)
+ if !isImagesDone && o.r.Images != nil {
+ ctx = publicreportQuickRelImagesCtx.WithValue(ctx, true)
+ for _, r := range o.r.Images {
if r.o.alreadyPersisted {
- m.R.QuickPhotos = append(m.R.QuickPhotos, r.o.Build())
+ m.R.Images = append(m.R.Images, r.o.Build())
} else {
rel0, err := r.o.CreateMany(ctx, exec, r.number)
if err != nil {
return err
}
- err = m.AttachQuickPhotos(ctx, exec, rel0...)
+ err = m.AttachImages(ctx, exec, rel0...)
if err != nil {
return err
}
@@ -729,50 +728,50 @@ func (m publicreportQuickMods) WithParentsCascading() PublicreportQuickMod {
})
}
-func (m publicreportQuickMods) WithQuickPhotos(number int, related *PublicreportQuickPhotoTemplate) PublicreportQuickMod {
+func (m publicreportQuickMods) WithImages(number int, related *PublicreportImageTemplate) PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
- o.r.QuickPhotos = []*publicreportQuickRQuickPhotosR{{
+ o.r.Images = []*publicreportQuickRImagesR{{
number: number,
o: related,
}}
})
}
-func (m publicreportQuickMods) WithNewQuickPhotos(number int, mods ...PublicreportQuickPhotoMod) PublicreportQuickMod {
+func (m publicreportQuickMods) WithNewImages(number int, mods ...PublicreportImageMod) PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
- related := o.f.NewPublicreportQuickPhotoWithContext(ctx, mods...)
- m.WithQuickPhotos(number, related).Apply(ctx, o)
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+ m.WithImages(number, related).Apply(ctx, o)
})
}
-func (m publicreportQuickMods) AddQuickPhotos(number int, related *PublicreportQuickPhotoTemplate) PublicreportQuickMod {
+func (m publicreportQuickMods) AddImages(number int, related *PublicreportImageTemplate) PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
- o.r.QuickPhotos = append(o.r.QuickPhotos, &publicreportQuickRQuickPhotosR{
+ o.r.Images = append(o.r.Images, &publicreportQuickRImagesR{
number: number,
o: related,
})
})
}
-func (m publicreportQuickMods) AddNewQuickPhotos(number int, mods ...PublicreportQuickPhotoMod) PublicreportQuickMod {
+func (m publicreportQuickMods) AddNewImages(number int, mods ...PublicreportImageMod) PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
- related := o.f.NewPublicreportQuickPhotoWithContext(ctx, mods...)
- m.AddQuickPhotos(number, related).Apply(ctx, o)
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+ m.AddImages(number, related).Apply(ctx, o)
})
}
-func (m publicreportQuickMods) AddExistingQuickPhotos(existingModels ...*models.PublicreportQuickPhoto) PublicreportQuickMod {
+func (m publicreportQuickMods) AddExistingImages(existingModels ...*models.PublicreportImage) PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
for _, em := range existingModels {
- o.r.QuickPhotos = append(o.r.QuickPhotos, &publicreportQuickRQuickPhotosR{
- o: o.f.FromExistingPublicreportQuickPhoto(em),
+ o.r.Images = append(o.r.Images, &publicreportQuickRImagesR{
+ o: o.f.FromExistingPublicreportImage(em),
})
}
})
}
-func (m publicreportQuickMods) WithoutQuickPhotos() PublicreportQuickMod {
+func (m publicreportQuickMods) WithoutImages() PublicreportQuickMod {
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
- o.r.QuickPhotos = nil
+ o.r.Images = nil
})
}
diff --git a/db/factory/publicreport.quick_image.bob.go b/db/factory/publicreport.quick_image.bob.go
new file mode 100644
index 00000000..951dc333
--- /dev/null
+++ b/db/factory/publicreport.quick_image.bob.go
@@ -0,0 +1,431 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package factory
+
+import (
+ "context"
+ "testing"
+
+ models "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/aarondl/opt/omit"
+ "github.com/jaswdr/faker/v2"
+ "github.com/stephenafamo/bob"
+)
+
+type PublicreportQuickImageMod interface {
+ Apply(context.Context, *PublicreportQuickImageTemplate)
+}
+
+type PublicreportQuickImageModFunc func(context.Context, *PublicreportQuickImageTemplate)
+
+func (f PublicreportQuickImageModFunc) Apply(ctx context.Context, n *PublicreportQuickImageTemplate) {
+ f(ctx, n)
+}
+
+type PublicreportQuickImageModSlice []PublicreportQuickImageMod
+
+func (mods PublicreportQuickImageModSlice) Apply(ctx context.Context, n *PublicreportQuickImageTemplate) {
+ for _, f := range mods {
+ f.Apply(ctx, n)
+ }
+}
+
+// PublicreportQuickImageTemplate is an object representing the database table.
+// all columns are optional and should be set by mods
+type PublicreportQuickImageTemplate struct {
+ ImageID func() int32
+ QuickID func() int32
+
+ r publicreportQuickImageR
+ f *Factory
+
+ alreadyPersisted bool
+}
+
+type publicreportQuickImageR struct {
+ Image *publicreportQuickImageRImageR
+ Quick *publicreportQuickImageRQuickR
+}
+
+type publicreportQuickImageRImageR struct {
+ o *PublicreportImageTemplate
+}
+type publicreportQuickImageRQuickR struct {
+ o *PublicreportQuickTemplate
+}
+
+// Apply mods to the PublicreportQuickImageTemplate
+func (o *PublicreportQuickImageTemplate) Apply(ctx context.Context, mods ...PublicreportQuickImageMod) {
+ for _, mod := range mods {
+ mod.Apply(ctx, o)
+ }
+}
+
+// setModelRels creates and sets the relationships on *models.PublicreportQuickImage
+// according to the relationships in the template. Nothing is inserted into the db
+func (t PublicreportQuickImageTemplate) setModelRels(o *models.PublicreportQuickImage) {
+ if t.r.Image != nil {
+ rel := t.r.Image.o.Build()
+ o.ImageID = rel.ID // h2
+ o.R.Image = rel
+ }
+
+ if t.r.Quick != nil {
+ rel := t.r.Quick.o.Build()
+ o.QuickID = rel.ID // h2
+ o.R.Quick = rel
+ }
+}
+
+// BuildSetter returns an *models.PublicreportQuickImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportQuickImageTemplate) BuildSetter() *models.PublicreportQuickImageSetter {
+ m := &models.PublicreportQuickImageSetter{}
+
+ if o.ImageID != nil {
+ val := o.ImageID()
+ m.ImageID = omit.From(val)
+ }
+ if o.QuickID != nil {
+ val := o.QuickID()
+ m.QuickID = omit.From(val)
+ }
+
+ return m
+}
+
+// BuildManySetter returns an []*models.PublicreportQuickImageSetter
+// this does nothing with the relationship templates
+func (o PublicreportQuickImageTemplate) BuildManySetter(number int) []*models.PublicreportQuickImageSetter {
+ m := make([]*models.PublicreportQuickImageSetter, number)
+
+ for i := range m {
+ m[i] = o.BuildSetter()
+ }
+
+ return m
+}
+
+// Build returns an *models.PublicreportQuickImage
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportQuickImageTemplate.Create
+func (o PublicreportQuickImageTemplate) Build() *models.PublicreportQuickImage {
+ m := &models.PublicreportQuickImage{}
+
+ if o.ImageID != nil {
+ m.ImageID = o.ImageID()
+ }
+ if o.QuickID != nil {
+ m.QuickID = o.QuickID()
+ }
+
+ o.setModelRels(m)
+
+ return m
+}
+
+// BuildMany returns an models.PublicreportQuickImageSlice
+// Related objects are also created and placed in the .R field
+// NOTE: Objects are not inserted into the database. Use PublicreportQuickImageTemplate.CreateMany
+func (o PublicreportQuickImageTemplate) BuildMany(number int) models.PublicreportQuickImageSlice {
+ m := make(models.PublicreportQuickImageSlice, number)
+
+ for i := range m {
+ m[i] = o.Build()
+ }
+
+ return m
+}
+
+func ensureCreatablePublicreportQuickImage(m *models.PublicreportQuickImageSetter) {
+ if !(m.ImageID.IsValue()) {
+ val := random_int32(nil)
+ m.ImageID = omit.From(val)
+ }
+ if !(m.QuickID.IsValue()) {
+ val := random_int32(nil)
+ m.QuickID = omit.From(val)
+ }
+}
+
+// insertOptRels creates and inserts any optional the relationships on *models.PublicreportQuickImage
+// according to the relationships in the template.
+// any required relationship should have already exist on the model
+func (o *PublicreportQuickImageTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportQuickImage) error {
+ var err error
+
+ return err
+}
+
+// Create builds a publicreportQuickImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+func (o *PublicreportQuickImageTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportQuickImage, error) {
+ var err error
+ opt := o.BuildSetter()
+ ensureCreatablePublicreportQuickImage(opt)
+
+ if o.r.Image == nil {
+ PublicreportQuickImageMods.WithNewImage().Apply(ctx, o)
+ }
+
+ var rel0 *models.PublicreportImage
+
+ if o.r.Image.o.alreadyPersisted {
+ rel0 = o.r.Image.o.Build()
+ } else {
+ rel0, err = o.r.Image.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.ImageID = omit.From(rel0.ID)
+
+ if o.r.Quick == nil {
+ PublicreportQuickImageMods.WithNewQuick().Apply(ctx, o)
+ }
+
+ var rel1 *models.PublicreportQuick
+
+ if o.r.Quick.o.alreadyPersisted {
+ rel1 = o.r.Quick.o.Build()
+ } else {
+ rel1, err = o.r.Quick.o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ opt.QuickID = omit.From(rel1.ID)
+
+ m, err := models.PublicreportQuickImages.Insert(opt).One(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+
+ m.R.Image = rel0
+ m.R.Quick = rel1
+
+ if err := o.insertOptRels(ctx, exec, m); err != nil {
+ return nil, err
+ }
+ return m, err
+}
+
+// MustCreate builds a publicreportQuickImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o *PublicreportQuickImageTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportQuickImage {
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateOrFail builds a publicreportQuickImage and inserts it into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o *PublicreportQuickImageTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportQuickImage {
+ tb.Helper()
+ m, err := o.Create(ctx, exec)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// CreateMany builds multiple publicreportQuickImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+func (o PublicreportQuickImageTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportQuickImageSlice, error) {
+ var err error
+ m := make(models.PublicreportQuickImageSlice, number)
+
+ for i := range m {
+ m[i], err = o.Create(ctx, exec)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return m, nil
+}
+
+// MustCreateMany builds multiple publicreportQuickImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// panics if an error occurs
+func (o PublicreportQuickImageTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportQuickImageSlice {
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ panic(err)
+ }
+ return m
+}
+
+// CreateManyOrFail builds multiple publicreportQuickImages and inserts them into the database
+// Relations objects are also inserted and placed in the .R field
+// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
+func (o PublicreportQuickImageTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportQuickImageSlice {
+ tb.Helper()
+ m, err := o.CreateMany(ctx, exec, number)
+ if err != nil {
+ tb.Fatal(err)
+ return nil
+ }
+ return m
+}
+
+// PublicreportQuickImage has methods that act as mods for the PublicreportQuickImageTemplate
+var PublicreportQuickImageMods publicreportQuickImageMods
+
+type publicreportQuickImageMods struct{}
+
+func (m publicreportQuickImageMods) RandomizeAllColumns(f *faker.Faker) PublicreportQuickImageMod {
+ return PublicreportQuickImageModSlice{
+ PublicreportQuickImageMods.RandomImageID(f),
+ PublicreportQuickImageMods.RandomQuickID(f),
+ }
+}
+
+// Set the model columns to this value
+func (m publicreportQuickImageMods) ImageID(val int32) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.ImageID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportQuickImageMods) ImageIDFunc(f func() int32) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.ImageID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportQuickImageMods) UnsetImageID() PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.ImageID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportQuickImageMods) RandomImageID(f *faker.Faker) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.ImageID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+// Set the model columns to this value
+func (m publicreportQuickImageMods) QuickID(val int32) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.QuickID = func() int32 { return val }
+ })
+}
+
+// Set the Column from the function
+func (m publicreportQuickImageMods) QuickIDFunc(f func() int32) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.QuickID = f
+ })
+}
+
+// Clear any values for the column
+func (m publicreportQuickImageMods) UnsetQuickID() PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.QuickID = nil
+ })
+}
+
+// Generates a random value for the column using the given faker
+// if faker is nil, a default faker is used
+func (m publicreportQuickImageMods) RandomQuickID(f *faker.Faker) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(_ context.Context, o *PublicreportQuickImageTemplate) {
+ o.QuickID = func() int32 {
+ return random_int32(f)
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithParentsCascading() PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ if isDone, _ := publicreportQuickImageWithParentsCascadingCtx.Value(ctx); isDone {
+ return
+ }
+ ctx = publicreportQuickImageWithParentsCascadingCtx.WithValue(ctx, true)
+ {
+
+ related := o.f.NewPublicreportImageWithContext(ctx, PublicreportImageMods.WithParentsCascading())
+ m.WithImage(related).Apply(ctx, o)
+ }
+ {
+
+ related := o.f.NewPublicreportQuickWithContext(ctx, PublicreportQuickMods.WithParentsCascading())
+ m.WithQuick(related).Apply(ctx, o)
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithImage(rel *PublicreportImageTemplate) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Image = &publicreportQuickImageRImageR{
+ o: rel,
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithNewImage(mods ...PublicreportImageMod) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ related := o.f.NewPublicreportImageWithContext(ctx, mods...)
+
+ m.WithImage(related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportQuickImageMods) WithExistingImage(em *models.PublicreportImage) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Image = &publicreportQuickImageRImageR{
+ o: o.f.FromExistingPublicreportImage(em),
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithoutImage() PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Image = nil
+ })
+}
+
+func (m publicreportQuickImageMods) WithQuick(rel *PublicreportQuickTemplate) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Quick = &publicreportQuickImageRQuickR{
+ o: rel,
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithNewQuick(mods ...PublicreportQuickMod) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
+
+ m.WithQuick(related).Apply(ctx, o)
+ })
+}
+
+func (m publicreportQuickImageMods) WithExistingQuick(em *models.PublicreportQuick) PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Quick = &publicreportQuickImageRQuickR{
+ o: o.f.FromExistingPublicreportQuick(em),
+ }
+ })
+}
+
+func (m publicreportQuickImageMods) WithoutQuick() PublicreportQuickImageMod {
+ return PublicreportQuickImageModFunc(func(ctx context.Context, o *PublicreportQuickImageTemplate) {
+ o.r.Quick = nil
+ })
+}
diff --git a/db/factory/publicreport.quick_photo.bob.go b/db/factory/publicreport.quick_photo.bob.go
deleted file mode 100644
index 4bd2bfb9..00000000
--- a/db/factory/publicreport.quick_photo.bob.go
+++ /dev/null
@@ -1,498 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package factory
-
-import (
- "context"
- "testing"
-
- models "github.com/Gleipnir-Technology/nidus-sync/db/models"
- "github.com/aarondl/opt/omit"
- "github.com/google/uuid"
- "github.com/jaswdr/faker/v2"
- "github.com/stephenafamo/bob"
-)
-
-type PublicreportQuickPhotoMod interface {
- Apply(context.Context, *PublicreportQuickPhotoTemplate)
-}
-
-type PublicreportQuickPhotoModFunc func(context.Context, *PublicreportQuickPhotoTemplate)
-
-func (f PublicreportQuickPhotoModFunc) Apply(ctx context.Context, n *PublicreportQuickPhotoTemplate) {
- f(ctx, n)
-}
-
-type PublicreportQuickPhotoModSlice []PublicreportQuickPhotoMod
-
-func (mods PublicreportQuickPhotoModSlice) Apply(ctx context.Context, n *PublicreportQuickPhotoTemplate) {
- for _, f := range mods {
- f.Apply(ctx, n)
- }
-}
-
-// PublicreportQuickPhotoTemplate is an object representing the database table.
-// all columns are optional and should be set by mods
-type PublicreportQuickPhotoTemplate struct {
- ID func() int32
- Size func() int64
- Filename func() string
- QuickID func() int32
- UUID func() uuid.UUID
-
- r publicreportQuickPhotoR
- f *Factory
-
- alreadyPersisted bool
-}
-
-type publicreportQuickPhotoR struct {
- Quick *publicreportQuickPhotoRQuickR
-}
-
-type publicreportQuickPhotoRQuickR struct {
- o *PublicreportQuickTemplate
-}
-
-// Apply mods to the PublicreportQuickPhotoTemplate
-func (o *PublicreportQuickPhotoTemplate) Apply(ctx context.Context, mods ...PublicreportQuickPhotoMod) {
- for _, mod := range mods {
- mod.Apply(ctx, o)
- }
-}
-
-// setModelRels creates and sets the relationships on *models.PublicreportQuickPhoto
-// according to the relationships in the template. Nothing is inserted into the db
-func (t PublicreportQuickPhotoTemplate) setModelRels(o *models.PublicreportQuickPhoto) {
- if t.r.Quick != nil {
- rel := t.r.Quick.o.Build()
- rel.R.QuickPhotos = append(rel.R.QuickPhotos, o)
- o.QuickID = rel.ID // h2
- o.R.Quick = rel
- }
-}
-
-// BuildSetter returns an *models.PublicreportQuickPhotoSetter
-// this does nothing with the relationship templates
-func (o PublicreportQuickPhotoTemplate) BuildSetter() *models.PublicreportQuickPhotoSetter {
- m := &models.PublicreportQuickPhotoSetter{}
-
- if o.ID != nil {
- val := o.ID()
- m.ID = omit.From(val)
- }
- if o.Size != nil {
- val := o.Size()
- m.Size = omit.From(val)
- }
- if o.Filename != nil {
- val := o.Filename()
- m.Filename = omit.From(val)
- }
- if o.QuickID != nil {
- val := o.QuickID()
- m.QuickID = omit.From(val)
- }
- if o.UUID != nil {
- val := o.UUID()
- m.UUID = omit.From(val)
- }
-
- return m
-}
-
-// BuildManySetter returns an []*models.PublicreportQuickPhotoSetter
-// this does nothing with the relationship templates
-func (o PublicreportQuickPhotoTemplate) BuildManySetter(number int) []*models.PublicreportQuickPhotoSetter {
- m := make([]*models.PublicreportQuickPhotoSetter, number)
-
- for i := range m {
- m[i] = o.BuildSetter()
- }
-
- return m
-}
-
-// Build returns an *models.PublicreportQuickPhoto
-// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use PublicreportQuickPhotoTemplate.Create
-func (o PublicreportQuickPhotoTemplate) Build() *models.PublicreportQuickPhoto {
- m := &models.PublicreportQuickPhoto{}
-
- if o.ID != nil {
- m.ID = o.ID()
- }
- if o.Size != nil {
- m.Size = o.Size()
- }
- if o.Filename != nil {
- m.Filename = o.Filename()
- }
- if o.QuickID != nil {
- m.QuickID = o.QuickID()
- }
- if o.UUID != nil {
- m.UUID = o.UUID()
- }
-
- o.setModelRels(m)
-
- return m
-}
-
-// BuildMany returns an models.PublicreportQuickPhotoSlice
-// Related objects are also created and placed in the .R field
-// NOTE: Objects are not inserted into the database. Use PublicreportQuickPhotoTemplate.CreateMany
-func (o PublicreportQuickPhotoTemplate) BuildMany(number int) models.PublicreportQuickPhotoSlice {
- m := make(models.PublicreportQuickPhotoSlice, number)
-
- for i := range m {
- m[i] = o.Build()
- }
-
- return m
-}
-
-func ensureCreatablePublicreportQuickPhoto(m *models.PublicreportQuickPhotoSetter) {
- if !(m.Size.IsValue()) {
- val := random_int64(nil)
- m.Size = omit.From(val)
- }
- if !(m.Filename.IsValue()) {
- val := random_string(nil)
- m.Filename = omit.From(val)
- }
- if !(m.QuickID.IsValue()) {
- val := random_int32(nil)
- m.QuickID = omit.From(val)
- }
- if !(m.UUID.IsValue()) {
- val := random_uuid_UUID(nil)
- m.UUID = omit.From(val)
- }
-}
-
-// insertOptRels creates and inserts any optional the relationships on *models.PublicreportQuickPhoto
-// according to the relationships in the template.
-// any required relationship should have already exist on the model
-func (o *PublicreportQuickPhotoTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportQuickPhoto) error {
- var err error
-
- return err
-}
-
-// Create builds a publicreportQuickPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-func (o *PublicreportQuickPhotoTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportQuickPhoto, error) {
- var err error
- opt := o.BuildSetter()
- ensureCreatablePublicreportQuickPhoto(opt)
-
- if o.r.Quick == nil {
- PublicreportQuickPhotoMods.WithNewQuick().Apply(ctx, o)
- }
-
- var rel0 *models.PublicreportQuick
-
- if o.r.Quick.o.alreadyPersisted {
- rel0 = o.r.Quick.o.Build()
- } else {
- rel0, err = o.r.Quick.o.Create(ctx, exec)
- if err != nil {
- return nil, err
- }
- }
-
- opt.QuickID = omit.From(rel0.ID)
-
- m, err := models.PublicreportQuickPhotos.Insert(opt).One(ctx, exec)
- if err != nil {
- return nil, err
- }
-
- m.R.Quick = rel0
-
- if err := o.insertOptRels(ctx, exec, m); err != nil {
- return nil, err
- }
- return m, err
-}
-
-// MustCreate builds a publicreportQuickPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-// panics if an error occurs
-func (o *PublicreportQuickPhotoTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportQuickPhoto {
- m, err := o.Create(ctx, exec)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-// CreateOrFail builds a publicreportQuickPhoto and inserts it into the database
-// Relations objects are also inserted and placed in the .R field
-// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o *PublicreportQuickPhotoTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportQuickPhoto {
- tb.Helper()
- m, err := o.Create(ctx, exec)
- if err != nil {
- tb.Fatal(err)
- return nil
- }
- return m
-}
-
-// CreateMany builds multiple publicreportQuickPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-func (o PublicreportQuickPhotoTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportQuickPhotoSlice, error) {
- var err error
- m := make(models.PublicreportQuickPhotoSlice, number)
-
- for i := range m {
- m[i], err = o.Create(ctx, exec)
- if err != nil {
- return nil, err
- }
- }
-
- return m, nil
-}
-
-// MustCreateMany builds multiple publicreportQuickPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-// panics if an error occurs
-func (o PublicreportQuickPhotoTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportQuickPhotoSlice {
- m, err := o.CreateMany(ctx, exec, number)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-// CreateManyOrFail builds multiple publicreportQuickPhotos and inserts them into the database
-// Relations objects are also inserted and placed in the .R field
-// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
-func (o PublicreportQuickPhotoTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportQuickPhotoSlice {
- tb.Helper()
- m, err := o.CreateMany(ctx, exec, number)
- if err != nil {
- tb.Fatal(err)
- return nil
- }
- return m
-}
-
-// PublicreportQuickPhoto has methods that act as mods for the PublicreportQuickPhotoTemplate
-var PublicreportQuickPhotoMods publicreportQuickPhotoMods
-
-type publicreportQuickPhotoMods struct{}
-
-func (m publicreportQuickPhotoMods) RandomizeAllColumns(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModSlice{
- PublicreportQuickPhotoMods.RandomID(f),
- PublicreportQuickPhotoMods.RandomSize(f),
- PublicreportQuickPhotoMods.RandomFilename(f),
- PublicreportQuickPhotoMods.RandomQuickID(f),
- PublicreportQuickPhotoMods.RandomUUID(f),
- }
-}
-
-// Set the model columns to this value
-func (m publicreportQuickPhotoMods) ID(val int32) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.ID = func() int32 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportQuickPhotoMods) IDFunc(f func() int32) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.ID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportQuickPhotoMods) UnsetID() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.ID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportQuickPhotoMods) RandomID(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.ID = func() int32 {
- return random_int32(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportQuickPhotoMods) Size(val int64) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Size = func() int64 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportQuickPhotoMods) SizeFunc(f func() int64) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Size = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportQuickPhotoMods) UnsetSize() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Size = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportQuickPhotoMods) RandomSize(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Size = func() int64 {
- return random_int64(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportQuickPhotoMods) Filename(val string) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Filename = func() string { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportQuickPhotoMods) FilenameFunc(f func() string) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Filename = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportQuickPhotoMods) UnsetFilename() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Filename = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportQuickPhotoMods) RandomFilename(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.Filename = func() string {
- return random_string(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportQuickPhotoMods) QuickID(val int32) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.QuickID = func() int32 { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportQuickPhotoMods) QuickIDFunc(f func() int32) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.QuickID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportQuickPhotoMods) UnsetQuickID() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.QuickID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportQuickPhotoMods) RandomQuickID(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.QuickID = func() int32 {
- return random_int32(f)
- }
- })
-}
-
-// Set the model columns to this value
-func (m publicreportQuickPhotoMods) UUID(val uuid.UUID) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.UUID = func() uuid.UUID { return val }
- })
-}
-
-// Set the Column from the function
-func (m publicreportQuickPhotoMods) UUIDFunc(f func() uuid.UUID) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.UUID = f
- })
-}
-
-// Clear any values for the column
-func (m publicreportQuickPhotoMods) UnsetUUID() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.UUID = nil
- })
-}
-
-// Generates a random value for the column using the given faker
-// if faker is nil, a default faker is used
-func (m publicreportQuickPhotoMods) RandomUUID(f *faker.Faker) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(_ context.Context, o *PublicreportQuickPhotoTemplate) {
- o.UUID = func() uuid.UUID {
- return random_uuid_UUID(f)
- }
- })
-}
-
-func (m publicreportQuickPhotoMods) WithParentsCascading() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(ctx context.Context, o *PublicreportQuickPhotoTemplate) {
- if isDone, _ := publicreportQuickPhotoWithParentsCascadingCtx.Value(ctx); isDone {
- return
- }
- ctx = publicreportQuickPhotoWithParentsCascadingCtx.WithValue(ctx, true)
- {
-
- related := o.f.NewPublicreportQuickWithContext(ctx, PublicreportQuickMods.WithParentsCascading())
- m.WithQuick(related).Apply(ctx, o)
- }
- })
-}
-
-func (m publicreportQuickPhotoMods) WithQuick(rel *PublicreportQuickTemplate) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(ctx context.Context, o *PublicreportQuickPhotoTemplate) {
- o.r.Quick = &publicreportQuickPhotoRQuickR{
- o: rel,
- }
- })
-}
-
-func (m publicreportQuickPhotoMods) WithNewQuick(mods ...PublicreportQuickMod) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(ctx context.Context, o *PublicreportQuickPhotoTemplate) {
- related := o.f.NewPublicreportQuickWithContext(ctx, mods...)
-
- m.WithQuick(related).Apply(ctx, o)
- })
-}
-
-func (m publicreportQuickPhotoMods) WithExistingQuick(em *models.PublicreportQuick) PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(ctx context.Context, o *PublicreportQuickPhotoTemplate) {
- o.r.Quick = &publicreportQuickPhotoRQuickR{
- o: o.f.FromExistingPublicreportQuick(em),
- }
- })
-}
-
-func (m publicreportQuickPhotoMods) WithoutQuick() PublicreportQuickPhotoMod {
- return PublicreportQuickPhotoModFunc(func(ctx context.Context, o *PublicreportQuickPhotoTemplate) {
- o.r.Quick = nil
- })
-}
diff --git a/db/migrations/00035_photo_content_type.sql b/db/migrations/00035_photo_content_type.sql
new file mode 100644
index 00000000..cafad2e5
--- /dev/null
+++ b/db/migrations/00035_photo_content_type.sql
@@ -0,0 +1,37 @@
+-- +goose Up
+CREATE TABLE publicreport.image (
+ id SERIAL,
+ content_type TEXT NOT NULL,
+ created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+ location GEOGRAPHY,
+ resolution_x INTEGER NOT NULL,
+ resolution_y INTEGER NOT NULL,
+ storage_uuid UUID NOT NULL,
+ storage_size BIGINT NOT NULL,
+ uploaded_filename TEXT NOT NULL,
+ PRIMARY KEY(id)
+);
+CREATE TABLE publicreport.image_exif (
+ image_id INTEGER NOT NULL REFERENCES publicreport.image(id),
+ name TEXT NOT NULL,
+ value TEXT NOT NULL,
+ PRIMARY KEY(image_id, name, value)
+);
+CREATE TABLE publicreport.pool_image (
+ image_id INTEGER NOT NULL REFERENCES publicreport.image(id),
+ pool_id INTEGER NOT NULL REFERENCES publicreport.pool(id),
+ PRIMARY KEY (image_id, pool_id)
+);
+CREATE TABLE publicreport.quick_image (
+ image_id INTEGER NOT NULL REFERENCES publicreport.image(id),
+ quick_id INTEGER NOT NULL REFERENCES publicreport.quick(id),
+ PRIMARY KEY (image_id, quick_id)
+);
+DROP TABLE IF EXISTS publicreport.pool_photo;
+DROP TABLE IF EXISTS publicreport.quick_photo;
+-- +goose Down
+DROP TABLE publicreport.quick_image;
+DROP TABLE publicreport.pool_image;
+DROP TABLE publicreport.image_exif;
+DROP TABLE publicreport.image;
+-- that's right, I'm not rebuilding the pool_photo or quick_photo tables because I'm lazy.
diff --git a/db/models/bob_counts.bob.go b/db/models/bob_counts.bob.go
index be17543e..de00d405 100644
--- a/db/models/bob_counts.bob.go
+++ b/db/models/bob_counts.bob.go
@@ -25,6 +25,7 @@ type preloadCounts struct {
NoteAudio noteAudioCountPreloader
NoteImage noteImageCountPreloader
Organization organizationCountPreloader
+ PublicreportImage publicreportImageCountPreloader
PublicreportPool publicreportPoolCountPreloader
PublicreportQuick publicreportQuickCountPreloader
User userCountPreloader
@@ -36,6 +37,7 @@ func getPreloadCount() preloadCounts {
NoteAudio: buildNoteAudioCountPreloader(),
NoteImage: buildNoteImageCountPreloader(),
Organization: buildOrganizationCountPreloader(),
+ PublicreportImage: buildPublicreportImageCountPreloader(),
PublicreportPool: buildPublicreportPoolCountPreloader(),
PublicreportQuick: buildPublicreportQuickCountPreloader(),
User: buildUserCountPreloader(),
@@ -47,6 +49,7 @@ type thenLoadCounts[Q orm.Loadable] struct {
NoteAudio noteAudioCountThenLoader[Q]
NoteImage noteImageCountThenLoader[Q]
Organization organizationCountThenLoader[Q]
+ PublicreportImage publicreportImageCountThenLoader[Q]
PublicreportPool publicreportPoolCountThenLoader[Q]
PublicreportQuick publicreportQuickCountThenLoader[Q]
User userCountThenLoader[Q]
@@ -58,6 +61,7 @@ func getThenLoadCount[Q orm.Loadable]() thenLoadCounts[Q] {
NoteAudio: buildNoteAudioCountThenLoader[Q](),
NoteImage: buildNoteImageCountThenLoader[Q](),
Organization: buildOrganizationCountThenLoader[Q](),
+ PublicreportImage: buildPublicreportImageCountThenLoader[Q](),
PublicreportPool: buildPublicreportPoolCountThenLoader[Q](),
PublicreportQuick: buildPublicreportQuickCountThenLoader[Q](),
User: buildUserCountThenLoader[Q](),
diff --git a/db/models/bob_joins.bob.go b/db/models/bob_joins.bob.go
index ef21e961..f387e8d3 100644
--- a/db/models/bob_joins.bob.go
+++ b/db/models/bob_joins.bob.go
@@ -73,10 +73,12 @@ type joins[Q dialect.Joinable] struct {
Notifications joinSet[notificationJoins[Q]]
OauthTokens joinSet[oauthTokenJoins[Q]]
Organizations joinSet[organizationJoins[Q]]
+ PublicreportImages joinSet[publicreportImageJoins[Q]]
+ PublicreportImageExifs joinSet[publicreportImageExifJoins[Q]]
PublicreportPools joinSet[publicreportPoolJoins[Q]]
- PublicreportPoolPhotos joinSet[publicreportPoolPhotoJoins[Q]]
+ PublicreportPoolImages joinSet[publicreportPoolImageJoins[Q]]
PublicreportQuicks joinSet[publicreportQuickJoins[Q]]
- PublicreportQuickPhotos joinSet[publicreportQuickPhotoJoins[Q]]
+ PublicreportQuickImages joinSet[publicreportQuickImageJoins[Q]]
Users joinSet[userJoins[Q]]
}
@@ -131,10 +133,12 @@ func getJoins[Q dialect.Joinable]() joins[Q] {
Notifications: buildJoinSet[notificationJoins[Q]](Notifications.Columns, buildNotificationJoins),
OauthTokens: buildJoinSet[oauthTokenJoins[Q]](OauthTokens.Columns, buildOauthTokenJoins),
Organizations: buildJoinSet[organizationJoins[Q]](Organizations.Columns, buildOrganizationJoins),
+ PublicreportImages: buildJoinSet[publicreportImageJoins[Q]](PublicreportImages.Columns, buildPublicreportImageJoins),
+ PublicreportImageExifs: buildJoinSet[publicreportImageExifJoins[Q]](PublicreportImageExifs.Columns, buildPublicreportImageExifJoins),
PublicreportPools: buildJoinSet[publicreportPoolJoins[Q]](PublicreportPools.Columns, buildPublicreportPoolJoins),
- PublicreportPoolPhotos: buildJoinSet[publicreportPoolPhotoJoins[Q]](PublicreportPoolPhotos.Columns, buildPublicreportPoolPhotoJoins),
+ PublicreportPoolImages: buildJoinSet[publicreportPoolImageJoins[Q]](PublicreportPoolImages.Columns, buildPublicreportPoolImageJoins),
PublicreportQuicks: buildJoinSet[publicreportQuickJoins[Q]](PublicreportQuicks.Columns, buildPublicreportQuickJoins),
- PublicreportQuickPhotos: buildJoinSet[publicreportQuickPhotoJoins[Q]](PublicreportQuickPhotos.Columns, buildPublicreportQuickPhotoJoins),
+ PublicreportQuickImages: buildJoinSet[publicreportQuickImageJoins[Q]](PublicreportQuickImages.Columns, buildPublicreportQuickImageJoins),
Users: buildJoinSet[userJoins[Q]](Users.Columns, buildUserJoins),
}
}
diff --git a/db/models/bob_loaders.bob.go b/db/models/bob_loaders.bob.go
index 50d02a99..fe6d28c7 100644
--- a/db/models/bob_loaders.bob.go
+++ b/db/models/bob_loaders.bob.go
@@ -58,10 +58,12 @@ type preloaders struct {
Notification notificationPreloader
OauthToken oauthTokenPreloader
Organization organizationPreloader
+ PublicreportImage publicreportImagePreloader
+ PublicreportImageExif publicreportImageExifPreloader
PublicreportPool publicreportPoolPreloader
- PublicreportPoolPhoto publicreportPoolPhotoPreloader
+ PublicreportPoolImage publicreportPoolImagePreloader
PublicreportQuick publicreportQuickPreloader
- PublicreportQuickPhoto publicreportQuickPhotoPreloader
+ PublicreportQuickImage publicreportQuickImagePreloader
User userPreloader
}
@@ -108,10 +110,12 @@ func getPreloaders() preloaders {
Notification: buildNotificationPreloader(),
OauthToken: buildOauthTokenPreloader(),
Organization: buildOrganizationPreloader(),
+ PublicreportImage: buildPublicreportImagePreloader(),
+ PublicreportImageExif: buildPublicreportImageExifPreloader(),
PublicreportPool: buildPublicreportPoolPreloader(),
- PublicreportPoolPhoto: buildPublicreportPoolPhotoPreloader(),
+ PublicreportPoolImage: buildPublicreportPoolImagePreloader(),
PublicreportQuick: buildPublicreportQuickPreloader(),
- PublicreportQuickPhoto: buildPublicreportQuickPhotoPreloader(),
+ PublicreportQuickImage: buildPublicreportQuickImagePreloader(),
User: buildUserPreloader(),
}
}
@@ -164,10 +168,12 @@ type thenLoaders[Q orm.Loadable] struct {
Notification notificationThenLoader[Q]
OauthToken oauthTokenThenLoader[Q]
Organization organizationThenLoader[Q]
+ PublicreportImage publicreportImageThenLoader[Q]
+ PublicreportImageExif publicreportImageExifThenLoader[Q]
PublicreportPool publicreportPoolThenLoader[Q]
- PublicreportPoolPhoto publicreportPoolPhotoThenLoader[Q]
+ PublicreportPoolImage publicreportPoolImageThenLoader[Q]
PublicreportQuick publicreportQuickThenLoader[Q]
- PublicreportQuickPhoto publicreportQuickPhotoThenLoader[Q]
+ PublicreportQuickImage publicreportQuickImageThenLoader[Q]
User userThenLoader[Q]
}
@@ -214,10 +220,12 @@ func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] {
Notification: buildNotificationThenLoader[Q](),
OauthToken: buildOauthTokenThenLoader[Q](),
Organization: buildOrganizationThenLoader[Q](),
+ PublicreportImage: buildPublicreportImageThenLoader[Q](),
+ PublicreportImageExif: buildPublicreportImageExifThenLoader[Q](),
PublicreportPool: buildPublicreportPoolThenLoader[Q](),
- PublicreportPoolPhoto: buildPublicreportPoolPhotoThenLoader[Q](),
+ PublicreportPoolImage: buildPublicreportPoolImageThenLoader[Q](),
PublicreportQuick: buildPublicreportQuickThenLoader[Q](),
- PublicreportQuickPhoto: buildPublicreportQuickPhotoThenLoader[Q](),
+ PublicreportQuickImage: buildPublicreportQuickImageThenLoader[Q](),
User: buildUserThenLoader[Q](),
}
}
diff --git a/db/models/bob_where.bob.go b/db/models/bob_where.bob.go
index 046968ad..4b2c8b5a 100644
--- a/db/models/bob_where.bob.go
+++ b/db/models/bob_where.bob.go
@@ -61,11 +61,13 @@ func Where[Q psql.Filterable]() struct {
Notifications notificationWhere[Q]
OauthTokens oauthTokenWhere[Q]
Organizations organizationWhere[Q]
+ PublicreportImages publicreportImageWhere[Q]
+ PublicreportImageExifs publicreportImageExifWhere[Q]
PublicreportNuisances publicreportNuisanceWhere[Q]
PublicreportPools publicreportPoolWhere[Q]
- PublicreportPoolPhotos publicreportPoolPhotoWhere[Q]
+ PublicreportPoolImages publicreportPoolImageWhere[Q]
PublicreportQuicks publicreportQuickWhere[Q]
- PublicreportQuickPhotos publicreportQuickPhotoWhere[Q]
+ PublicreportQuickImages publicreportQuickImageWhere[Q]
PublicreportReportLocations publicreportReportLocationWhere[Q]
RasterColumns rasterColumnWhere[Q]
RasterOverviews rasterOverviewWhere[Q]
@@ -118,11 +120,13 @@ func Where[Q psql.Filterable]() struct {
Notifications notificationWhere[Q]
OauthTokens oauthTokenWhere[Q]
Organizations organizationWhere[Q]
+ PublicreportImages publicreportImageWhere[Q]
+ PublicreportImageExifs publicreportImageExifWhere[Q]
PublicreportNuisances publicreportNuisanceWhere[Q]
PublicreportPools publicreportPoolWhere[Q]
- PublicreportPoolPhotos publicreportPoolPhotoWhere[Q]
+ PublicreportPoolImages publicreportPoolImageWhere[Q]
PublicreportQuicks publicreportQuickWhere[Q]
- PublicreportQuickPhotos publicreportQuickPhotoWhere[Q]
+ PublicreportQuickImages publicreportQuickImageWhere[Q]
PublicreportReportLocations publicreportReportLocationWhere[Q]
RasterColumns rasterColumnWhere[Q]
RasterOverviews rasterOverviewWhere[Q]
@@ -174,11 +178,13 @@ func Where[Q psql.Filterable]() struct {
Notifications: buildNotificationWhere[Q](Notifications.Columns),
OauthTokens: buildOauthTokenWhere[Q](OauthTokens.Columns),
Organizations: buildOrganizationWhere[Q](Organizations.Columns),
+ PublicreportImages: buildPublicreportImageWhere[Q](PublicreportImages.Columns),
+ PublicreportImageExifs: buildPublicreportImageExifWhere[Q](PublicreportImageExifs.Columns),
PublicreportNuisances: buildPublicreportNuisanceWhere[Q](PublicreportNuisances.Columns),
PublicreportPools: buildPublicreportPoolWhere[Q](PublicreportPools.Columns),
- PublicreportPoolPhotos: buildPublicreportPoolPhotoWhere[Q](PublicreportPoolPhotos.Columns),
+ PublicreportPoolImages: buildPublicreportPoolImageWhere[Q](PublicreportPoolImages.Columns),
PublicreportQuicks: buildPublicreportQuickWhere[Q](PublicreportQuicks.Columns),
- PublicreportQuickPhotos: buildPublicreportQuickPhotoWhere[Q](PublicreportQuickPhotos.Columns),
+ PublicreportQuickImages: buildPublicreportQuickImageWhere[Q](PublicreportQuickImages.Columns),
PublicreportReportLocations: buildPublicreportReportLocationWhere[Q](PublicreportReportLocations.Columns),
RasterColumns: buildRasterColumnWhere[Q](RasterColumns.Columns),
RasterOverviews: buildRasterOverviewWhere[Q](RasterOverviews.Columns),
diff --git a/db/models/publicreport.image.bob.go b/db/models/publicreport.image.bob.go
new file mode 100644
index 00000000..01aae3bd
--- /dev/null
+++ b/db/models/publicreport.image.bob.go
@@ -0,0 +1,1440 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "strconv"
+ "time"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/google/uuid"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+ "github.com/stephenafamo/scan"
+)
+
+// PublicreportImage is an object representing the database table.
+type PublicreportImage struct {
+ ID int32 `db:"id,pk" `
+ ContentType string `db:"content_type" `
+ Created time.Time `db:"created" `
+ ResolutionX int32 `db:"resolution_x" `
+ ResolutionY int32 `db:"resolution_y" `
+ StorageUUID uuid.UUID `db:"storage_uuid" `
+ StorageSize int64 `db:"storage_size" `
+ UploadedFilename string `db:"uploaded_filename" `
+
+ R publicreportImageR `db:"-" `
+
+ C publicreportImageC `db:"-" `
+}
+
+// PublicreportImageSlice is an alias for a slice of pointers to PublicreportImage.
+// This should almost always be used instead of []*PublicreportImage.
+type PublicreportImageSlice []*PublicreportImage
+
+// PublicreportImages contains methods to work with the image table
+var PublicreportImages = psql.NewTablex[*PublicreportImage, PublicreportImageSlice, *PublicreportImageSetter]("publicreport", "image", buildPublicreportImageColumns("publicreport.image"))
+
+// PublicreportImagesQuery is a query on the image table
+type PublicreportImagesQuery = *psql.ViewQuery[*PublicreportImage, PublicreportImageSlice]
+
+// publicreportImageR is where relationships are stored.
+type publicreportImageR struct {
+ ImageExifs PublicreportImageExifSlice // publicreport.image_exif.image_exif_image_id_fkey
+ Pools PublicreportPoolSlice // publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey
+ Quicks PublicreportQuickSlice // publicreport.quick_image.quick_image_image_id_fkeypublicreport.quick_image.quick_image_quick_id_fkey
+}
+
+func buildPublicreportImageColumns(alias string) publicreportImageColumns {
+ return publicreportImageColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "id", "content_type", "created", "resolution_x", "resolution_y", "storage_uuid", "storage_size", "uploaded_filename",
+ ).WithParent("publicreport.image"),
+ tableAlias: alias,
+ ID: psql.Quote(alias, "id"),
+ ContentType: psql.Quote(alias, "content_type"),
+ Created: psql.Quote(alias, "created"),
+ ResolutionX: psql.Quote(alias, "resolution_x"),
+ ResolutionY: psql.Quote(alias, "resolution_y"),
+ StorageUUID: psql.Quote(alias, "storage_uuid"),
+ StorageSize: psql.Quote(alias, "storage_size"),
+ UploadedFilename: psql.Quote(alias, "uploaded_filename"),
+ }
+}
+
+type publicreportImageColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ ID psql.Expression
+ ContentType psql.Expression
+ Created psql.Expression
+ ResolutionX psql.Expression
+ ResolutionY psql.Expression
+ StorageUUID psql.Expression
+ StorageSize psql.Expression
+ UploadedFilename psql.Expression
+}
+
+func (c publicreportImageColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (publicreportImageColumns) AliasedAs(alias string) publicreportImageColumns {
+ return buildPublicreportImageColumns(alias)
+}
+
+// PublicreportImageSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type PublicreportImageSetter struct {
+ ID omit.Val[int32] `db:"id,pk" `
+ ContentType omit.Val[string] `db:"content_type" `
+ Created omit.Val[time.Time] `db:"created" `
+ ResolutionX omit.Val[int32] `db:"resolution_x" `
+ ResolutionY omit.Val[int32] `db:"resolution_y" `
+ StorageUUID omit.Val[uuid.UUID] `db:"storage_uuid" `
+ StorageSize omit.Val[int64] `db:"storage_size" `
+ UploadedFilename omit.Val[string] `db:"uploaded_filename" `
+}
+
+func (s PublicreportImageSetter) SetColumns() []string {
+ vals := make([]string, 0, 8)
+ if s.ID.IsValue() {
+ vals = append(vals, "id")
+ }
+ if s.ContentType.IsValue() {
+ vals = append(vals, "content_type")
+ }
+ if s.Created.IsValue() {
+ vals = append(vals, "created")
+ }
+ if s.ResolutionX.IsValue() {
+ vals = append(vals, "resolution_x")
+ }
+ if s.ResolutionY.IsValue() {
+ vals = append(vals, "resolution_y")
+ }
+ if s.StorageUUID.IsValue() {
+ vals = append(vals, "storage_uuid")
+ }
+ if s.StorageSize.IsValue() {
+ vals = append(vals, "storage_size")
+ }
+ if s.UploadedFilename.IsValue() {
+ vals = append(vals, "uploaded_filename")
+ }
+ return vals
+}
+
+func (s PublicreportImageSetter) Overwrite(t *PublicreportImage) {
+ if s.ID.IsValue() {
+ t.ID = s.ID.MustGet()
+ }
+ if s.ContentType.IsValue() {
+ t.ContentType = s.ContentType.MustGet()
+ }
+ if s.Created.IsValue() {
+ t.Created = s.Created.MustGet()
+ }
+ if s.ResolutionX.IsValue() {
+ t.ResolutionX = s.ResolutionX.MustGet()
+ }
+ if s.ResolutionY.IsValue() {
+ t.ResolutionY = s.ResolutionY.MustGet()
+ }
+ if s.StorageUUID.IsValue() {
+ t.StorageUUID = s.StorageUUID.MustGet()
+ }
+ if s.StorageSize.IsValue() {
+ t.StorageSize = s.StorageSize.MustGet()
+ }
+ if s.UploadedFilename.IsValue() {
+ t.UploadedFilename = s.UploadedFilename.MustGet()
+ }
+}
+
+func (s *PublicreportImageSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImages.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 8)
+ if s.ID.IsValue() {
+ vals[0] = psql.Arg(s.ID.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.ContentType.IsValue() {
+ vals[1] = psql.Arg(s.ContentType.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ if s.Created.IsValue() {
+ vals[2] = psql.Arg(s.Created.MustGet())
+ } else {
+ vals[2] = psql.Raw("DEFAULT")
+ }
+
+ if s.ResolutionX.IsValue() {
+ vals[3] = psql.Arg(s.ResolutionX.MustGet())
+ } else {
+ vals[3] = psql.Raw("DEFAULT")
+ }
+
+ if s.ResolutionY.IsValue() {
+ vals[4] = psql.Arg(s.ResolutionY.MustGet())
+ } else {
+ vals[4] = psql.Raw("DEFAULT")
+ }
+
+ if s.StorageUUID.IsValue() {
+ vals[5] = psql.Arg(s.StorageUUID.MustGet())
+ } else {
+ vals[5] = psql.Raw("DEFAULT")
+ }
+
+ if s.StorageSize.IsValue() {
+ vals[6] = psql.Arg(s.StorageSize.MustGet())
+ } else {
+ vals[6] = psql.Raw("DEFAULT")
+ }
+
+ if s.UploadedFilename.IsValue() {
+ vals[7] = psql.Arg(s.UploadedFilename.MustGet())
+ } else {
+ vals[7] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s PublicreportImageSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s PublicreportImageSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 8)
+
+ if s.ID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "id")...),
+ psql.Arg(s.ID),
+ }})
+ }
+
+ if s.ContentType.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "content_type")...),
+ psql.Arg(s.ContentType),
+ }})
+ }
+
+ if s.Created.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "created")...),
+ psql.Arg(s.Created),
+ }})
+ }
+
+ if s.ResolutionX.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "resolution_x")...),
+ psql.Arg(s.ResolutionX),
+ }})
+ }
+
+ if s.ResolutionY.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "resolution_y")...),
+ psql.Arg(s.ResolutionY),
+ }})
+ }
+
+ if s.StorageUUID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "storage_uuid")...),
+ psql.Arg(s.StorageUUID),
+ }})
+ }
+
+ if s.StorageSize.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "storage_size")...),
+ psql.Arg(s.StorageSize),
+ }})
+ }
+
+ if s.UploadedFilename.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "uploaded_filename")...),
+ psql.Arg(s.UploadedFilename),
+ }})
+ }
+
+ return exprs
+}
+
+// FindPublicreportImage retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindPublicreportImage(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportImage, error) {
+ if len(cols) == 0 {
+ return PublicreportImages.Query(
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(IDPK))),
+ ).One(ctx, exec)
+ }
+
+ return PublicreportImages.Query(
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(IDPK))),
+ sm.Columns(PublicreportImages.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// PublicreportImageExists checks the presence of a single record by primary key
+func PublicreportImageExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
+ return PublicreportImages.Query(
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(IDPK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after PublicreportImage is retrieved from the database
+func (o *PublicreportImage) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportImages.AfterSelectHooks.RunHooks(ctx, exec, PublicreportImageSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportImages.AfterInsertHooks.RunHooks(ctx, exec, PublicreportImageSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportImages.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportImageSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportImages.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportImageSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the PublicreportImage
+func (o *PublicreportImage) primaryKeyVals() bob.Expression {
+ return psql.Arg(o.ID)
+}
+
+func (o *PublicreportImage) pkEQ() dialect.Expression {
+ return psql.Quote("publicreport.image", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the PublicreportImage
+func (o *PublicreportImage) Update(ctx context.Context, exec bob.Executor, s *PublicreportImageSetter) error {
+ v, err := PublicreportImages.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single PublicreportImage record with an executor
+func (o *PublicreportImage) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := PublicreportImages.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the PublicreportImage using the executor
+func (o *PublicreportImage) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := PublicreportImages.Query(
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(o.ID))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after PublicreportImageSlice is retrieved from the database
+func (o PublicreportImageSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportImages.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportImages.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o PublicreportImageSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Quote("publicreport.image", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o PublicreportImageSlice) copyMatchingRows(from ...*PublicreportImage) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.ID != old.ID {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o PublicreportImageSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImages.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportImage or a slice of PublicreportImage
+ // then run the AfterUpdateHooks on the slice
+ _, err = PublicreportImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o PublicreportImageSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImages.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportImage or a slice of PublicreportImage
+ // then run the AfterDeleteHooks on the slice
+ _, err = PublicreportImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o PublicreportImageSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportImageSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportImages.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o PublicreportImageSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportImages.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o PublicreportImageSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := PublicreportImages.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// ImageExifs starts a query for related objects on publicreport.image_exif
+func (o *PublicreportImage) ImageExifs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImageExifsQuery {
+ return PublicreportImageExifs.Query(append(mods,
+ sm.Where(PublicreportImageExifs.Columns.ImageID.EQ(psql.Arg(o.ID))),
+ )...)
+}
+
+func (os PublicreportImageSlice) ImageExifs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImageExifsQuery {
+ pkID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkID = append(pkID, o.ID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
+ ))
+
+ return PublicreportImageExifs.Query(append(mods,
+ sm.Where(psql.Group(PublicreportImageExifs.Columns.ImageID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+// Pools starts a query for related objects on publicreport.pool
+func (o *PublicreportImage) Pools(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
+ return PublicreportPools.Query(append(mods,
+ sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
+ PublicreportPools.Columns.ID.EQ(PublicreportPoolImages.Columns.PoolID)),
+ sm.Where(PublicreportPoolImages.Columns.ImageID.EQ(psql.Arg(o.ID))),
+ )...)
+}
+
+func (os PublicreportImageSlice) Pools(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
+ pkID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkID = append(pkID, o.ID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
+ ))
+
+ return PublicreportPools.Query(append(mods,
+ sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
+ PublicreportPools.Columns.ID.EQ(PublicreportPoolImages.Columns.PoolID),
+ ),
+ sm.Where(psql.Group(PublicreportPoolImages.Columns.ImageID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+// Quicks starts a query for related objects on publicreport.quick
+func (o *PublicreportImage) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
+ return PublicreportQuicks.Query(append(mods,
+ sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
+ PublicreportQuicks.Columns.ID.EQ(PublicreportQuickImages.Columns.QuickID)),
+ sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(o.ID))),
+ )...)
+}
+
+func (os PublicreportImageSlice) Quicks(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
+ pkID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkID = append(pkID, o.ID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
+ ))
+
+ return PublicreportQuicks.Query(append(mods,
+ sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
+ PublicreportQuicks.Columns.ID.EQ(PublicreportQuickImages.Columns.QuickID),
+ ),
+ sm.Where(psql.Group(PublicreportQuickImages.Columns.ImageID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func insertPublicreportImageImageExifs0(ctx context.Context, exec bob.Executor, publicreportImageExifs1 []*PublicreportImageExifSetter, publicreportImage0 *PublicreportImage) (PublicreportImageExifSlice, error) {
+ for i := range publicreportImageExifs1 {
+ publicreportImageExifs1[i].ImageID = omit.From(publicreportImage0.ID)
+ }
+
+ ret, err := PublicreportImageExifs.Insert(bob.ToMods(publicreportImageExifs1...)).All(ctx, exec)
+ if err != nil {
+ return ret, fmt.Errorf("insertPublicreportImageImageExifs0: %w", err)
+ }
+
+ return ret, nil
+}
+
+func attachPublicreportImageImageExifs0(ctx context.Context, exec bob.Executor, count int, publicreportImageExifs1 PublicreportImageExifSlice, publicreportImage0 *PublicreportImage) (PublicreportImageExifSlice, error) {
+ setter := &PublicreportImageExifSetter{
+ ImageID: omit.From(publicreportImage0.ID),
+ }
+
+ err := publicreportImageExifs1.UpdateAll(ctx, exec, *setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportImageImageExifs0: %w", err)
+ }
+
+ return publicreportImageExifs1, nil
+}
+
+func (publicreportImage0 *PublicreportImage) InsertImageExifs(ctx context.Context, exec bob.Executor, related ...*PublicreportImageExifSetter) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+
+ publicreportImageExifs1, err := insertPublicreportImageImageExifs0(ctx, exec, related, publicreportImage0)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.ImageExifs = append(publicreportImage0.R.ImageExifs, publicreportImageExifs1...)
+
+ for _, rel := range publicreportImageExifs1 {
+ rel.R.Image = publicreportImage0
+ }
+ return nil
+}
+
+func (publicreportImage0 *PublicreportImage) AttachImageExifs(ctx context.Context, exec bob.Executor, related ...*PublicreportImageExif) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+ publicreportImageExifs1 := PublicreportImageExifSlice(related)
+
+ _, err = attachPublicreportImageImageExifs0(ctx, exec, len(related), publicreportImageExifs1, publicreportImage0)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.ImageExifs = append(publicreportImage0.R.ImageExifs, publicreportImageExifs1...)
+
+ for _, rel := range related {
+ rel.R.Image = publicreportImage0
+ }
+
+ return nil
+}
+
+func attachPublicreportImagePools0(ctx context.Context, exec bob.Executor, count int, publicreportImage0 *PublicreportImage, publicreportPools2 PublicreportPoolSlice) (PublicreportPoolImageSlice, error) {
+ setters := make([]*PublicreportPoolImageSetter, count)
+ for i := range count {
+ setters[i] = &PublicreportPoolImageSetter{
+ ImageID: omit.From(publicreportImage0.ID),
+ PoolID: omit.From(publicreportPools2[i].ID),
+ }
+ }
+
+ publicreportPoolImages1, err := PublicreportPoolImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportImagePools0: %w", err)
+ }
+
+ return publicreportPoolImages1, nil
+}
+
+func (publicreportImage0 *PublicreportImage) InsertPools(ctx context.Context, exec bob.Executor, related ...*PublicreportPoolSetter) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+
+ inserted, err := PublicreportPools.Insert(bob.ToMods(related...)).All(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+ publicreportPools2 := PublicreportPoolSlice(inserted)
+
+ _, err = attachPublicreportImagePools0(ctx, exec, len(related), publicreportImage0, publicreportPools2)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.Pools = append(publicreportImage0.R.Pools, publicreportPools2...)
+
+ for _, rel := range publicreportPools2 {
+ rel.R.Images = append(rel.R.Images, publicreportImage0)
+ }
+ return nil
+}
+
+func (publicreportImage0 *PublicreportImage) AttachPools(ctx context.Context, exec bob.Executor, related ...*PublicreportPool) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+ publicreportPools2 := PublicreportPoolSlice(related)
+
+ _, err = attachPublicreportImagePools0(ctx, exec, len(related), publicreportImage0, publicreportPools2)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.Pools = append(publicreportImage0.R.Pools, publicreportPools2...)
+
+ for _, rel := range related {
+ rel.R.Images = append(rel.R.Images, publicreportImage0)
+ }
+
+ return nil
+}
+
+func attachPublicreportImageQuicks0(ctx context.Context, exec bob.Executor, count int, publicreportImage0 *PublicreportImage, publicreportQuicks2 PublicreportQuickSlice) (PublicreportQuickImageSlice, error) {
+ setters := make([]*PublicreportQuickImageSetter, count)
+ for i := range count {
+ setters[i] = &PublicreportQuickImageSetter{
+ ImageID: omit.From(publicreportImage0.ID),
+ QuickID: omit.From(publicreportQuicks2[i].ID),
+ }
+ }
+
+ publicreportQuickImages1, err := PublicreportQuickImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportImageQuicks0: %w", err)
+ }
+
+ return publicreportQuickImages1, nil
+}
+
+func (publicreportImage0 *PublicreportImage) InsertQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuickSetter) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+
+ inserted, err := PublicreportQuicks.Insert(bob.ToMods(related...)).All(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+ publicreportQuicks2 := PublicreportQuickSlice(inserted)
+
+ _, err = attachPublicreportImageQuicks0(ctx, exec, len(related), publicreportImage0, publicreportQuicks2)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.Quicks = append(publicreportImage0.R.Quicks, publicreportQuicks2...)
+
+ for _, rel := range publicreportQuicks2 {
+ rel.R.Images = append(rel.R.Images, publicreportImage0)
+ }
+ return nil
+}
+
+func (publicreportImage0 *PublicreportImage) AttachQuicks(ctx context.Context, exec bob.Executor, related ...*PublicreportQuick) error {
+ if len(related) == 0 {
+ return nil
+ }
+
+ var err error
+ publicreportQuicks2 := PublicreportQuickSlice(related)
+
+ _, err = attachPublicreportImageQuicks0(ctx, exec, len(related), publicreportImage0, publicreportQuicks2)
+ if err != nil {
+ return err
+ }
+
+ publicreportImage0.R.Quicks = append(publicreportImage0.R.Quicks, publicreportQuicks2...)
+
+ for _, rel := range related {
+ rel.R.Images = append(rel.R.Images, publicreportImage0)
+ }
+
+ return nil
+}
+
+type publicreportImageWhere[Q psql.Filterable] struct {
+ ID psql.WhereMod[Q, int32]
+ ContentType psql.WhereMod[Q, string]
+ Created psql.WhereMod[Q, time.Time]
+ ResolutionX psql.WhereMod[Q, int32]
+ ResolutionY psql.WhereMod[Q, int32]
+ StorageUUID psql.WhereMod[Q, uuid.UUID]
+ StorageSize psql.WhereMod[Q, int64]
+ UploadedFilename psql.WhereMod[Q, string]
+}
+
+func (publicreportImageWhere[Q]) AliasedAs(alias string) publicreportImageWhere[Q] {
+ return buildPublicreportImageWhere[Q](buildPublicreportImageColumns(alias))
+}
+
+func buildPublicreportImageWhere[Q psql.Filterable](cols publicreportImageColumns) publicreportImageWhere[Q] {
+ return publicreportImageWhere[Q]{
+ ID: psql.Where[Q, int32](cols.ID),
+ ContentType: psql.Where[Q, string](cols.ContentType),
+ Created: psql.Where[Q, time.Time](cols.Created),
+ ResolutionX: psql.Where[Q, int32](cols.ResolutionX),
+ ResolutionY: psql.Where[Q, int32](cols.ResolutionY),
+ StorageUUID: psql.Where[Q, uuid.UUID](cols.StorageUUID),
+ StorageSize: psql.Where[Q, int64](cols.StorageSize),
+ UploadedFilename: psql.Where[Q, string](cols.UploadedFilename),
+ }
+}
+
+func (o *PublicreportImage) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "ImageExifs":
+ rels, ok := retrieved.(PublicreportImageExifSlice)
+ if !ok {
+ return fmt.Errorf("publicreportImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.ImageExifs = rels
+
+ for _, rel := range rels {
+ if rel != nil {
+ rel.R.Image = o
+ }
+ }
+ return nil
+ case "Pools":
+ rels, ok := retrieved.(PublicreportPoolSlice)
+ if !ok {
+ return fmt.Errorf("publicreportImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Pools = rels
+
+ for _, rel := range rels {
+ if rel != nil {
+ rel.R.Images = PublicreportImageSlice{o}
+ }
+ }
+ return nil
+ case "Quicks":
+ rels, ok := retrieved.(PublicreportQuickSlice)
+ if !ok {
+ return fmt.Errorf("publicreportImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Quicks = rels
+
+ for _, rel := range rels {
+ if rel != nil {
+ rel.R.Images = PublicreportImageSlice{o}
+ }
+ }
+ return nil
+ default:
+ return fmt.Errorf("publicreportImage has no relationship %q", name)
+ }
+}
+
+type publicreportImagePreloader struct{}
+
+func buildPublicreportImagePreloader() publicreportImagePreloader {
+ return publicreportImagePreloader{}
+}
+
+type publicreportImageThenLoader[Q orm.Loadable] struct {
+ ImageExifs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportImageThenLoader[Q orm.Loadable]() publicreportImageThenLoader[Q] {
+ type ImageExifsLoadInterface interface {
+ LoadImageExifs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PoolsLoadInterface interface {
+ LoadPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type QuicksLoadInterface interface {
+ LoadQuicks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportImageThenLoader[Q]{
+ ImageExifs: thenLoadBuilder[Q](
+ "ImageExifs",
+ func(ctx context.Context, exec bob.Executor, retrieved ImageExifsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImageExifs(ctx, exec, mods...)
+ },
+ ),
+ Pools: thenLoadBuilder[Q](
+ "Pools",
+ func(ctx context.Context, exec bob.Executor, retrieved PoolsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadPools(ctx, exec, mods...)
+ },
+ ),
+ Quicks: thenLoadBuilder[Q](
+ "Quicks",
+ func(ctx context.Context, exec bob.Executor, retrieved QuicksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadQuicks(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadImageExifs loads the publicreportImage's ImageExifs into the .R struct
+func (o *PublicreportImage) LoadImageExifs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.ImageExifs = nil
+
+ related, err := o.ImageExifs(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, rel := range related {
+ rel.R.Image = o
+ }
+
+ o.R.ImageExifs = related
+ return nil
+}
+
+// LoadImageExifs loads the publicreportImage's ImageExifs into the .R struct
+func (os PublicreportImageSlice) LoadImageExifs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportImageExifs, err := os.ImageExifs(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ o.R.ImageExifs = nil
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportImageExifs {
+
+ if !(o.ID == rel.ImageID) {
+ continue
+ }
+
+ rel.R.Image = o
+
+ o.R.ImageExifs = append(o.R.ImageExifs, rel)
+ }
+ }
+
+ return nil
+}
+
+// LoadPools loads the publicreportImage's Pools into the .R struct
+func (o *PublicreportImage) LoadPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Pools = nil
+
+ related, err := o.Pools(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, rel := range related {
+ rel.R.Images = PublicreportImageSlice{o}
+ }
+
+ o.R.Pools = related
+ return nil
+}
+
+// LoadPools loads the publicreportImage's Pools into the .R struct
+func (os PublicreportImageSlice) LoadPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ // since we are changing the columns, we need to check if the original columns were set or add the defaults
+ sq := dialect.SelectQuery{}
+ for _, mod := range mods {
+ mod.Apply(&sq)
+ }
+
+ if len(sq.SelectList.Columns) == 0 {
+ mods = append(mods, sm.Columns(PublicreportPools.Columns))
+ }
+
+ q := os.Pools(append(
+ mods,
+ sm.Columns(PublicreportPoolImages.Columns.ImageID.As("related_publicreport.image.ID")),
+ )...)
+
+ IDSlice := []int32{}
+
+ mapper := scan.Mod(scan.StructMapper[*PublicreportPool](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
+ return func(row *scan.Row) (any, error) {
+ IDSlice = append(IDSlice, *new(int32))
+ row.ScheduleScanByName("related_publicreport.image.ID", &IDSlice[len(IDSlice)-1])
+
+ return nil, nil
+ },
+ func(any, any) error {
+ return nil
+ }
+ })
+
+ publicreportPools, err := bob.Allx[bob.SliceTransformer[*PublicreportPool, PublicreportPoolSlice]](ctx, exec, q, mapper)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ o.R.Pools = nil
+ }
+
+ for _, o := range os {
+ for i, rel := range publicreportPools {
+ if !(o.ID == IDSlice[i]) {
+ continue
+ }
+
+ rel.R.Images = append(rel.R.Images, o)
+
+ o.R.Pools = append(o.R.Pools, rel)
+ }
+ }
+
+ return nil
+}
+
+// LoadQuicks loads the publicreportImage's Quicks into the .R struct
+func (o *PublicreportImage) LoadQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Quicks = nil
+
+ related, err := o.Quicks(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, rel := range related {
+ rel.R.Images = PublicreportImageSlice{o}
+ }
+
+ o.R.Quicks = related
+ return nil
+}
+
+// LoadQuicks loads the publicreportImage's Quicks into the .R struct
+func (os PublicreportImageSlice) LoadQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ // since we are changing the columns, we need to check if the original columns were set or add the defaults
+ sq := dialect.SelectQuery{}
+ for _, mod := range mods {
+ mod.Apply(&sq)
+ }
+
+ if len(sq.SelectList.Columns) == 0 {
+ mods = append(mods, sm.Columns(PublicreportQuicks.Columns))
+ }
+
+ q := os.Quicks(append(
+ mods,
+ sm.Columns(PublicreportQuickImages.Columns.ImageID.As("related_publicreport.image.ID")),
+ )...)
+
+ IDSlice := []int32{}
+
+ mapper := scan.Mod(scan.StructMapper[*PublicreportQuick](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
+ return func(row *scan.Row) (any, error) {
+ IDSlice = append(IDSlice, *new(int32))
+ row.ScheduleScanByName("related_publicreport.image.ID", &IDSlice[len(IDSlice)-1])
+
+ return nil, nil
+ },
+ func(any, any) error {
+ return nil
+ }
+ })
+
+ publicreportQuicks, err := bob.Allx[bob.SliceTransformer[*PublicreportQuick, PublicreportQuickSlice]](ctx, exec, q, mapper)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ o.R.Quicks = nil
+ }
+
+ for _, o := range os {
+ for i, rel := range publicreportQuicks {
+ if !(o.ID == IDSlice[i]) {
+ continue
+ }
+
+ rel.R.Images = append(rel.R.Images, o)
+
+ o.R.Quicks = append(o.R.Quicks, rel)
+ }
+ }
+
+ return nil
+}
+
+// publicreportImageC is where relationship counts are stored.
+type publicreportImageC struct {
+ ImageExifs *int64
+ Pools *int64
+ Quicks *int64
+}
+
+// PreloadCount sets a count in the C struct by name
+func (o *PublicreportImage) PreloadCount(name string, count int64) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "ImageExifs":
+ o.C.ImageExifs = &count
+ case "Pools":
+ o.C.Pools = &count
+ case "Quicks":
+ o.C.Quicks = &count
+ }
+ return nil
+}
+
+type publicreportImageCountPreloader struct {
+ ImageExifs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Pools func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Quicks func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+}
+
+func buildPublicreportImageCountPreloader() publicreportImageCountPreloader {
+ return publicreportImageCountPreloader{
+ ImageExifs: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportImage]("ImageExifs", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = PublicreportImages.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(PublicreportImageExifs.Name()),
+ sm.Where(psql.Quote(PublicreportImageExifs.Alias(), "image_id").EQ(psql.Quote(parent, "id"))),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Pools: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportImage]("Pools", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = PublicreportImages.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(PublicreportPoolImages.Name()),
+ sm.Where(psql.Quote(PublicreportPoolImages.Alias(), "image_id").EQ(psql.Quote(parent, "id"))),
+ sm.InnerJoin(PublicreportPools.Name()).On(
+ psql.Quote(PublicreportPools.Alias(), "id").EQ(psql.Quote(PublicreportPoolImages.Alias(), "pool_id")),
+ ),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ Quicks: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportImage]("Quicks", func(parent string) bob.Expression {
+ // Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
+ if parent == "" {
+ parent = PublicreportImages.Alias()
+ }
+
+ subqueryMods := []bob.Mod[*dialect.SelectQuery]{
+ sm.Columns(psql.Raw("count(*)")),
+
+ sm.From(PublicreportQuickImages.Name()),
+ sm.Where(psql.Quote(PublicreportQuickImages.Alias(), "image_id").EQ(psql.Quote(parent, "id"))),
+ sm.InnerJoin(PublicreportQuicks.Name()).On(
+ psql.Quote(PublicreportQuicks.Alias(), "id").EQ(psql.Quote(PublicreportQuickImages.Alias(), "quick_id")),
+ ),
+ }
+ subqueryMods = append(subqueryMods, mods...)
+ return psql.Group(psql.Select(subqueryMods...).Expression)
+ })
+ },
+ }
+}
+
+type publicreportImageCountThenLoader[Q orm.Loadable] struct {
+ ImageExifs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Quicks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportImageCountThenLoader[Q orm.Loadable]() publicreportImageCountThenLoader[Q] {
+ type ImageExifsCountInterface interface {
+ LoadCountImageExifs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PoolsCountInterface interface {
+ LoadCountPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type QuicksCountInterface interface {
+ LoadCountQuicks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportImageCountThenLoader[Q]{
+ ImageExifs: countThenLoadBuilder[Q](
+ "ImageExifs",
+ func(ctx context.Context, exec bob.Executor, retrieved ImageExifsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountImageExifs(ctx, exec, mods...)
+ },
+ ),
+ Pools: countThenLoadBuilder[Q](
+ "Pools",
+ func(ctx context.Context, exec bob.Executor, retrieved PoolsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountPools(ctx, exec, mods...)
+ },
+ ),
+ Quicks: countThenLoadBuilder[Q](
+ "Quicks",
+ func(ctx context.Context, exec bob.Executor, retrieved QuicksCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountQuicks(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadCountImageExifs loads the count of ImageExifs into the C struct
+func (o *PublicreportImage) LoadCountImageExifs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.ImageExifs(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.ImageExifs = &count
+ return nil
+}
+
+// LoadCountImageExifs loads the count of ImageExifs for a slice
+func (os PublicreportImageSlice) LoadCountImageExifs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountImageExifs(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountPools loads the count of Pools into the C struct
+func (o *PublicreportImage) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Pools(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Pools = &count
+ return nil
+}
+
+// LoadCountPools loads the count of Pools for a slice
+func (os PublicreportImageSlice) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountPools(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// LoadCountQuicks loads the count of Quicks into the C struct
+func (o *PublicreportImage) LoadCountQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ count, err := o.Quicks(mods...).Count(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.C.Quicks = &count
+ return nil
+}
+
+// LoadCountQuicks loads the count of Quicks for a slice
+func (os PublicreportImageSlice) LoadCountQuicks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ for _, o := range os {
+ if err := o.LoadCountQuicks(ctx, exec, mods...); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+type publicreportImageJoins[Q dialect.Joinable] struct {
+ typ string
+ ImageExifs modAs[Q, publicreportImageExifColumns]
+ Pools modAs[Q, publicreportPoolColumns]
+ Quicks modAs[Q, publicreportQuickColumns]
+}
+
+func (j publicreportImageJoins[Q]) aliasedAs(alias string) publicreportImageJoins[Q] {
+ return buildPublicreportImageJoins[Q](buildPublicreportImageColumns(alias), j.typ)
+}
+
+func buildPublicreportImageJoins[Q dialect.Joinable](cols publicreportImageColumns, typ string) publicreportImageJoins[Q] {
+ return publicreportImageJoins[Q]{
+ typ: typ,
+ ImageExifs: modAs[Q, publicreportImageExifColumns]{
+ c: PublicreportImageExifs.Columns,
+ f: func(to publicreportImageExifColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImageExifs.Name().As(to.Alias())).On(
+ to.ImageID.EQ(cols.ID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ Pools: modAs[Q, publicreportPoolColumns]{
+ c: PublicreportPools.Columns,
+ f: func(to publicreportPoolColumns) bob.Mod[Q] {
+ random := strconv.FormatInt(randInt(), 10)
+ mods := make(mods.QueryMods[Q], 0, 2)
+
+ {
+ to := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportPoolImages.Name().As(to.Alias())).On(
+ to.ImageID.EQ(cols.ID),
+ ))
+ }
+ {
+ cols := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportPools.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.PoolID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ Quicks: modAs[Q, publicreportQuickColumns]{
+ c: PublicreportQuicks.Columns,
+ f: func(to publicreportQuickColumns) bob.Mod[Q] {
+ random := strconv.FormatInt(randInt(), 10)
+ mods := make(mods.QueryMods[Q], 0, 2)
+
+ {
+ to := PublicreportQuickImages.Columns.AliasedAs(PublicreportQuickImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportQuickImages.Name().As(to.Alias())).On(
+ to.ImageID.EQ(cols.ID),
+ ))
+ }
+ {
+ cols := PublicreportQuickImages.Columns.AliasedAs(PublicreportQuickImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportQuicks.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.QuickID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/publicreport.image_exif.bob.go b/db/models/publicreport.image_exif.bob.go
new file mode 100644
index 00000000..bc4ac461
--- /dev/null
+++ b/db/models/publicreport.image_exif.bob.go
@@ -0,0 +1,645 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+)
+
+// PublicreportImageExif is an object representing the database table.
+type PublicreportImageExif struct {
+ ImageID int32 `db:"image_id,pk" `
+ Name string `db:"name,pk" `
+ Value string `db:"value,pk" `
+
+ R publicreportImageExifR `db:"-" `
+}
+
+// PublicreportImageExifSlice is an alias for a slice of pointers to PublicreportImageExif.
+// This should almost always be used instead of []*PublicreportImageExif.
+type PublicreportImageExifSlice []*PublicreportImageExif
+
+// PublicreportImageExifs contains methods to work with the image_exif table
+var PublicreportImageExifs = psql.NewTablex[*PublicreportImageExif, PublicreportImageExifSlice, *PublicreportImageExifSetter]("publicreport", "image_exif", buildPublicreportImageExifColumns("publicreport.image_exif"))
+
+// PublicreportImageExifsQuery is a query on the image_exif table
+type PublicreportImageExifsQuery = *psql.ViewQuery[*PublicreportImageExif, PublicreportImageExifSlice]
+
+// publicreportImageExifR is where relationships are stored.
+type publicreportImageExifR struct {
+ Image *PublicreportImage // publicreport.image_exif.image_exif_image_id_fkey
+}
+
+func buildPublicreportImageExifColumns(alias string) publicreportImageExifColumns {
+ return publicreportImageExifColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "image_id", "name", "value",
+ ).WithParent("publicreport.image_exif"),
+ tableAlias: alias,
+ ImageID: psql.Quote(alias, "image_id"),
+ Name: psql.Quote(alias, "name"),
+ Value: psql.Quote(alias, "value"),
+ }
+}
+
+type publicreportImageExifColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ ImageID psql.Expression
+ Name psql.Expression
+ Value psql.Expression
+}
+
+func (c publicreportImageExifColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (publicreportImageExifColumns) AliasedAs(alias string) publicreportImageExifColumns {
+ return buildPublicreportImageExifColumns(alias)
+}
+
+// PublicreportImageExifSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type PublicreportImageExifSetter struct {
+ ImageID omit.Val[int32] `db:"image_id,pk" `
+ Name omit.Val[string] `db:"name,pk" `
+ Value omit.Val[string] `db:"value,pk" `
+}
+
+func (s PublicreportImageExifSetter) SetColumns() []string {
+ vals := make([]string, 0, 3)
+ if s.ImageID.IsValue() {
+ vals = append(vals, "image_id")
+ }
+ if s.Name.IsValue() {
+ vals = append(vals, "name")
+ }
+ if s.Value.IsValue() {
+ vals = append(vals, "value")
+ }
+ return vals
+}
+
+func (s PublicreportImageExifSetter) Overwrite(t *PublicreportImageExif) {
+ if s.ImageID.IsValue() {
+ t.ImageID = s.ImageID.MustGet()
+ }
+ if s.Name.IsValue() {
+ t.Name = s.Name.MustGet()
+ }
+ if s.Value.IsValue() {
+ t.Value = s.Value.MustGet()
+ }
+}
+
+func (s *PublicreportImageExifSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImageExifs.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 3)
+ if s.ImageID.IsValue() {
+ vals[0] = psql.Arg(s.ImageID.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.Name.IsValue() {
+ vals[1] = psql.Arg(s.Name.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ if s.Value.IsValue() {
+ vals[2] = psql.Arg(s.Value.MustGet())
+ } else {
+ vals[2] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s PublicreportImageExifSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s PublicreportImageExifSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 3)
+
+ if s.ImageID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "image_id")...),
+ psql.Arg(s.ImageID),
+ }})
+ }
+
+ if s.Name.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "name")...),
+ psql.Arg(s.Name),
+ }})
+ }
+
+ if s.Value.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "value")...),
+ psql.Arg(s.Value),
+ }})
+ }
+
+ return exprs
+}
+
+// FindPublicreportImageExif retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindPublicreportImageExif(ctx context.Context, exec bob.Executor, ImageIDPK int32, NamePK string, ValuePK string, cols ...string) (*PublicreportImageExif, error) {
+ if len(cols) == 0 {
+ return PublicreportImageExifs.Query(
+ sm.Where(PublicreportImageExifs.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportImageExifs.Columns.Name.EQ(psql.Arg(NamePK))),
+ sm.Where(PublicreportImageExifs.Columns.Value.EQ(psql.Arg(ValuePK))),
+ ).One(ctx, exec)
+ }
+
+ return PublicreportImageExifs.Query(
+ sm.Where(PublicreportImageExifs.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportImageExifs.Columns.Name.EQ(psql.Arg(NamePK))),
+ sm.Where(PublicreportImageExifs.Columns.Value.EQ(psql.Arg(ValuePK))),
+ sm.Columns(PublicreportImageExifs.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// PublicreportImageExifExists checks the presence of a single record by primary key
+func PublicreportImageExifExists(ctx context.Context, exec bob.Executor, ImageIDPK int32, NamePK string, ValuePK string) (bool, error) {
+ return PublicreportImageExifs.Query(
+ sm.Where(PublicreportImageExifs.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportImageExifs.Columns.Name.EQ(psql.Arg(NamePK))),
+ sm.Where(PublicreportImageExifs.Columns.Value.EQ(psql.Arg(ValuePK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after PublicreportImageExif is retrieved from the database
+func (o *PublicreportImageExif) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportImageExifs.AfterSelectHooks.RunHooks(ctx, exec, PublicreportImageExifSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportImageExifs.AfterInsertHooks.RunHooks(ctx, exec, PublicreportImageExifSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportImageExifs.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportImageExifSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportImageExifs.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportImageExifSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the PublicreportImageExif
+func (o *PublicreportImageExif) primaryKeyVals() bob.Expression {
+ return psql.ArgGroup(
+ o.ImageID,
+ o.Name,
+ o.Value,
+ )
+}
+
+func (o *PublicreportImageExif) pkEQ() dialect.Expression {
+ return psql.Group(psql.Quote("publicreport.image_exif", "image_id"), psql.Quote("publicreport.image_exif", "name"), psql.Quote("publicreport.image_exif", "value")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the PublicreportImageExif
+func (o *PublicreportImageExif) Update(ctx context.Context, exec bob.Executor, s *PublicreportImageExifSetter) error {
+ v, err := PublicreportImageExifs.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single PublicreportImageExif record with an executor
+func (o *PublicreportImageExif) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := PublicreportImageExifs.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the PublicreportImageExif using the executor
+func (o *PublicreportImageExif) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := PublicreportImageExifs.Query(
+ sm.Where(PublicreportImageExifs.Columns.ImageID.EQ(psql.Arg(o.ImageID))),
+ sm.Where(PublicreportImageExifs.Columns.Name.EQ(psql.Arg(o.Name))),
+ sm.Where(PublicreportImageExifs.Columns.Value.EQ(psql.Arg(o.Value))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after PublicreportImageExifSlice is retrieved from the database
+func (o PublicreportImageExifSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportImageExifs.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportImageExifs.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportImageExifs.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportImageExifs.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o PublicreportImageExifSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Group(psql.Quote("publicreport.image_exif", "image_id"), psql.Quote("publicreport.image_exif", "name"), psql.Quote("publicreport.image_exif", "value")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o PublicreportImageExifSlice) copyMatchingRows(from ...*PublicreportImageExif) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.ImageID != old.ImageID {
+ continue
+ }
+ if new.Name != old.Name {
+ continue
+ }
+ if new.Value != old.Value {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o PublicreportImageExifSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImageExifs.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportImageExif:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportImageExif:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportImageExifSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportImageExif or a slice of PublicreportImageExif
+ // then run the AfterUpdateHooks on the slice
+ _, err = PublicreportImageExifs.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o PublicreportImageExifSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportImageExifs.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportImageExif:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportImageExif:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportImageExifSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportImageExif or a slice of PublicreportImageExif
+ // then run the AfterDeleteHooks on the slice
+ _, err = PublicreportImageExifs.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o PublicreportImageExifSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportImageExifSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportImageExifs.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o PublicreportImageExifSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportImageExifs.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o PublicreportImageExifSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := PublicreportImageExifs.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// Image starts a query for related objects on publicreport.image
+func (o *PublicreportImageExif) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ return PublicreportImages.Query(append(mods,
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(o.ImageID))),
+ )...)
+}
+
+func (os PublicreportImageExifSlice) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ pkImageID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkImageID = append(pkImageID, o.ImageID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkImageID), "integer[]")),
+ ))
+
+ return PublicreportImages.Query(append(mods,
+ sm.Where(psql.Group(PublicreportImages.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func attachPublicreportImageExifImage0(ctx context.Context, exec bob.Executor, count int, publicreportImageExif0 *PublicreportImageExif, publicreportImage1 *PublicreportImage) (*PublicreportImageExif, error) {
+ setter := &PublicreportImageExifSetter{
+ ImageID: omit.From(publicreportImage1.ID),
+ }
+
+ err := publicreportImageExif0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportImageExifImage0: %w", err)
+ }
+
+ return publicreportImageExif0, nil
+}
+
+func (publicreportImageExif0 *PublicreportImageExif) InsertImage(ctx context.Context, exec bob.Executor, related *PublicreportImageSetter) error {
+ var err error
+
+ publicreportImage1, err := PublicreportImages.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachPublicreportImageExifImage0(ctx, exec, 1, publicreportImageExif0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportImageExif0.R.Image = publicreportImage1
+
+ publicreportImage1.R.ImageExifs = append(publicreportImage1.R.ImageExifs, publicreportImageExif0)
+
+ return nil
+}
+
+func (publicreportImageExif0 *PublicreportImageExif) AttachImage(ctx context.Context, exec bob.Executor, publicreportImage1 *PublicreportImage) error {
+ var err error
+
+ _, err = attachPublicreportImageExifImage0(ctx, exec, 1, publicreportImageExif0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportImageExif0.R.Image = publicreportImage1
+
+ publicreportImage1.R.ImageExifs = append(publicreportImage1.R.ImageExifs, publicreportImageExif0)
+
+ return nil
+}
+
+type publicreportImageExifWhere[Q psql.Filterable] struct {
+ ImageID psql.WhereMod[Q, int32]
+ Name psql.WhereMod[Q, string]
+ Value psql.WhereMod[Q, string]
+}
+
+func (publicreportImageExifWhere[Q]) AliasedAs(alias string) publicreportImageExifWhere[Q] {
+ return buildPublicreportImageExifWhere[Q](buildPublicreportImageExifColumns(alias))
+}
+
+func buildPublicreportImageExifWhere[Q psql.Filterable](cols publicreportImageExifColumns) publicreportImageExifWhere[Q] {
+ return publicreportImageExifWhere[Q]{
+ ImageID: psql.Where[Q, int32](cols.ImageID),
+ Name: psql.Where[Q, string](cols.Name),
+ Value: psql.Where[Q, string](cols.Value),
+ }
+}
+
+func (o *PublicreportImageExif) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "Image":
+ rel, ok := retrieved.(*PublicreportImage)
+ if !ok {
+ return fmt.Errorf("publicreportImageExif cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Image = rel
+
+ if rel != nil {
+ rel.R.ImageExifs = PublicreportImageExifSlice{o}
+ }
+ return nil
+ default:
+ return fmt.Errorf("publicreportImageExif has no relationship %q", name)
+ }
+}
+
+type publicreportImageExifPreloader struct {
+ Image func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildPublicreportImageExifPreloader() publicreportImageExifPreloader {
+ return publicreportImageExifPreloader{
+ Image: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*PublicreportImage, PublicreportImageSlice](psql.PreloadRel{
+ Name: "Image",
+ Sides: []psql.PreloadSide{
+ {
+ From: PublicreportImageExifs,
+ To: PublicreportImages,
+ FromColumns: []string{"image_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, PublicreportImages.Columns.Names(), opts...)
+ },
+ }
+}
+
+type publicreportImageExifThenLoader[Q orm.Loadable] struct {
+ Image func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportImageExifThenLoader[Q orm.Loadable]() publicreportImageExifThenLoader[Q] {
+ type ImageLoadInterface interface {
+ LoadImage(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportImageExifThenLoader[Q]{
+ Image: thenLoadBuilder[Q](
+ "Image",
+ func(ctx context.Context, exec bob.Executor, retrieved ImageLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImage(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadImage loads the publicreportImageExif's Image into the .R struct
+func (o *PublicreportImageExif) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Image = nil
+
+ related, err := o.Image(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ related.R.ImageExifs = PublicreportImageExifSlice{o}
+
+ o.R.Image = related
+ return nil
+}
+
+// LoadImage loads the publicreportImageExif's Image into the .R struct
+func (os PublicreportImageExifSlice) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportImages, err := os.Image(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportImages {
+
+ if !(o.ImageID == rel.ID) {
+ continue
+ }
+
+ rel.R.ImageExifs = append(rel.R.ImageExifs, o)
+
+ o.R.Image = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+type publicreportImageExifJoins[Q dialect.Joinable] struct {
+ typ string
+ Image modAs[Q, publicreportImageColumns]
+}
+
+func (j publicreportImageExifJoins[Q]) aliasedAs(alias string) publicreportImageExifJoins[Q] {
+ return buildPublicreportImageExifJoins[Q](buildPublicreportImageExifColumns(alias), j.typ)
+}
+
+func buildPublicreportImageExifJoins[Q dialect.Joinable](cols publicreportImageExifColumns, typ string) publicreportImageExifJoins[Q] {
+ return publicreportImageExifJoins[Q]{
+ typ: typ,
+ Image: modAs[Q, publicreportImageColumns]{
+ c: PublicreportImages.Columns,
+ f: func(to publicreportImageColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.ImageID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/publicreport.pool.bob.go b/db/models/publicreport.pool.bob.go
index 350af417..0a5a9d8e 100644
--- a/db/models/publicreport.pool.bob.go
+++ b/db/models/publicreport.pool.bob.go
@@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
+ "strconv"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
@@ -23,6 +24,7 @@ import (
"github.com/stephenafamo/bob/mods"
"github.com/stephenafamo/bob/orm"
"github.com/stephenafamo/bob/types/pgtypes"
+ "github.com/stephenafamo/scan"
)
// PublicreportPool is an object representing the database table.
@@ -75,7 +77,7 @@ type PublicreportPoolsQuery = *psql.ViewQuery[*PublicreportPool, PublicreportPoo
// publicreportPoolR is where relationships are stored.
type publicreportPoolR struct {
- PoolPhotos PublicreportPoolPhotoSlice // publicreport.pool_photo.pool_photo_pool_id_fkey
+ Images PublicreportImageSlice // publicreport.pool_image.pool_image_image_id_fkeypublicreport.pool_image.pool_image_pool_id_fkey
}
func buildPublicreportPoolColumns(alias string) publicreportPoolColumns {
@@ -1018,14 +1020,16 @@ func (o PublicreportPoolSlice) ReloadAll(ctx context.Context, exec bob.Executor)
return nil
}
-// PoolPhotos starts a query for related objects on publicreport.pool_photo
-func (o *PublicreportPool) PoolPhotos(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolPhotosQuery {
- return PublicreportPoolPhotos.Query(append(mods,
- sm.Where(PublicreportPoolPhotos.Columns.PoolID.EQ(psql.Arg(o.ID))),
+// Images starts a query for related objects on publicreport.image
+func (o *PublicreportPool) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ return PublicreportImages.Query(append(mods,
+ sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
+ PublicreportImages.Columns.ID.EQ(PublicreportPoolImages.Columns.ImageID)),
+ sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(o.ID))),
)...)
}
-func (os PublicreportPoolSlice) PoolPhotos(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolPhotosQuery {
+func (os PublicreportPoolSlice) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
pkID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
@@ -1037,74 +1041,74 @@ func (os PublicreportPoolSlice) PoolPhotos(mods ...bob.Mod[*dialect.SelectQuery]
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
))
- return PublicreportPoolPhotos.Query(append(mods,
- sm.Where(psql.Group(PublicreportPoolPhotos.Columns.PoolID).OP("IN", PKArgExpr)),
+ return PublicreportImages.Query(append(mods,
+ sm.InnerJoin(PublicreportPoolImages.NameAs()).On(
+ PublicreportImages.Columns.ID.EQ(PublicreportPoolImages.Columns.ImageID),
+ ),
+ sm.Where(psql.Group(PublicreportPoolImages.Columns.PoolID).OP("IN", PKArgExpr)),
)...)
}
-func insertPublicreportPoolPoolPhotos0(ctx context.Context, exec bob.Executor, publicreportPoolPhotos1 []*PublicreportPoolPhotoSetter, publicreportPool0 *PublicreportPool) (PublicreportPoolPhotoSlice, error) {
- for i := range publicreportPoolPhotos1 {
- publicreportPoolPhotos1[i].PoolID = omit.From(publicreportPool0.ID)
+func attachPublicreportPoolImages0(ctx context.Context, exec bob.Executor, count int, publicreportPool0 *PublicreportPool, publicreportImages2 PublicreportImageSlice) (PublicreportPoolImageSlice, error) {
+ setters := make([]*PublicreportPoolImageSetter, count)
+ for i := range count {
+ setters[i] = &PublicreportPoolImageSetter{
+ PoolID: omit.From(publicreportPool0.ID),
+ ImageID: omit.From(publicreportImages2[i].ID),
+ }
}
- ret, err := PublicreportPoolPhotos.Insert(bob.ToMods(publicreportPoolPhotos1...)).All(ctx, exec)
+ publicreportPoolImages1, err := PublicreportPoolImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
if err != nil {
- return ret, fmt.Errorf("insertPublicreportPoolPoolPhotos0: %w", err)
+ return nil, fmt.Errorf("attachPublicreportPoolImages0: %w", err)
}
- return ret, nil
+ return publicreportPoolImages1, nil
}
-func attachPublicreportPoolPoolPhotos0(ctx context.Context, exec bob.Executor, count int, publicreportPoolPhotos1 PublicreportPoolPhotoSlice, publicreportPool0 *PublicreportPool) (PublicreportPoolPhotoSlice, error) {
- setter := &PublicreportPoolPhotoSetter{
- PoolID: omit.From(publicreportPool0.ID),
- }
-
- err := publicreportPoolPhotos1.UpdateAll(ctx, exec, *setter)
- if err != nil {
- return nil, fmt.Errorf("attachPublicreportPoolPoolPhotos0: %w", err)
- }
-
- return publicreportPoolPhotos1, nil
-}
-
-func (publicreportPool0 *PublicreportPool) InsertPoolPhotos(ctx context.Context, exec bob.Executor, related ...*PublicreportPoolPhotoSetter) error {
+func (publicreportPool0 *PublicreportPool) InsertImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImageSetter) error {
if len(related) == 0 {
return nil
}
var err error
- publicreportPoolPhotos1, err := insertPublicreportPoolPoolPhotos0(ctx, exec, related, publicreportPool0)
+ inserted, err := PublicreportImages.Insert(bob.ToMods(related...)).All(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+ publicreportImages2 := PublicreportImageSlice(inserted)
+
+ _, err = attachPublicreportPoolImages0(ctx, exec, len(related), publicreportPool0, publicreportImages2)
if err != nil {
return err
}
- publicreportPool0.R.PoolPhotos = append(publicreportPool0.R.PoolPhotos, publicreportPoolPhotos1...)
+ publicreportPool0.R.Images = append(publicreportPool0.R.Images, publicreportImages2...)
- for _, rel := range publicreportPoolPhotos1 {
- rel.R.Pool = publicreportPool0
+ for _, rel := range publicreportImages2 {
+ rel.R.Pools = append(rel.R.Pools, publicreportPool0)
}
return nil
}
-func (publicreportPool0 *PublicreportPool) AttachPoolPhotos(ctx context.Context, exec bob.Executor, related ...*PublicreportPoolPhoto) error {
+func (publicreportPool0 *PublicreportPool) AttachImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImage) error {
if len(related) == 0 {
return nil
}
var err error
- publicreportPoolPhotos1 := PublicreportPoolPhotoSlice(related)
+ publicreportImages2 := PublicreportImageSlice(related)
- _, err = attachPublicreportPoolPoolPhotos0(ctx, exec, len(related), publicreportPoolPhotos1, publicreportPool0)
+ _, err = attachPublicreportPoolImages0(ctx, exec, len(related), publicreportPool0, publicreportImages2)
if err != nil {
return err
}
- publicreportPool0.R.PoolPhotos = append(publicreportPool0.R.PoolPhotos, publicreportPoolPhotos1...)
+ publicreportPool0.R.Images = append(publicreportPool0.R.Images, publicreportImages2...)
for _, rel := range related {
- rel.R.Pool = publicreportPool0
+ rel.R.Pools = append(rel.R.Pools, publicreportPool0)
}
return nil
@@ -1188,17 +1192,17 @@ func (o *PublicreportPool) Preload(name string, retrieved any) error {
}
switch name {
- case "PoolPhotos":
- rels, ok := retrieved.(PublicreportPoolPhotoSlice)
+ case "Images":
+ rels, ok := retrieved.(PublicreportImageSlice)
if !ok {
return fmt.Errorf("publicreportPool cannot load %T as %q", retrieved, name)
}
- o.R.PoolPhotos = rels
+ o.R.Images = rels
for _, rel := range rels {
if rel != nil {
- rel.R.Pool = o
+ rel.R.Pools = PublicreportPoolSlice{o}
}
}
return nil
@@ -1214,79 +1218,99 @@ func buildPublicreportPoolPreloader() publicreportPoolPreloader {
}
type publicreportPoolThenLoader[Q orm.Loadable] struct {
- PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildPublicreportPoolThenLoader[Q orm.Loadable]() publicreportPoolThenLoader[Q] {
- type PoolPhotosLoadInterface interface {
- LoadPoolPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ type ImagesLoadInterface interface {
+ LoadImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return publicreportPoolThenLoader[Q]{
- PoolPhotos: thenLoadBuilder[Q](
- "PoolPhotos",
- func(ctx context.Context, exec bob.Executor, retrieved PoolPhotosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadPoolPhotos(ctx, exec, mods...)
+ Images: thenLoadBuilder[Q](
+ "Images",
+ func(ctx context.Context, exec bob.Executor, retrieved ImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImages(ctx, exec, mods...)
},
),
}
}
-// LoadPoolPhotos loads the publicreportPool's PoolPhotos into the .R struct
-func (o *PublicreportPool) LoadPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadImages loads the publicreportPool's Images into the .R struct
+func (o *PublicreportPool) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
- o.R.PoolPhotos = nil
+ o.R.Images = nil
- related, err := o.PoolPhotos(mods...).All(ctx, exec)
+ related, err := o.Images(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, rel := range related {
- rel.R.Pool = o
+ rel.R.Pools = PublicreportPoolSlice{o}
}
- o.R.PoolPhotos = related
+ o.R.Images = related
return nil
}
-// LoadPoolPhotos loads the publicreportPool's PoolPhotos into the .R struct
-func (os PublicreportPoolSlice) LoadPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadImages loads the publicreportPool's Images into the .R struct
+func (os PublicreportPoolSlice) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
- publicreportPoolPhotos, err := os.PoolPhotos(mods...).All(ctx, exec)
+ // since we are changing the columns, we need to check if the original columns were set or add the defaults
+ sq := dialect.SelectQuery{}
+ for _, mod := range mods {
+ mod.Apply(&sq)
+ }
+
+ if len(sq.SelectList.Columns) == 0 {
+ mods = append(mods, sm.Columns(PublicreportImages.Columns))
+ }
+
+ q := os.Images(append(
+ mods,
+ sm.Columns(PublicreportPoolImages.Columns.PoolID.As("related_publicreport.pool.ID")),
+ )...)
+
+ IDSlice := []int32{}
+
+ mapper := scan.Mod(scan.StructMapper[*PublicreportImage](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
+ return func(row *scan.Row) (any, error) {
+ IDSlice = append(IDSlice, *new(int32))
+ row.ScheduleScanByName("related_publicreport.pool.ID", &IDSlice[len(IDSlice)-1])
+
+ return nil, nil
+ },
+ func(any, any) error {
+ return nil
+ }
+ })
+
+ publicreportImages, err := bob.Allx[bob.SliceTransformer[*PublicreportImage, PublicreportImageSlice]](ctx, exec, q, mapper)
if err != nil {
return err
}
for _, o := range os {
- if o == nil {
- continue
- }
-
- o.R.PoolPhotos = nil
+ o.R.Images = nil
}
for _, o := range os {
- if o == nil {
- continue
- }
-
- for _, rel := range publicreportPoolPhotos {
-
- if !(o.ID == rel.PoolID) {
+ for i, rel := range publicreportImages {
+ if !(o.ID == IDSlice[i]) {
continue
}
- rel.R.Pool = o
+ rel.R.Pools = append(rel.R.Pools, o)
- o.R.PoolPhotos = append(o.R.PoolPhotos, rel)
+ o.R.Images = append(o.R.Images, rel)
}
}
@@ -1295,7 +1319,7 @@ func (os PublicreportPoolSlice) LoadPoolPhotos(ctx context.Context, exec bob.Exe
// publicreportPoolC is where relationship counts are stored.
type publicreportPoolC struct {
- PoolPhotos *int64
+ Images *int64
}
// PreloadCount sets a count in the C struct by name
@@ -1305,20 +1329,20 @@ func (o *PublicreportPool) PreloadCount(name string, count int64) error {
}
switch name {
- case "PoolPhotos":
- o.C.PoolPhotos = &count
+ case "Images":
+ o.C.Images = &count
}
return nil
}
type publicreportPoolCountPreloader struct {
- PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Images func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
}
func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader {
return publicreportPoolCountPreloader{
- PoolPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
- return countPreloader[*PublicreportPool]("PoolPhotos", func(parent string) bob.Expression {
+ Images: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportPool]("Images", func(parent string) bob.Expression {
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
if parent == "" {
parent = PublicreportPools.Alias()
@@ -1327,8 +1351,11 @@ func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader {
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
sm.Columns(psql.Raw("count(*)")),
- sm.From(PublicreportPoolPhotos.Name()),
- sm.Where(psql.Quote(PublicreportPoolPhotos.Alias(), "pool_id").EQ(psql.Quote(parent, "id"))),
+ sm.From(PublicreportPoolImages.Name()),
+ sm.Where(psql.Quote(PublicreportPoolImages.Alias(), "pool_id").EQ(psql.Quote(parent, "id"))),
+ sm.InnerJoin(PublicreportImages.Name()).On(
+ psql.Quote(PublicreportImages.Alias(), "id").EQ(psql.Quote(PublicreportPoolImages.Alias(), "image_id")),
+ ),
}
subqueryMods = append(subqueryMods, mods...)
return psql.Group(psql.Select(subqueryMods...).Expression)
@@ -1338,47 +1365,47 @@ func buildPublicreportPoolCountPreloader() publicreportPoolCountPreloader {
}
type publicreportPoolCountThenLoader[Q orm.Loadable] struct {
- PoolPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildPublicreportPoolCountThenLoader[Q orm.Loadable]() publicreportPoolCountThenLoader[Q] {
- type PoolPhotosCountInterface interface {
- LoadCountPoolPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ type ImagesCountInterface interface {
+ LoadCountImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return publicreportPoolCountThenLoader[Q]{
- PoolPhotos: countThenLoadBuilder[Q](
- "PoolPhotos",
- func(ctx context.Context, exec bob.Executor, retrieved PoolPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadCountPoolPhotos(ctx, exec, mods...)
+ Images: countThenLoadBuilder[Q](
+ "Images",
+ func(ctx context.Context, exec bob.Executor, retrieved ImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountImages(ctx, exec, mods...)
},
),
}
}
-// LoadCountPoolPhotos loads the count of PoolPhotos into the C struct
-func (o *PublicreportPool) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadCountImages loads the count of Images into the C struct
+func (o *PublicreportPool) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
- count, err := o.PoolPhotos(mods...).Count(ctx, exec)
+ count, err := o.Images(mods...).Count(ctx, exec)
if err != nil {
return err
}
- o.C.PoolPhotos = &count
+ o.C.Images = &count
return nil
}
-// LoadCountPoolPhotos loads the count of PoolPhotos for a slice
-func (os PublicreportPoolSlice) LoadCountPoolPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadCountImages loads the count of Images for a slice
+func (os PublicreportPoolSlice) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
for _, o := range os {
- if err := o.LoadCountPoolPhotos(ctx, exec, mods...); err != nil {
+ if err := o.LoadCountImages(ctx, exec, mods...); err != nil {
return err
}
}
@@ -1387,8 +1414,8 @@ func (os PublicreportPoolSlice) LoadCountPoolPhotos(ctx context.Context, exec bo
}
type publicreportPoolJoins[Q dialect.Joinable] struct {
- typ string
- PoolPhotos modAs[Q, publicreportPoolPhotoColumns]
+ typ string
+ Images modAs[Q, publicreportImageColumns]
}
func (j publicreportPoolJoins[Q]) aliasedAs(alias string) publicreportPoolJoins[Q] {
@@ -1398,16 +1425,24 @@ func (j publicreportPoolJoins[Q]) aliasedAs(alias string) publicreportPoolJoins[
func buildPublicreportPoolJoins[Q dialect.Joinable](cols publicreportPoolColumns, typ string) publicreportPoolJoins[Q] {
return publicreportPoolJoins[Q]{
typ: typ,
- PoolPhotos: modAs[Q, publicreportPoolPhotoColumns]{
- c: PublicreportPoolPhotos.Columns,
- f: func(to publicreportPoolPhotoColumns) bob.Mod[Q] {
- mods := make(mods.QueryMods[Q], 0, 1)
+ Images: modAs[Q, publicreportImageColumns]{
+ c: PublicreportImages.Columns,
+ f: func(to publicreportImageColumns) bob.Mod[Q] {
+ random := strconv.FormatInt(randInt(), 10)
+ mods := make(mods.QueryMods[Q], 0, 2)
{
- mods = append(mods, dialect.Join[Q](typ, PublicreportPoolPhotos.Name().As(to.Alias())).On(
+ to := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportPoolImages.Name().As(to.Alias())).On(
to.PoolID.EQ(cols.ID),
))
}
+ {
+ cols := PublicreportPoolImages.Columns.AliasedAs(PublicreportPoolImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.ImageID),
+ ))
+ }
return mods
},
diff --git a/db/models/publicreport.pool_image.bob.go b/db/models/publicreport.pool_image.bob.go
new file mode 100644
index 00000000..3547232d
--- /dev/null
+++ b/db/models/publicreport.pool_image.bob.go
@@ -0,0 +1,766 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+)
+
+// PublicreportPoolImage is an object representing the database table.
+type PublicreportPoolImage struct {
+ ImageID int32 `db:"image_id,pk" `
+ PoolID int32 `db:"pool_id,pk" `
+
+ R publicreportPoolImageR `db:"-" `
+}
+
+// PublicreportPoolImageSlice is an alias for a slice of pointers to PublicreportPoolImage.
+// This should almost always be used instead of []*PublicreportPoolImage.
+type PublicreportPoolImageSlice []*PublicreportPoolImage
+
+// PublicreportPoolImages contains methods to work with the pool_image table
+var PublicreportPoolImages = psql.NewTablex[*PublicreportPoolImage, PublicreportPoolImageSlice, *PublicreportPoolImageSetter]("publicreport", "pool_image", buildPublicreportPoolImageColumns("publicreport.pool_image"))
+
+// PublicreportPoolImagesQuery is a query on the pool_image table
+type PublicreportPoolImagesQuery = *psql.ViewQuery[*PublicreportPoolImage, PublicreportPoolImageSlice]
+
+// publicreportPoolImageR is where relationships are stored.
+type publicreportPoolImageR struct {
+ Image *PublicreportImage // publicreport.pool_image.pool_image_image_id_fkey
+ Pool *PublicreportPool // publicreport.pool_image.pool_image_pool_id_fkey
+}
+
+func buildPublicreportPoolImageColumns(alias string) publicreportPoolImageColumns {
+ return publicreportPoolImageColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "image_id", "pool_id",
+ ).WithParent("publicreport.pool_image"),
+ tableAlias: alias,
+ ImageID: psql.Quote(alias, "image_id"),
+ PoolID: psql.Quote(alias, "pool_id"),
+ }
+}
+
+type publicreportPoolImageColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ ImageID psql.Expression
+ PoolID psql.Expression
+}
+
+func (c publicreportPoolImageColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (publicreportPoolImageColumns) AliasedAs(alias string) publicreportPoolImageColumns {
+ return buildPublicreportPoolImageColumns(alias)
+}
+
+// PublicreportPoolImageSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type PublicreportPoolImageSetter struct {
+ ImageID omit.Val[int32] `db:"image_id,pk" `
+ PoolID omit.Val[int32] `db:"pool_id,pk" `
+}
+
+func (s PublicreportPoolImageSetter) SetColumns() []string {
+ vals := make([]string, 0, 2)
+ if s.ImageID.IsValue() {
+ vals = append(vals, "image_id")
+ }
+ if s.PoolID.IsValue() {
+ vals = append(vals, "pool_id")
+ }
+ return vals
+}
+
+func (s PublicreportPoolImageSetter) Overwrite(t *PublicreportPoolImage) {
+ if s.ImageID.IsValue() {
+ t.ImageID = s.ImageID.MustGet()
+ }
+ if s.PoolID.IsValue() {
+ t.PoolID = s.PoolID.MustGet()
+ }
+}
+
+func (s *PublicreportPoolImageSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportPoolImages.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 2)
+ if s.ImageID.IsValue() {
+ vals[0] = psql.Arg(s.ImageID.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.PoolID.IsValue() {
+ vals[1] = psql.Arg(s.PoolID.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s PublicreportPoolImageSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s PublicreportPoolImageSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 2)
+
+ if s.ImageID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "image_id")...),
+ psql.Arg(s.ImageID),
+ }})
+ }
+
+ if s.PoolID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "pool_id")...),
+ psql.Arg(s.PoolID),
+ }})
+ }
+
+ return exprs
+}
+
+// FindPublicreportPoolImage retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindPublicreportPoolImage(ctx context.Context, exec bob.Executor, ImageIDPK int32, PoolIDPK int32, cols ...string) (*PublicreportPoolImage, error) {
+ if len(cols) == 0 {
+ return PublicreportPoolImages.Query(
+ sm.Where(PublicreportPoolImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(PoolIDPK))),
+ ).One(ctx, exec)
+ }
+
+ return PublicreportPoolImages.Query(
+ sm.Where(PublicreportPoolImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(PoolIDPK))),
+ sm.Columns(PublicreportPoolImages.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// PublicreportPoolImageExists checks the presence of a single record by primary key
+func PublicreportPoolImageExists(ctx context.Context, exec bob.Executor, ImageIDPK int32, PoolIDPK int32) (bool, error) {
+ return PublicreportPoolImages.Query(
+ sm.Where(PublicreportPoolImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(PoolIDPK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after PublicreportPoolImage is retrieved from the database
+func (o *PublicreportPoolImage) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportPoolImages.AfterSelectHooks.RunHooks(ctx, exec, PublicreportPoolImageSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportPoolImages.AfterInsertHooks.RunHooks(ctx, exec, PublicreportPoolImageSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportPoolImages.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportPoolImageSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportPoolImages.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportPoolImageSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the PublicreportPoolImage
+func (o *PublicreportPoolImage) primaryKeyVals() bob.Expression {
+ return psql.ArgGroup(
+ o.ImageID,
+ o.PoolID,
+ )
+}
+
+func (o *PublicreportPoolImage) pkEQ() dialect.Expression {
+ return psql.Group(psql.Quote("publicreport.pool_image", "image_id"), psql.Quote("publicreport.pool_image", "pool_id")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the PublicreportPoolImage
+func (o *PublicreportPoolImage) Update(ctx context.Context, exec bob.Executor, s *PublicreportPoolImageSetter) error {
+ v, err := PublicreportPoolImages.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single PublicreportPoolImage record with an executor
+func (o *PublicreportPoolImage) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := PublicreportPoolImages.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the PublicreportPoolImage using the executor
+func (o *PublicreportPoolImage) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := PublicreportPoolImages.Query(
+ sm.Where(PublicreportPoolImages.Columns.ImageID.EQ(psql.Arg(o.ImageID))),
+ sm.Where(PublicreportPoolImages.Columns.PoolID.EQ(psql.Arg(o.PoolID))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after PublicreportPoolImageSlice is retrieved from the database
+func (o PublicreportPoolImageSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportPoolImages.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportPoolImages.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportPoolImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportPoolImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o PublicreportPoolImageSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Group(psql.Quote("publicreport.pool_image", "image_id"), psql.Quote("publicreport.pool_image", "pool_id")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o PublicreportPoolImageSlice) copyMatchingRows(from ...*PublicreportPoolImage) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.ImageID != old.ImageID {
+ continue
+ }
+ if new.PoolID != old.PoolID {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o PublicreportPoolImageSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportPoolImages.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportPoolImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportPoolImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportPoolImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportPoolImage or a slice of PublicreportPoolImage
+ // then run the AfterUpdateHooks on the slice
+ _, err = PublicreportPoolImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o PublicreportPoolImageSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportPoolImages.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportPoolImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportPoolImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportPoolImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportPoolImage or a slice of PublicreportPoolImage
+ // then run the AfterDeleteHooks on the slice
+ _, err = PublicreportPoolImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o PublicreportPoolImageSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportPoolImageSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportPoolImages.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o PublicreportPoolImageSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportPoolImages.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o PublicreportPoolImageSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := PublicreportPoolImages.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// Image starts a query for related objects on publicreport.image
+func (o *PublicreportPoolImage) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ return PublicreportImages.Query(append(mods,
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(o.ImageID))),
+ )...)
+}
+
+func (os PublicreportPoolImageSlice) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ pkImageID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkImageID = append(pkImageID, o.ImageID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkImageID), "integer[]")),
+ ))
+
+ return PublicreportImages.Query(append(mods,
+ sm.Where(psql.Group(PublicreportImages.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+// Pool starts a query for related objects on publicreport.pool
+func (o *PublicreportPoolImage) Pool(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
+ return PublicreportPools.Query(append(mods,
+ sm.Where(PublicreportPools.Columns.ID.EQ(psql.Arg(o.PoolID))),
+ )...)
+}
+
+func (os PublicreportPoolImageSlice) Pool(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
+ pkPoolID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkPoolID = append(pkPoolID, o.PoolID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkPoolID), "integer[]")),
+ ))
+
+ return PublicreportPools.Query(append(mods,
+ sm.Where(psql.Group(PublicreportPools.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func attachPublicreportPoolImageImage0(ctx context.Context, exec bob.Executor, count int, publicreportPoolImage0 *PublicreportPoolImage, publicreportImage1 *PublicreportImage) (*PublicreportPoolImage, error) {
+ setter := &PublicreportPoolImageSetter{
+ ImageID: omit.From(publicreportImage1.ID),
+ }
+
+ err := publicreportPoolImage0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportPoolImageImage0: %w", err)
+ }
+
+ return publicreportPoolImage0, nil
+}
+
+func (publicreportPoolImage0 *PublicreportPoolImage) InsertImage(ctx context.Context, exec bob.Executor, related *PublicreportImageSetter) error {
+ var err error
+
+ publicreportImage1, err := PublicreportImages.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachPublicreportPoolImageImage0(ctx, exec, 1, publicreportPoolImage0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportPoolImage0.R.Image = publicreportImage1
+
+ return nil
+}
+
+func (publicreportPoolImage0 *PublicreportPoolImage) AttachImage(ctx context.Context, exec bob.Executor, publicreportImage1 *PublicreportImage) error {
+ var err error
+
+ _, err = attachPublicreportPoolImageImage0(ctx, exec, 1, publicreportPoolImage0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportPoolImage0.R.Image = publicreportImage1
+
+ return nil
+}
+
+func attachPublicreportPoolImagePool0(ctx context.Context, exec bob.Executor, count int, publicreportPoolImage0 *PublicreportPoolImage, publicreportPool1 *PublicreportPool) (*PublicreportPoolImage, error) {
+ setter := &PublicreportPoolImageSetter{
+ PoolID: omit.From(publicreportPool1.ID),
+ }
+
+ err := publicreportPoolImage0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportPoolImagePool0: %w", err)
+ }
+
+ return publicreportPoolImage0, nil
+}
+
+func (publicreportPoolImage0 *PublicreportPoolImage) InsertPool(ctx context.Context, exec bob.Executor, related *PublicreportPoolSetter) error {
+ var err error
+
+ publicreportPool1, err := PublicreportPools.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachPublicreportPoolImagePool0(ctx, exec, 1, publicreportPoolImage0, publicreportPool1)
+ if err != nil {
+ return err
+ }
+
+ publicreportPoolImage0.R.Pool = publicreportPool1
+
+ return nil
+}
+
+func (publicreportPoolImage0 *PublicreportPoolImage) AttachPool(ctx context.Context, exec bob.Executor, publicreportPool1 *PublicreportPool) error {
+ var err error
+
+ _, err = attachPublicreportPoolImagePool0(ctx, exec, 1, publicreportPoolImage0, publicreportPool1)
+ if err != nil {
+ return err
+ }
+
+ publicreportPoolImage0.R.Pool = publicreportPool1
+
+ return nil
+}
+
+type publicreportPoolImageWhere[Q psql.Filterable] struct {
+ ImageID psql.WhereMod[Q, int32]
+ PoolID psql.WhereMod[Q, int32]
+}
+
+func (publicreportPoolImageWhere[Q]) AliasedAs(alias string) publicreportPoolImageWhere[Q] {
+ return buildPublicreportPoolImageWhere[Q](buildPublicreportPoolImageColumns(alias))
+}
+
+func buildPublicreportPoolImageWhere[Q psql.Filterable](cols publicreportPoolImageColumns) publicreportPoolImageWhere[Q] {
+ return publicreportPoolImageWhere[Q]{
+ ImageID: psql.Where[Q, int32](cols.ImageID),
+ PoolID: psql.Where[Q, int32](cols.PoolID),
+ }
+}
+
+func (o *PublicreportPoolImage) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "Image":
+ rel, ok := retrieved.(*PublicreportImage)
+ if !ok {
+ return fmt.Errorf("publicreportPoolImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Image = rel
+
+ return nil
+ case "Pool":
+ rel, ok := retrieved.(*PublicreportPool)
+ if !ok {
+ return fmt.Errorf("publicreportPoolImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Pool = rel
+
+ return nil
+ default:
+ return fmt.Errorf("publicreportPoolImage has no relationship %q", name)
+ }
+}
+
+type publicreportPoolImagePreloader struct {
+ Image func(...psql.PreloadOption) psql.Preloader
+ Pool func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildPublicreportPoolImagePreloader() publicreportPoolImagePreloader {
+ return publicreportPoolImagePreloader{
+ Image: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*PublicreportImage, PublicreportImageSlice](psql.PreloadRel{
+ Name: "Image",
+ Sides: []psql.PreloadSide{
+ {
+ From: PublicreportPoolImages,
+ To: PublicreportImages,
+ FromColumns: []string{"image_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, PublicreportImages.Columns.Names(), opts...)
+ },
+ Pool: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*PublicreportPool, PublicreportPoolSlice](psql.PreloadRel{
+ Name: "Pool",
+ Sides: []psql.PreloadSide{
+ {
+ From: PublicreportPoolImages,
+ To: PublicreportPools,
+ FromColumns: []string{"pool_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, PublicreportPools.Columns.Names(), opts...)
+ },
+ }
+}
+
+type publicreportPoolImageThenLoader[Q orm.Loadable] struct {
+ Image func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Pool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportPoolImageThenLoader[Q orm.Loadable]() publicreportPoolImageThenLoader[Q] {
+ type ImageLoadInterface interface {
+ LoadImage(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type PoolLoadInterface interface {
+ LoadPool(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportPoolImageThenLoader[Q]{
+ Image: thenLoadBuilder[Q](
+ "Image",
+ func(ctx context.Context, exec bob.Executor, retrieved ImageLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImage(ctx, exec, mods...)
+ },
+ ),
+ Pool: thenLoadBuilder[Q](
+ "Pool",
+ func(ctx context.Context, exec bob.Executor, retrieved PoolLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadPool(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadImage loads the publicreportPoolImage's Image into the .R struct
+func (o *PublicreportPoolImage) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Image = nil
+
+ related, err := o.Image(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R.Image = related
+ return nil
+}
+
+// LoadImage loads the publicreportPoolImage's Image into the .R struct
+func (os PublicreportPoolImageSlice) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportImages, err := os.Image(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportImages {
+
+ if !(o.ImageID == rel.ID) {
+ continue
+ }
+
+ o.R.Image = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+// LoadPool loads the publicreportPoolImage's Pool into the .R struct
+func (o *PublicreportPoolImage) LoadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Pool = nil
+
+ related, err := o.Pool(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R.Pool = related
+ return nil
+}
+
+// LoadPool loads the publicreportPoolImage's Pool into the .R struct
+func (os PublicreportPoolImageSlice) LoadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportPools, err := os.Pool(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportPools {
+
+ if !(o.PoolID == rel.ID) {
+ continue
+ }
+
+ o.R.Pool = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+type publicreportPoolImageJoins[Q dialect.Joinable] struct {
+ typ string
+ Image modAs[Q, publicreportImageColumns]
+ Pool modAs[Q, publicreportPoolColumns]
+}
+
+func (j publicreportPoolImageJoins[Q]) aliasedAs(alias string) publicreportPoolImageJoins[Q] {
+ return buildPublicreportPoolImageJoins[Q](buildPublicreportPoolImageColumns(alias), j.typ)
+}
+
+func buildPublicreportPoolImageJoins[Q dialect.Joinable](cols publicreportPoolImageColumns, typ string) publicreportPoolImageJoins[Q] {
+ return publicreportPoolImageJoins[Q]{
+ typ: typ,
+ Image: modAs[Q, publicreportImageColumns]{
+ c: PublicreportImages.Columns,
+ f: func(to publicreportImageColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.ImageID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ Pool: modAs[Q, publicreportPoolColumns]{
+ c: PublicreportPools.Columns,
+ f: func(to publicreportPoolColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportPools.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.PoolID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/publicreport.pool_photo.bob.go b/db/models/publicreport.pool_photo.bob.go
deleted file mode 100644
index 1240a0e3..00000000
--- a/db/models/publicreport.pool_photo.bob.go
+++ /dev/null
@@ -1,678 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package models
-
-import (
- "context"
- "fmt"
- "io"
-
- "github.com/aarondl/opt/omit"
- "github.com/google/uuid"
- "github.com/stephenafamo/bob"
- "github.com/stephenafamo/bob/dialect/psql"
- "github.com/stephenafamo/bob/dialect/psql/dialect"
- "github.com/stephenafamo/bob/dialect/psql/dm"
- "github.com/stephenafamo/bob/dialect/psql/sm"
- "github.com/stephenafamo/bob/dialect/psql/um"
- "github.com/stephenafamo/bob/expr"
- "github.com/stephenafamo/bob/mods"
- "github.com/stephenafamo/bob/orm"
- "github.com/stephenafamo/bob/types/pgtypes"
-)
-
-// PublicreportPoolPhoto is an object representing the database table.
-type PublicreportPoolPhoto struct {
- ID int32 `db:"id,pk" `
- Size int64 `db:"size" `
- Filename string `db:"filename" `
- PoolID int32 `db:"pool_id" `
- UUID uuid.UUID `db:"uuid" `
-
- R publicreportPoolPhotoR `db:"-" `
-}
-
-// PublicreportPoolPhotoSlice is an alias for a slice of pointers to PublicreportPoolPhoto.
-// This should almost always be used instead of []*PublicreportPoolPhoto.
-type PublicreportPoolPhotoSlice []*PublicreportPoolPhoto
-
-// PublicreportPoolPhotos contains methods to work with the pool_photo table
-var PublicreportPoolPhotos = psql.NewTablex[*PublicreportPoolPhoto, PublicreportPoolPhotoSlice, *PublicreportPoolPhotoSetter]("publicreport", "pool_photo", buildPublicreportPoolPhotoColumns("publicreport.pool_photo"))
-
-// PublicreportPoolPhotosQuery is a query on the pool_photo table
-type PublicreportPoolPhotosQuery = *psql.ViewQuery[*PublicreportPoolPhoto, PublicreportPoolPhotoSlice]
-
-// publicreportPoolPhotoR is where relationships are stored.
-type publicreportPoolPhotoR struct {
- Pool *PublicreportPool // publicreport.pool_photo.pool_photo_pool_id_fkey
-}
-
-func buildPublicreportPoolPhotoColumns(alias string) publicreportPoolPhotoColumns {
- return publicreportPoolPhotoColumns{
- ColumnsExpr: expr.NewColumnsExpr(
- "id", "size", "filename", "pool_id", "uuid",
- ).WithParent("publicreport.pool_photo"),
- tableAlias: alias,
- ID: psql.Quote(alias, "id"),
- Size: psql.Quote(alias, "size"),
- Filename: psql.Quote(alias, "filename"),
- PoolID: psql.Quote(alias, "pool_id"),
- UUID: psql.Quote(alias, "uuid"),
- }
-}
-
-type publicreportPoolPhotoColumns struct {
- expr.ColumnsExpr
- tableAlias string
- ID psql.Expression
- Size psql.Expression
- Filename psql.Expression
- PoolID psql.Expression
- UUID psql.Expression
-}
-
-func (c publicreportPoolPhotoColumns) Alias() string {
- return c.tableAlias
-}
-
-func (publicreportPoolPhotoColumns) AliasedAs(alias string) publicreportPoolPhotoColumns {
- return buildPublicreportPoolPhotoColumns(alias)
-}
-
-// PublicreportPoolPhotoSetter is used for insert/upsert/update operations
-// All values are optional, and do not have to be set
-// Generated columns are not included
-type PublicreportPoolPhotoSetter struct {
- ID omit.Val[int32] `db:"id,pk" `
- Size omit.Val[int64] `db:"size" `
- Filename omit.Val[string] `db:"filename" `
- PoolID omit.Val[int32] `db:"pool_id" `
- UUID omit.Val[uuid.UUID] `db:"uuid" `
-}
-
-func (s PublicreportPoolPhotoSetter) SetColumns() []string {
- vals := make([]string, 0, 5)
- if s.ID.IsValue() {
- vals = append(vals, "id")
- }
- if s.Size.IsValue() {
- vals = append(vals, "size")
- }
- if s.Filename.IsValue() {
- vals = append(vals, "filename")
- }
- if s.PoolID.IsValue() {
- vals = append(vals, "pool_id")
- }
- if s.UUID.IsValue() {
- vals = append(vals, "uuid")
- }
- return vals
-}
-
-func (s PublicreportPoolPhotoSetter) Overwrite(t *PublicreportPoolPhoto) {
- if s.ID.IsValue() {
- t.ID = s.ID.MustGet()
- }
- if s.Size.IsValue() {
- t.Size = s.Size.MustGet()
- }
- if s.Filename.IsValue() {
- t.Filename = s.Filename.MustGet()
- }
- if s.PoolID.IsValue() {
- t.PoolID = s.PoolID.MustGet()
- }
- if s.UUID.IsValue() {
- t.UUID = s.UUID.MustGet()
- }
-}
-
-func (s *PublicreportPoolPhotoSetter) Apply(q *dialect.InsertQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportPoolPhotos.BeforeInsertHooks.RunHooks(ctx, exec, s)
- })
-
- q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- vals := make([]bob.Expression, 5)
- if s.ID.IsValue() {
- vals[0] = psql.Arg(s.ID.MustGet())
- } else {
- vals[0] = psql.Raw("DEFAULT")
- }
-
- if s.Size.IsValue() {
- vals[1] = psql.Arg(s.Size.MustGet())
- } else {
- vals[1] = psql.Raw("DEFAULT")
- }
-
- if s.Filename.IsValue() {
- vals[2] = psql.Arg(s.Filename.MustGet())
- } else {
- vals[2] = psql.Raw("DEFAULT")
- }
-
- if s.PoolID.IsValue() {
- vals[3] = psql.Arg(s.PoolID.MustGet())
- } else {
- vals[3] = psql.Raw("DEFAULT")
- }
-
- if s.UUID.IsValue() {
- vals[4] = psql.Arg(s.UUID.MustGet())
- } else {
- vals[4] = psql.Raw("DEFAULT")
- }
-
- return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
- }))
-}
-
-func (s PublicreportPoolPhotoSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
- return um.Set(s.Expressions()...)
-}
-
-func (s PublicreportPoolPhotoSetter) Expressions(prefix ...string) []bob.Expression {
- exprs := make([]bob.Expression, 0, 5)
-
- if s.ID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "id")...),
- psql.Arg(s.ID),
- }})
- }
-
- if s.Size.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "size")...),
- psql.Arg(s.Size),
- }})
- }
-
- if s.Filename.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "filename")...),
- psql.Arg(s.Filename),
- }})
- }
-
- if s.PoolID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "pool_id")...),
- psql.Arg(s.PoolID),
- }})
- }
-
- if s.UUID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "uuid")...),
- psql.Arg(s.UUID),
- }})
- }
-
- return exprs
-}
-
-// FindPublicreportPoolPhoto retrieves a single record by primary key
-// If cols is empty Find will return all columns.
-func FindPublicreportPoolPhoto(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportPoolPhoto, error) {
- if len(cols) == 0 {
- return PublicreportPoolPhotos.Query(
- sm.Where(PublicreportPoolPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- ).One(ctx, exec)
- }
-
- return PublicreportPoolPhotos.Query(
- sm.Where(PublicreportPoolPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- sm.Columns(PublicreportPoolPhotos.Columns.Only(cols...)),
- ).One(ctx, exec)
-}
-
-// PublicreportPoolPhotoExists checks the presence of a single record by primary key
-func PublicreportPoolPhotoExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
- return PublicreportPoolPhotos.Query(
- sm.Where(PublicreportPoolPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- ).Exists(ctx, exec)
-}
-
-// AfterQueryHook is called after PublicreportPoolPhoto is retrieved from the database
-func (o *PublicreportPoolPhoto) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
- var err error
-
- switch queryType {
- case bob.QueryTypeSelect:
- ctx, err = PublicreportPoolPhotos.AfterSelectHooks.RunHooks(ctx, exec, PublicreportPoolPhotoSlice{o})
- case bob.QueryTypeInsert:
- ctx, err = PublicreportPoolPhotos.AfterInsertHooks.RunHooks(ctx, exec, PublicreportPoolPhotoSlice{o})
- case bob.QueryTypeUpdate:
- ctx, err = PublicreportPoolPhotos.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportPoolPhotoSlice{o})
- case bob.QueryTypeDelete:
- ctx, err = PublicreportPoolPhotos.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportPoolPhotoSlice{o})
- }
-
- return err
-}
-
-// primaryKeyVals returns the primary key values of the PublicreportPoolPhoto
-func (o *PublicreportPoolPhoto) primaryKeyVals() bob.Expression {
- return psql.Arg(o.ID)
-}
-
-func (o *PublicreportPoolPhoto) pkEQ() dialect.Expression {
- return psql.Quote("publicreport.pool_photo", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
- }))
-}
-
-// Update uses an executor to update the PublicreportPoolPhoto
-func (o *PublicreportPoolPhoto) Update(ctx context.Context, exec bob.Executor, s *PublicreportPoolPhotoSetter) error {
- v, err := PublicreportPoolPhotos.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
- if err != nil {
- return err
- }
-
- o.R = v.R
- *o = *v
-
- return nil
-}
-
-// Delete deletes a single PublicreportPoolPhoto record with an executor
-func (o *PublicreportPoolPhoto) Delete(ctx context.Context, exec bob.Executor) error {
- _, err := PublicreportPoolPhotos.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
- return err
-}
-
-// Reload refreshes the PublicreportPoolPhoto using the executor
-func (o *PublicreportPoolPhoto) Reload(ctx context.Context, exec bob.Executor) error {
- o2, err := PublicreportPoolPhotos.Query(
- sm.Where(PublicreportPoolPhotos.Columns.ID.EQ(psql.Arg(o.ID))),
- ).One(ctx, exec)
- if err != nil {
- return err
- }
- o2.R = o.R
- *o = *o2
-
- return nil
-}
-
-// AfterQueryHook is called after PublicreportPoolPhotoSlice is retrieved from the database
-func (o PublicreportPoolPhotoSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
- var err error
-
- switch queryType {
- case bob.QueryTypeSelect:
- ctx, err = PublicreportPoolPhotos.AfterSelectHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeInsert:
- ctx, err = PublicreportPoolPhotos.AfterInsertHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeUpdate:
- ctx, err = PublicreportPoolPhotos.AfterUpdateHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeDelete:
- ctx, err = PublicreportPoolPhotos.AfterDeleteHooks.RunHooks(ctx, exec, o)
- }
-
- return err
-}
-
-func (o PublicreportPoolPhotoSlice) pkIN() dialect.Expression {
- if len(o) == 0 {
- return psql.Raw("NULL")
- }
-
- return psql.Quote("publicreport.pool_photo", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- pkPairs := make([]bob.Expression, len(o))
- for i, row := range o {
- pkPairs[i] = row.primaryKeyVals()
- }
- return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
- }))
-}
-
-// copyMatchingRows finds models in the given slice that have the same primary key
-// then it first copies the existing relationships from the old model to the new model
-// and then replaces the old model in the slice with the new model
-func (o PublicreportPoolPhotoSlice) copyMatchingRows(from ...*PublicreportPoolPhoto) {
- for i, old := range o {
- for _, new := range from {
- if new.ID != old.ID {
- continue
- }
- new.R = old.R
- o[i] = new
- break
- }
- }
-}
-
-// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
-func (o PublicreportPoolPhotoSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
- return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportPoolPhotos.BeforeUpdateHooks.RunHooks(ctx, exec, o)
- })
-
- q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
- var err error
- switch retrieved := retrieved.(type) {
- case *PublicreportPoolPhoto:
- o.copyMatchingRows(retrieved)
- case []*PublicreportPoolPhoto:
- o.copyMatchingRows(retrieved...)
- case PublicreportPoolPhotoSlice:
- o.copyMatchingRows(retrieved...)
- default:
- // If the retrieved value is not a PublicreportPoolPhoto or a slice of PublicreportPoolPhoto
- // then run the AfterUpdateHooks on the slice
- _, err = PublicreportPoolPhotos.AfterUpdateHooks.RunHooks(ctx, exec, o)
- }
-
- return err
- }))
-
- q.AppendWhere(o.pkIN())
- })
-}
-
-// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
-func (o PublicreportPoolPhotoSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
- return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportPoolPhotos.BeforeDeleteHooks.RunHooks(ctx, exec, o)
- })
-
- q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
- var err error
- switch retrieved := retrieved.(type) {
- case *PublicreportPoolPhoto:
- o.copyMatchingRows(retrieved)
- case []*PublicreportPoolPhoto:
- o.copyMatchingRows(retrieved...)
- case PublicreportPoolPhotoSlice:
- o.copyMatchingRows(retrieved...)
- default:
- // If the retrieved value is not a PublicreportPoolPhoto or a slice of PublicreportPoolPhoto
- // then run the AfterDeleteHooks on the slice
- _, err = PublicreportPoolPhotos.AfterDeleteHooks.RunHooks(ctx, exec, o)
- }
-
- return err
- }))
-
- q.AppendWhere(o.pkIN())
- })
-}
-
-func (o PublicreportPoolPhotoSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportPoolPhotoSetter) error {
- if len(o) == 0 {
- return nil
- }
-
- _, err := PublicreportPoolPhotos.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
- return err
-}
-
-func (o PublicreportPoolPhotoSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
- if len(o) == 0 {
- return nil
- }
-
- _, err := PublicreportPoolPhotos.Delete(o.DeleteMod()).Exec(ctx, exec)
- return err
-}
-
-func (o PublicreportPoolPhotoSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
- if len(o) == 0 {
- return nil
- }
-
- o2, err := PublicreportPoolPhotos.Query(sm.Where(o.pkIN())).All(ctx, exec)
- if err != nil {
- return err
- }
-
- o.copyMatchingRows(o2...)
-
- return nil
-}
-
-// Pool starts a query for related objects on publicreport.pool
-func (o *PublicreportPoolPhoto) Pool(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
- return PublicreportPools.Query(append(mods,
- sm.Where(PublicreportPools.Columns.ID.EQ(psql.Arg(o.PoolID))),
- )...)
-}
-
-func (os PublicreportPoolPhotoSlice) Pool(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportPoolsQuery {
- pkPoolID := make(pgtypes.Array[int32], 0, len(os))
- for _, o := range os {
- if o == nil {
- continue
- }
- pkPoolID = append(pkPoolID, o.PoolID)
- }
- PKArgExpr := psql.Select(sm.Columns(
- psql.F("unnest", psql.Cast(psql.Arg(pkPoolID), "integer[]")),
- ))
-
- return PublicreportPools.Query(append(mods,
- sm.Where(psql.Group(PublicreportPools.Columns.ID).OP("IN", PKArgExpr)),
- )...)
-}
-
-func attachPublicreportPoolPhotoPool0(ctx context.Context, exec bob.Executor, count int, publicreportPoolPhoto0 *PublicreportPoolPhoto, publicreportPool1 *PublicreportPool) (*PublicreportPoolPhoto, error) {
- setter := &PublicreportPoolPhotoSetter{
- PoolID: omit.From(publicreportPool1.ID),
- }
-
- err := publicreportPoolPhoto0.Update(ctx, exec, setter)
- if err != nil {
- return nil, fmt.Errorf("attachPublicreportPoolPhotoPool0: %w", err)
- }
-
- return publicreportPoolPhoto0, nil
-}
-
-func (publicreportPoolPhoto0 *PublicreportPoolPhoto) InsertPool(ctx context.Context, exec bob.Executor, related *PublicreportPoolSetter) error {
- var err error
-
- publicreportPool1, err := PublicreportPools.Insert(related).One(ctx, exec)
- if err != nil {
- return fmt.Errorf("inserting related objects: %w", err)
- }
-
- _, err = attachPublicreportPoolPhotoPool0(ctx, exec, 1, publicreportPoolPhoto0, publicreportPool1)
- if err != nil {
- return err
- }
-
- publicreportPoolPhoto0.R.Pool = publicreportPool1
-
- publicreportPool1.R.PoolPhotos = append(publicreportPool1.R.PoolPhotos, publicreportPoolPhoto0)
-
- return nil
-}
-
-func (publicreportPoolPhoto0 *PublicreportPoolPhoto) AttachPool(ctx context.Context, exec bob.Executor, publicreportPool1 *PublicreportPool) error {
- var err error
-
- _, err = attachPublicreportPoolPhotoPool0(ctx, exec, 1, publicreportPoolPhoto0, publicreportPool1)
- if err != nil {
- return err
- }
-
- publicreportPoolPhoto0.R.Pool = publicreportPool1
-
- publicreportPool1.R.PoolPhotos = append(publicreportPool1.R.PoolPhotos, publicreportPoolPhoto0)
-
- return nil
-}
-
-type publicreportPoolPhotoWhere[Q psql.Filterable] struct {
- ID psql.WhereMod[Q, int32]
- Size psql.WhereMod[Q, int64]
- Filename psql.WhereMod[Q, string]
- PoolID psql.WhereMod[Q, int32]
- UUID psql.WhereMod[Q, uuid.UUID]
-}
-
-func (publicreportPoolPhotoWhere[Q]) AliasedAs(alias string) publicreportPoolPhotoWhere[Q] {
- return buildPublicreportPoolPhotoWhere[Q](buildPublicreportPoolPhotoColumns(alias))
-}
-
-func buildPublicreportPoolPhotoWhere[Q psql.Filterable](cols publicreportPoolPhotoColumns) publicreportPoolPhotoWhere[Q] {
- return publicreportPoolPhotoWhere[Q]{
- ID: psql.Where[Q, int32](cols.ID),
- Size: psql.Where[Q, int64](cols.Size),
- Filename: psql.Where[Q, string](cols.Filename),
- PoolID: psql.Where[Q, int32](cols.PoolID),
- UUID: psql.Where[Q, uuid.UUID](cols.UUID),
- }
-}
-
-func (o *PublicreportPoolPhoto) Preload(name string, retrieved any) error {
- if o == nil {
- return nil
- }
-
- switch name {
- case "Pool":
- rel, ok := retrieved.(*PublicreportPool)
- if !ok {
- return fmt.Errorf("publicreportPoolPhoto cannot load %T as %q", retrieved, name)
- }
-
- o.R.Pool = rel
-
- if rel != nil {
- rel.R.PoolPhotos = PublicreportPoolPhotoSlice{o}
- }
- return nil
- default:
- return fmt.Errorf("publicreportPoolPhoto has no relationship %q", name)
- }
-}
-
-type publicreportPoolPhotoPreloader struct {
- Pool func(...psql.PreloadOption) psql.Preloader
-}
-
-func buildPublicreportPoolPhotoPreloader() publicreportPoolPhotoPreloader {
- return publicreportPoolPhotoPreloader{
- Pool: func(opts ...psql.PreloadOption) psql.Preloader {
- return psql.Preload[*PublicreportPool, PublicreportPoolSlice](psql.PreloadRel{
- Name: "Pool",
- Sides: []psql.PreloadSide{
- {
- From: PublicreportPoolPhotos,
- To: PublicreportPools,
- FromColumns: []string{"pool_id"},
- ToColumns: []string{"id"},
- },
- },
- }, PublicreportPools.Columns.Names(), opts...)
- },
- }
-}
-
-type publicreportPoolPhotoThenLoader[Q orm.Loadable] struct {
- Pool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
-}
-
-func buildPublicreportPoolPhotoThenLoader[Q orm.Loadable]() publicreportPoolPhotoThenLoader[Q] {
- type PoolLoadInterface interface {
- LoadPool(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
- }
-
- return publicreportPoolPhotoThenLoader[Q]{
- Pool: thenLoadBuilder[Q](
- "Pool",
- func(ctx context.Context, exec bob.Executor, retrieved PoolLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadPool(ctx, exec, mods...)
- },
- ),
- }
-}
-
-// LoadPool loads the publicreportPoolPhoto's Pool into the .R struct
-func (o *PublicreportPoolPhoto) LoadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
- if o == nil {
- return nil
- }
-
- // Reset the relationship
- o.R.Pool = nil
-
- related, err := o.Pool(mods...).One(ctx, exec)
- if err != nil {
- return err
- }
-
- related.R.PoolPhotos = PublicreportPoolPhotoSlice{o}
-
- o.R.Pool = related
- return nil
-}
-
-// LoadPool loads the publicreportPoolPhoto's Pool into the .R struct
-func (os PublicreportPoolPhotoSlice) LoadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
- if len(os) == 0 {
- return nil
- }
-
- publicreportPools, err := os.Pool(mods...).All(ctx, exec)
- if err != nil {
- return err
- }
-
- for _, o := range os {
- if o == nil {
- continue
- }
-
- for _, rel := range publicreportPools {
-
- if !(o.PoolID == rel.ID) {
- continue
- }
-
- rel.R.PoolPhotos = append(rel.R.PoolPhotos, o)
-
- o.R.Pool = rel
- break
- }
- }
-
- return nil
-}
-
-type publicreportPoolPhotoJoins[Q dialect.Joinable] struct {
- typ string
- Pool modAs[Q, publicreportPoolColumns]
-}
-
-func (j publicreportPoolPhotoJoins[Q]) aliasedAs(alias string) publicreportPoolPhotoJoins[Q] {
- return buildPublicreportPoolPhotoJoins[Q](buildPublicreportPoolPhotoColumns(alias), j.typ)
-}
-
-func buildPublicreportPoolPhotoJoins[Q dialect.Joinable](cols publicreportPoolPhotoColumns, typ string) publicreportPoolPhotoJoins[Q] {
- return publicreportPoolPhotoJoins[Q]{
- typ: typ,
- Pool: modAs[Q, publicreportPoolColumns]{
- c: PublicreportPools.Columns,
- f: func(to publicreportPoolColumns) bob.Mod[Q] {
- mods := make(mods.QueryMods[Q], 0, 1)
-
- {
- mods = append(mods, dialect.Join[Q](typ, PublicreportPools.Name().As(to.Alias())).On(
- to.ID.EQ(cols.PoolID),
- ))
- }
-
- return mods
- },
- },
- }
-}
diff --git a/db/models/publicreport.quick.bob.go b/db/models/publicreport.quick.bob.go
index 5cec372c..c6514bb6 100644
--- a/db/models/publicreport.quick.bob.go
+++ b/db/models/publicreport.quick.bob.go
@@ -7,6 +7,7 @@ import (
"context"
"fmt"
"io"
+ "strconv"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
@@ -23,6 +24,7 @@ import (
"github.com/stephenafamo/bob/mods"
"github.com/stephenafamo/bob/orm"
"github.com/stephenafamo/bob/types/pgtypes"
+ "github.com/stephenafamo/scan"
)
// PublicreportQuick is an object representing the database table.
@@ -55,7 +57,7 @@ type PublicreportQuicksQuery = *psql.ViewQuery[*PublicreportQuick, PublicreportQ
// publicreportQuickR is where relationships are stored.
type publicreportQuickR struct {
- QuickPhotos PublicreportQuickPhotoSlice // publicreport.quick_photo.quick_photo_quick_id_fkey
+ Images PublicreportImageSlice // publicreport.quick_image.quick_image_image_id_fkeypublicreport.quick_image.quick_image_quick_id_fkey
}
func buildPublicreportQuickColumns(alias string) publicreportQuickColumns {
@@ -558,14 +560,16 @@ func (o PublicreportQuickSlice) ReloadAll(ctx context.Context, exec bob.Executor
return nil
}
-// QuickPhotos starts a query for related objects on publicreport.quick_photo
-func (o *PublicreportQuick) QuickPhotos(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuickPhotosQuery {
- return PublicreportQuickPhotos.Query(append(mods,
- sm.Where(PublicreportQuickPhotos.Columns.QuickID.EQ(psql.Arg(o.ID))),
+// Images starts a query for related objects on publicreport.image
+func (o *PublicreportQuick) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ return PublicreportImages.Query(append(mods,
+ sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
+ PublicreportImages.Columns.ID.EQ(PublicreportQuickImages.Columns.ImageID)),
+ sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(o.ID))),
)...)
}
-func (os PublicreportQuickSlice) QuickPhotos(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuickPhotosQuery {
+func (os PublicreportQuickSlice) Images(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
pkID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
@@ -577,74 +581,74 @@ func (os PublicreportQuickSlice) QuickPhotos(mods ...bob.Mod[*dialect.SelectQuer
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
))
- return PublicreportQuickPhotos.Query(append(mods,
- sm.Where(psql.Group(PublicreportQuickPhotos.Columns.QuickID).OP("IN", PKArgExpr)),
+ return PublicreportImages.Query(append(mods,
+ sm.InnerJoin(PublicreportQuickImages.NameAs()).On(
+ PublicreportImages.Columns.ID.EQ(PublicreportQuickImages.Columns.ImageID),
+ ),
+ sm.Where(psql.Group(PublicreportQuickImages.Columns.QuickID).OP("IN", PKArgExpr)),
)...)
}
-func insertPublicreportQuickQuickPhotos0(ctx context.Context, exec bob.Executor, publicreportQuickPhotos1 []*PublicreportQuickPhotoSetter, publicreportQuick0 *PublicreportQuick) (PublicreportQuickPhotoSlice, error) {
- for i := range publicreportQuickPhotos1 {
- publicreportQuickPhotos1[i].QuickID = omit.From(publicreportQuick0.ID)
+func attachPublicreportQuickImages0(ctx context.Context, exec bob.Executor, count int, publicreportQuick0 *PublicreportQuick, publicreportImages2 PublicreportImageSlice) (PublicreportQuickImageSlice, error) {
+ setters := make([]*PublicreportQuickImageSetter, count)
+ for i := range count {
+ setters[i] = &PublicreportQuickImageSetter{
+ QuickID: omit.From(publicreportQuick0.ID),
+ ImageID: omit.From(publicreportImages2[i].ID),
+ }
}
- ret, err := PublicreportQuickPhotos.Insert(bob.ToMods(publicreportQuickPhotos1...)).All(ctx, exec)
+ publicreportQuickImages1, err := PublicreportQuickImages.Insert(bob.ToMods(setters...)).All(ctx, exec)
if err != nil {
- return ret, fmt.Errorf("insertPublicreportQuickQuickPhotos0: %w", err)
+ return nil, fmt.Errorf("attachPublicreportQuickImages0: %w", err)
}
- return ret, nil
+ return publicreportQuickImages1, nil
}
-func attachPublicreportQuickQuickPhotos0(ctx context.Context, exec bob.Executor, count int, publicreportQuickPhotos1 PublicreportQuickPhotoSlice, publicreportQuick0 *PublicreportQuick) (PublicreportQuickPhotoSlice, error) {
- setter := &PublicreportQuickPhotoSetter{
- QuickID: omit.From(publicreportQuick0.ID),
- }
-
- err := publicreportQuickPhotos1.UpdateAll(ctx, exec, *setter)
- if err != nil {
- return nil, fmt.Errorf("attachPublicreportQuickQuickPhotos0: %w", err)
- }
-
- return publicreportQuickPhotos1, nil
-}
-
-func (publicreportQuick0 *PublicreportQuick) InsertQuickPhotos(ctx context.Context, exec bob.Executor, related ...*PublicreportQuickPhotoSetter) error {
+func (publicreportQuick0 *PublicreportQuick) InsertImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImageSetter) error {
if len(related) == 0 {
return nil
}
var err error
- publicreportQuickPhotos1, err := insertPublicreportQuickQuickPhotos0(ctx, exec, related, publicreportQuick0)
+ inserted, err := PublicreportImages.Insert(bob.ToMods(related...)).All(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+ publicreportImages2 := PublicreportImageSlice(inserted)
+
+ _, err = attachPublicreportQuickImages0(ctx, exec, len(related), publicreportQuick0, publicreportImages2)
if err != nil {
return err
}
- publicreportQuick0.R.QuickPhotos = append(publicreportQuick0.R.QuickPhotos, publicreportQuickPhotos1...)
+ publicreportQuick0.R.Images = append(publicreportQuick0.R.Images, publicreportImages2...)
- for _, rel := range publicreportQuickPhotos1 {
- rel.R.Quick = publicreportQuick0
+ for _, rel := range publicreportImages2 {
+ rel.R.Quicks = append(rel.R.Quicks, publicreportQuick0)
}
return nil
}
-func (publicreportQuick0 *PublicreportQuick) AttachQuickPhotos(ctx context.Context, exec bob.Executor, related ...*PublicreportQuickPhoto) error {
+func (publicreportQuick0 *PublicreportQuick) AttachImages(ctx context.Context, exec bob.Executor, related ...*PublicreportImage) error {
if len(related) == 0 {
return nil
}
var err error
- publicreportQuickPhotos1 := PublicreportQuickPhotoSlice(related)
+ publicreportImages2 := PublicreportImageSlice(related)
- _, err = attachPublicreportQuickQuickPhotos0(ctx, exec, len(related), publicreportQuickPhotos1, publicreportQuick0)
+ _, err = attachPublicreportQuickImages0(ctx, exec, len(related), publicreportQuick0, publicreportImages2)
if err != nil {
return err
}
- publicreportQuick0.R.QuickPhotos = append(publicreportQuick0.R.QuickPhotos, publicreportQuickPhotos1...)
+ publicreportQuick0.R.Images = append(publicreportQuick0.R.Images, publicreportImages2...)
for _, rel := range related {
- rel.R.Quick = publicreportQuick0
+ rel.R.Quicks = append(rel.R.Quicks, publicreportQuick0)
}
return nil
@@ -688,17 +692,17 @@ func (o *PublicreportQuick) Preload(name string, retrieved any) error {
}
switch name {
- case "QuickPhotos":
- rels, ok := retrieved.(PublicreportQuickPhotoSlice)
+ case "Images":
+ rels, ok := retrieved.(PublicreportImageSlice)
if !ok {
return fmt.Errorf("publicreportQuick cannot load %T as %q", retrieved, name)
}
- o.R.QuickPhotos = rels
+ o.R.Images = rels
for _, rel := range rels {
if rel != nil {
- rel.R.Quick = o
+ rel.R.Quicks = PublicreportQuickSlice{o}
}
}
return nil
@@ -714,79 +718,99 @@ func buildPublicreportQuickPreloader() publicreportQuickPreloader {
}
type publicreportQuickThenLoader[Q orm.Loadable] struct {
- QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildPublicreportQuickThenLoader[Q orm.Loadable]() publicreportQuickThenLoader[Q] {
- type QuickPhotosLoadInterface interface {
- LoadQuickPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ type ImagesLoadInterface interface {
+ LoadImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return publicreportQuickThenLoader[Q]{
- QuickPhotos: thenLoadBuilder[Q](
- "QuickPhotos",
- func(ctx context.Context, exec bob.Executor, retrieved QuickPhotosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadQuickPhotos(ctx, exec, mods...)
+ Images: thenLoadBuilder[Q](
+ "Images",
+ func(ctx context.Context, exec bob.Executor, retrieved ImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImages(ctx, exec, mods...)
},
),
}
}
-// LoadQuickPhotos loads the publicreportQuick's QuickPhotos into the .R struct
-func (o *PublicreportQuick) LoadQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadImages loads the publicreportQuick's Images into the .R struct
+func (o *PublicreportQuick) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
- o.R.QuickPhotos = nil
+ o.R.Images = nil
- related, err := o.QuickPhotos(mods...).All(ctx, exec)
+ related, err := o.Images(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, rel := range related {
- rel.R.Quick = o
+ rel.R.Quicks = PublicreportQuickSlice{o}
}
- o.R.QuickPhotos = related
+ o.R.Images = related
return nil
}
-// LoadQuickPhotos loads the publicreportQuick's QuickPhotos into the .R struct
-func (os PublicreportQuickSlice) LoadQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadImages loads the publicreportQuick's Images into the .R struct
+func (os PublicreportQuickSlice) LoadImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
- publicreportQuickPhotos, err := os.QuickPhotos(mods...).All(ctx, exec)
+ // since we are changing the columns, we need to check if the original columns were set or add the defaults
+ sq := dialect.SelectQuery{}
+ for _, mod := range mods {
+ mod.Apply(&sq)
+ }
+
+ if len(sq.SelectList.Columns) == 0 {
+ mods = append(mods, sm.Columns(PublicreportImages.Columns))
+ }
+
+ q := os.Images(append(
+ mods,
+ sm.Columns(PublicreportQuickImages.Columns.QuickID.As("related_publicreport.quick.ID")),
+ )...)
+
+ IDSlice := []int32{}
+
+ mapper := scan.Mod(scan.StructMapper[*PublicreportImage](), func(ctx context.Context, cols []string) (scan.BeforeFunc, func(any, any) error) {
+ return func(row *scan.Row) (any, error) {
+ IDSlice = append(IDSlice, *new(int32))
+ row.ScheduleScanByName("related_publicreport.quick.ID", &IDSlice[len(IDSlice)-1])
+
+ return nil, nil
+ },
+ func(any, any) error {
+ return nil
+ }
+ })
+
+ publicreportImages, err := bob.Allx[bob.SliceTransformer[*PublicreportImage, PublicreportImageSlice]](ctx, exec, q, mapper)
if err != nil {
return err
}
for _, o := range os {
- if o == nil {
- continue
- }
-
- o.R.QuickPhotos = nil
+ o.R.Images = nil
}
for _, o := range os {
- if o == nil {
- continue
- }
-
- for _, rel := range publicreportQuickPhotos {
-
- if !(o.ID == rel.QuickID) {
+ for i, rel := range publicreportImages {
+ if !(o.ID == IDSlice[i]) {
continue
}
- rel.R.Quick = o
+ rel.R.Quicks = append(rel.R.Quicks, o)
- o.R.QuickPhotos = append(o.R.QuickPhotos, rel)
+ o.R.Images = append(o.R.Images, rel)
}
}
@@ -795,7 +819,7 @@ func (os PublicreportQuickSlice) LoadQuickPhotos(ctx context.Context, exec bob.E
// publicreportQuickC is where relationship counts are stored.
type publicreportQuickC struct {
- QuickPhotos *int64
+ Images *int64
}
// PreloadCount sets a count in the C struct by name
@@ -805,20 +829,20 @@ func (o *PublicreportQuick) PreloadCount(name string, count int64) error {
}
switch name {
- case "QuickPhotos":
- o.C.QuickPhotos = &count
+ case "Images":
+ o.C.Images = &count
}
return nil
}
type publicreportQuickCountPreloader struct {
- QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
+ Images func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
}
func buildPublicreportQuickCountPreloader() publicreportQuickCountPreloader {
return publicreportQuickCountPreloader{
- QuickPhotos: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
- return countPreloader[*PublicreportQuick]("QuickPhotos", func(parent string) bob.Expression {
+ Images: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
+ return countPreloader[*PublicreportQuick]("Images", func(parent string) bob.Expression {
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
if parent == "" {
parent = PublicreportQuicks.Alias()
@@ -827,8 +851,11 @@ func buildPublicreportQuickCountPreloader() publicreportQuickCountPreloader {
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
sm.Columns(psql.Raw("count(*)")),
- sm.From(PublicreportQuickPhotos.Name()),
- sm.Where(psql.Quote(PublicreportQuickPhotos.Alias(), "quick_id").EQ(psql.Quote(parent, "id"))),
+ sm.From(PublicreportQuickImages.Name()),
+ sm.Where(psql.Quote(PublicreportQuickImages.Alias(), "quick_id").EQ(psql.Quote(parent, "id"))),
+ sm.InnerJoin(PublicreportImages.Name()).On(
+ psql.Quote(PublicreportImages.Alias(), "id").EQ(psql.Quote(PublicreportQuickImages.Alias(), "image_id")),
+ ),
}
subqueryMods = append(subqueryMods, mods...)
return psql.Group(psql.Select(subqueryMods...).Expression)
@@ -838,47 +865,47 @@ func buildPublicreportQuickCountPreloader() publicreportQuickCountPreloader {
}
type publicreportQuickCountThenLoader[Q orm.Loadable] struct {
- QuickPhotos func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildPublicreportQuickCountThenLoader[Q orm.Loadable]() publicreportQuickCountThenLoader[Q] {
- type QuickPhotosCountInterface interface {
- LoadCountQuickPhotos(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ type ImagesCountInterface interface {
+ LoadCountImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return publicreportQuickCountThenLoader[Q]{
- QuickPhotos: countThenLoadBuilder[Q](
- "QuickPhotos",
- func(ctx context.Context, exec bob.Executor, retrieved QuickPhotosCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadCountQuickPhotos(ctx, exec, mods...)
+ Images: countThenLoadBuilder[Q](
+ "Images",
+ func(ctx context.Context, exec bob.Executor, retrieved ImagesCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadCountImages(ctx, exec, mods...)
},
),
}
}
-// LoadCountQuickPhotos loads the count of QuickPhotos into the C struct
-func (o *PublicreportQuick) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadCountImages loads the count of Images into the C struct
+func (o *PublicreportQuick) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
- count, err := o.QuickPhotos(mods...).Count(ctx, exec)
+ count, err := o.Images(mods...).Count(ctx, exec)
if err != nil {
return err
}
- o.C.QuickPhotos = &count
+ o.C.Images = &count
return nil
}
-// LoadCountQuickPhotos loads the count of QuickPhotos for a slice
-func (os PublicreportQuickSlice) LoadCountQuickPhotos(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+// LoadCountImages loads the count of Images for a slice
+func (os PublicreportQuickSlice) LoadCountImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
for _, o := range os {
- if err := o.LoadCountQuickPhotos(ctx, exec, mods...); err != nil {
+ if err := o.LoadCountImages(ctx, exec, mods...); err != nil {
return err
}
}
@@ -887,8 +914,8 @@ func (os PublicreportQuickSlice) LoadCountQuickPhotos(ctx context.Context, exec
}
type publicreportQuickJoins[Q dialect.Joinable] struct {
- typ string
- QuickPhotos modAs[Q, publicreportQuickPhotoColumns]
+ typ string
+ Images modAs[Q, publicreportImageColumns]
}
func (j publicreportQuickJoins[Q]) aliasedAs(alias string) publicreportQuickJoins[Q] {
@@ -898,16 +925,24 @@ func (j publicreportQuickJoins[Q]) aliasedAs(alias string) publicreportQuickJoin
func buildPublicreportQuickJoins[Q dialect.Joinable](cols publicreportQuickColumns, typ string) publicreportQuickJoins[Q] {
return publicreportQuickJoins[Q]{
typ: typ,
- QuickPhotos: modAs[Q, publicreportQuickPhotoColumns]{
- c: PublicreportQuickPhotos.Columns,
- f: func(to publicreportQuickPhotoColumns) bob.Mod[Q] {
- mods := make(mods.QueryMods[Q], 0, 1)
+ Images: modAs[Q, publicreportImageColumns]{
+ c: PublicreportImages.Columns,
+ f: func(to publicreportImageColumns) bob.Mod[Q] {
+ random := strconv.FormatInt(randInt(), 10)
+ mods := make(mods.QueryMods[Q], 0, 2)
{
- mods = append(mods, dialect.Join[Q](typ, PublicreportQuickPhotos.Name().As(to.Alias())).On(
+ to := PublicreportQuickImages.Columns.AliasedAs(PublicreportQuickImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportQuickImages.Name().As(to.Alias())).On(
to.QuickID.EQ(cols.ID),
))
}
+ {
+ cols := PublicreportQuickImages.Columns.AliasedAs(PublicreportQuickImages.Columns.Alias() + random)
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.ImageID),
+ ))
+ }
return mods
},
diff --git a/db/models/publicreport.quick_image.bob.go b/db/models/publicreport.quick_image.bob.go
new file mode 100644
index 00000000..9d78ab8c
--- /dev/null
+++ b/db/models/publicreport.quick_image.bob.go
@@ -0,0 +1,766 @@
+// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
+// This file is meant to be re-generated in place and/or deleted at any time.
+
+package models
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/dialect"
+ "github.com/stephenafamo/bob/dialect/psql/dm"
+ "github.com/stephenafamo/bob/dialect/psql/sm"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+ "github.com/stephenafamo/bob/expr"
+ "github.com/stephenafamo/bob/mods"
+ "github.com/stephenafamo/bob/orm"
+ "github.com/stephenafamo/bob/types/pgtypes"
+)
+
+// PublicreportQuickImage is an object representing the database table.
+type PublicreportQuickImage struct {
+ ImageID int32 `db:"image_id,pk" `
+ QuickID int32 `db:"quick_id,pk" `
+
+ R publicreportQuickImageR `db:"-" `
+}
+
+// PublicreportQuickImageSlice is an alias for a slice of pointers to PublicreportQuickImage.
+// This should almost always be used instead of []*PublicreportQuickImage.
+type PublicreportQuickImageSlice []*PublicreportQuickImage
+
+// PublicreportQuickImages contains methods to work with the quick_image table
+var PublicreportQuickImages = psql.NewTablex[*PublicreportQuickImage, PublicreportQuickImageSlice, *PublicreportQuickImageSetter]("publicreport", "quick_image", buildPublicreportQuickImageColumns("publicreport.quick_image"))
+
+// PublicreportQuickImagesQuery is a query on the quick_image table
+type PublicreportQuickImagesQuery = *psql.ViewQuery[*PublicreportQuickImage, PublicreportQuickImageSlice]
+
+// publicreportQuickImageR is where relationships are stored.
+type publicreportQuickImageR struct {
+ Image *PublicreportImage // publicreport.quick_image.quick_image_image_id_fkey
+ Quick *PublicreportQuick // publicreport.quick_image.quick_image_quick_id_fkey
+}
+
+func buildPublicreportQuickImageColumns(alias string) publicreportQuickImageColumns {
+ return publicreportQuickImageColumns{
+ ColumnsExpr: expr.NewColumnsExpr(
+ "image_id", "quick_id",
+ ).WithParent("publicreport.quick_image"),
+ tableAlias: alias,
+ ImageID: psql.Quote(alias, "image_id"),
+ QuickID: psql.Quote(alias, "quick_id"),
+ }
+}
+
+type publicreportQuickImageColumns struct {
+ expr.ColumnsExpr
+ tableAlias string
+ ImageID psql.Expression
+ QuickID psql.Expression
+}
+
+func (c publicreportQuickImageColumns) Alias() string {
+ return c.tableAlias
+}
+
+func (publicreportQuickImageColumns) AliasedAs(alias string) publicreportQuickImageColumns {
+ return buildPublicreportQuickImageColumns(alias)
+}
+
+// PublicreportQuickImageSetter is used for insert/upsert/update operations
+// All values are optional, and do not have to be set
+// Generated columns are not included
+type PublicreportQuickImageSetter struct {
+ ImageID omit.Val[int32] `db:"image_id,pk" `
+ QuickID omit.Val[int32] `db:"quick_id,pk" `
+}
+
+func (s PublicreportQuickImageSetter) SetColumns() []string {
+ vals := make([]string, 0, 2)
+ if s.ImageID.IsValue() {
+ vals = append(vals, "image_id")
+ }
+ if s.QuickID.IsValue() {
+ vals = append(vals, "quick_id")
+ }
+ return vals
+}
+
+func (s PublicreportQuickImageSetter) Overwrite(t *PublicreportQuickImage) {
+ if s.ImageID.IsValue() {
+ t.ImageID = s.ImageID.MustGet()
+ }
+ if s.QuickID.IsValue() {
+ t.QuickID = s.QuickID.MustGet()
+ }
+}
+
+func (s *PublicreportQuickImageSetter) Apply(q *dialect.InsertQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportQuickImages.BeforeInsertHooks.RunHooks(ctx, exec, s)
+ })
+
+ q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ vals := make([]bob.Expression, 2)
+ if s.ImageID.IsValue() {
+ vals[0] = psql.Arg(s.ImageID.MustGet())
+ } else {
+ vals[0] = psql.Raw("DEFAULT")
+ }
+
+ if s.QuickID.IsValue() {
+ vals[1] = psql.Arg(s.QuickID.MustGet())
+ } else {
+ vals[1] = psql.Raw("DEFAULT")
+ }
+
+ return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
+ }))
+}
+
+func (s PublicreportQuickImageSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return um.Set(s.Expressions()...)
+}
+
+func (s PublicreportQuickImageSetter) Expressions(prefix ...string) []bob.Expression {
+ exprs := make([]bob.Expression, 0, 2)
+
+ if s.ImageID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "image_id")...),
+ psql.Arg(s.ImageID),
+ }})
+ }
+
+ if s.QuickID.IsValue() {
+ exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
+ psql.Quote(append(prefix, "quick_id")...),
+ psql.Arg(s.QuickID),
+ }})
+ }
+
+ return exprs
+}
+
+// FindPublicreportQuickImage retrieves a single record by primary key
+// If cols is empty Find will return all columns.
+func FindPublicreportQuickImage(ctx context.Context, exec bob.Executor, ImageIDPK int32, QuickIDPK int32, cols ...string) (*PublicreportQuickImage, error) {
+ if len(cols) == 0 {
+ return PublicreportQuickImages.Query(
+ sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
+ ).One(ctx, exec)
+ }
+
+ return PublicreportQuickImages.Query(
+ sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
+ sm.Columns(PublicreportQuickImages.Columns.Only(cols...)),
+ ).One(ctx, exec)
+}
+
+// PublicreportQuickImageExists checks the presence of a single record by primary key
+func PublicreportQuickImageExists(ctx context.Context, exec bob.Executor, ImageIDPK int32, QuickIDPK int32) (bool, error) {
+ return PublicreportQuickImages.Query(
+ sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(ImageIDPK))),
+ sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(QuickIDPK))),
+ ).Exists(ctx, exec)
+}
+
+// AfterQueryHook is called after PublicreportQuickImage is retrieved from the database
+func (o *PublicreportQuickImage) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportQuickImages.AfterSelectHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportQuickImages.AfterInsertHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportQuickImageSlice{o})
+ }
+
+ return err
+}
+
+// primaryKeyVals returns the primary key values of the PublicreportQuickImage
+func (o *PublicreportQuickImage) primaryKeyVals() bob.Expression {
+ return psql.ArgGroup(
+ o.ImageID,
+ o.QuickID,
+ )
+}
+
+func (o *PublicreportQuickImage) pkEQ() dialect.Expression {
+ return psql.Group(psql.Quote("publicreport.quick_image", "image_id"), psql.Quote("publicreport.quick_image", "quick_id")).EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
+ }))
+}
+
+// Update uses an executor to update the PublicreportQuickImage
+func (o *PublicreportQuickImage) Update(ctx context.Context, exec bob.Executor, s *PublicreportQuickImageSetter) error {
+ v, err := PublicreportQuickImages.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R = v.R
+ *o = *v
+
+ return nil
+}
+
+// Delete deletes a single PublicreportQuickImage record with an executor
+func (o *PublicreportQuickImage) Delete(ctx context.Context, exec bob.Executor) error {
+ _, err := PublicreportQuickImages.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
+ return err
+}
+
+// Reload refreshes the PublicreportQuickImage using the executor
+func (o *PublicreportQuickImage) Reload(ctx context.Context, exec bob.Executor) error {
+ o2, err := PublicreportQuickImages.Query(
+ sm.Where(PublicreportQuickImages.Columns.ImageID.EQ(psql.Arg(o.ImageID))),
+ sm.Where(PublicreportQuickImages.Columns.QuickID.EQ(psql.Arg(o.QuickID))),
+ ).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+ o2.R = o.R
+ *o = *o2
+
+ return nil
+}
+
+// AfterQueryHook is called after PublicreportQuickImageSlice is retrieved from the database
+func (o PublicreportQuickImageSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
+ var err error
+
+ switch queryType {
+ case bob.QueryTypeSelect:
+ ctx, err = PublicreportQuickImages.AfterSelectHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeInsert:
+ ctx, err = PublicreportQuickImages.AfterInsertHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeUpdate:
+ ctx, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ case bob.QueryTypeDelete:
+ ctx, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+}
+
+func (o PublicreportQuickImageSlice) pkIN() dialect.Expression {
+ if len(o) == 0 {
+ return psql.Raw("NULL")
+ }
+
+ return psql.Group(psql.Quote("publicreport.quick_image", "image_id"), psql.Quote("publicreport.quick_image", "quick_id")).In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
+ pkPairs := make([]bob.Expression, len(o))
+ for i, row := range o {
+ pkPairs[i] = row.primaryKeyVals()
+ }
+ return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
+ }))
+}
+
+// copyMatchingRows finds models in the given slice that have the same primary key
+// then it first copies the existing relationships from the old model to the new model
+// and then replaces the old model in the slice with the new model
+func (o PublicreportQuickImageSlice) copyMatchingRows(from ...*PublicreportQuickImage) {
+ for i, old := range o {
+ for _, new := range from {
+ if new.ImageID != old.ImageID {
+ continue
+ }
+ if new.QuickID != old.QuickID {
+ continue
+ }
+ new.R = old.R
+ o[i] = new
+ break
+ }
+ }
+}
+
+// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
+func (o PublicreportQuickImageSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
+ return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportQuickImages.BeforeUpdateHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportQuickImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportQuickImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportQuickImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportQuickImage or a slice of PublicreportQuickImage
+ // then run the AfterUpdateHooks on the slice
+ _, err = PublicreportQuickImages.AfterUpdateHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
+func (o PublicreportQuickImageSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
+ return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
+ q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
+ return PublicreportQuickImages.BeforeDeleteHooks.RunHooks(ctx, exec, o)
+ })
+
+ q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
+ var err error
+ switch retrieved := retrieved.(type) {
+ case *PublicreportQuickImage:
+ o.copyMatchingRows(retrieved)
+ case []*PublicreportQuickImage:
+ o.copyMatchingRows(retrieved...)
+ case PublicreportQuickImageSlice:
+ o.copyMatchingRows(retrieved...)
+ default:
+ // If the retrieved value is not a PublicreportQuickImage or a slice of PublicreportQuickImage
+ // then run the AfterDeleteHooks on the slice
+ _, err = PublicreportQuickImages.AfterDeleteHooks.RunHooks(ctx, exec, o)
+ }
+
+ return err
+ }))
+
+ q.AppendWhere(o.pkIN())
+ })
+}
+
+func (o PublicreportQuickImageSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportQuickImageSetter) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportQuickImages.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
+ return err
+}
+
+func (o PublicreportQuickImageSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ _, err := PublicreportQuickImages.Delete(o.DeleteMod()).Exec(ctx, exec)
+ return err
+}
+
+func (o PublicreportQuickImageSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
+ if len(o) == 0 {
+ return nil
+ }
+
+ o2, err := PublicreportQuickImages.Query(sm.Where(o.pkIN())).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.copyMatchingRows(o2...)
+
+ return nil
+}
+
+// Image starts a query for related objects on publicreport.image
+func (o *PublicreportQuickImage) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ return PublicreportImages.Query(append(mods,
+ sm.Where(PublicreportImages.Columns.ID.EQ(psql.Arg(o.ImageID))),
+ )...)
+}
+
+func (os PublicreportQuickImageSlice) Image(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportImagesQuery {
+ pkImageID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkImageID = append(pkImageID, o.ImageID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkImageID), "integer[]")),
+ ))
+
+ return PublicreportImages.Query(append(mods,
+ sm.Where(psql.Group(PublicreportImages.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+// Quick starts a query for related objects on publicreport.quick
+func (o *PublicreportQuickImage) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
+ return PublicreportQuicks.Query(append(mods,
+ sm.Where(PublicreportQuicks.Columns.ID.EQ(psql.Arg(o.QuickID))),
+ )...)
+}
+
+func (os PublicreportQuickImageSlice) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
+ pkQuickID := make(pgtypes.Array[int32], 0, len(os))
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+ pkQuickID = append(pkQuickID, o.QuickID)
+ }
+ PKArgExpr := psql.Select(sm.Columns(
+ psql.F("unnest", psql.Cast(psql.Arg(pkQuickID), "integer[]")),
+ ))
+
+ return PublicreportQuicks.Query(append(mods,
+ sm.Where(psql.Group(PublicreportQuicks.Columns.ID).OP("IN", PKArgExpr)),
+ )...)
+}
+
+func attachPublicreportQuickImageImage0(ctx context.Context, exec bob.Executor, count int, publicreportQuickImage0 *PublicreportQuickImage, publicreportImage1 *PublicreportImage) (*PublicreportQuickImage, error) {
+ setter := &PublicreportQuickImageSetter{
+ ImageID: omit.From(publicreportImage1.ID),
+ }
+
+ err := publicreportQuickImage0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportQuickImageImage0: %w", err)
+ }
+
+ return publicreportQuickImage0, nil
+}
+
+func (publicreportQuickImage0 *PublicreportQuickImage) InsertImage(ctx context.Context, exec bob.Executor, related *PublicreportImageSetter) error {
+ var err error
+
+ publicreportImage1, err := PublicreportImages.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachPublicreportQuickImageImage0(ctx, exec, 1, publicreportQuickImage0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportQuickImage0.R.Image = publicreportImage1
+
+ return nil
+}
+
+func (publicreportQuickImage0 *PublicreportQuickImage) AttachImage(ctx context.Context, exec bob.Executor, publicreportImage1 *PublicreportImage) error {
+ var err error
+
+ _, err = attachPublicreportQuickImageImage0(ctx, exec, 1, publicreportQuickImage0, publicreportImage1)
+ if err != nil {
+ return err
+ }
+
+ publicreportQuickImage0.R.Image = publicreportImage1
+
+ return nil
+}
+
+func attachPublicreportQuickImageQuick0(ctx context.Context, exec bob.Executor, count int, publicreportQuickImage0 *PublicreportQuickImage, publicreportQuick1 *PublicreportQuick) (*PublicreportQuickImage, error) {
+ setter := &PublicreportQuickImageSetter{
+ QuickID: omit.From(publicreportQuick1.ID),
+ }
+
+ err := publicreportQuickImage0.Update(ctx, exec, setter)
+ if err != nil {
+ return nil, fmt.Errorf("attachPublicreportQuickImageQuick0: %w", err)
+ }
+
+ return publicreportQuickImage0, nil
+}
+
+func (publicreportQuickImage0 *PublicreportQuickImage) InsertQuick(ctx context.Context, exec bob.Executor, related *PublicreportQuickSetter) error {
+ var err error
+
+ publicreportQuick1, err := PublicreportQuicks.Insert(related).One(ctx, exec)
+ if err != nil {
+ return fmt.Errorf("inserting related objects: %w", err)
+ }
+
+ _, err = attachPublicreportQuickImageQuick0(ctx, exec, 1, publicreportQuickImage0, publicreportQuick1)
+ if err != nil {
+ return err
+ }
+
+ publicreportQuickImage0.R.Quick = publicreportQuick1
+
+ return nil
+}
+
+func (publicreportQuickImage0 *PublicreportQuickImage) AttachQuick(ctx context.Context, exec bob.Executor, publicreportQuick1 *PublicreportQuick) error {
+ var err error
+
+ _, err = attachPublicreportQuickImageQuick0(ctx, exec, 1, publicreportQuickImage0, publicreportQuick1)
+ if err != nil {
+ return err
+ }
+
+ publicreportQuickImage0.R.Quick = publicreportQuick1
+
+ return nil
+}
+
+type publicreportQuickImageWhere[Q psql.Filterable] struct {
+ ImageID psql.WhereMod[Q, int32]
+ QuickID psql.WhereMod[Q, int32]
+}
+
+func (publicreportQuickImageWhere[Q]) AliasedAs(alias string) publicreportQuickImageWhere[Q] {
+ return buildPublicreportQuickImageWhere[Q](buildPublicreportQuickImageColumns(alias))
+}
+
+func buildPublicreportQuickImageWhere[Q psql.Filterable](cols publicreportQuickImageColumns) publicreportQuickImageWhere[Q] {
+ return publicreportQuickImageWhere[Q]{
+ ImageID: psql.Where[Q, int32](cols.ImageID),
+ QuickID: psql.Where[Q, int32](cols.QuickID),
+ }
+}
+
+func (o *PublicreportQuickImage) Preload(name string, retrieved any) error {
+ if o == nil {
+ return nil
+ }
+
+ switch name {
+ case "Image":
+ rel, ok := retrieved.(*PublicreportImage)
+ if !ok {
+ return fmt.Errorf("publicreportQuickImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Image = rel
+
+ return nil
+ case "Quick":
+ rel, ok := retrieved.(*PublicreportQuick)
+ if !ok {
+ return fmt.Errorf("publicreportQuickImage cannot load %T as %q", retrieved, name)
+ }
+
+ o.R.Quick = rel
+
+ return nil
+ default:
+ return fmt.Errorf("publicreportQuickImage has no relationship %q", name)
+ }
+}
+
+type publicreportQuickImagePreloader struct {
+ Image func(...psql.PreloadOption) psql.Preloader
+ Quick func(...psql.PreloadOption) psql.Preloader
+}
+
+func buildPublicreportQuickImagePreloader() publicreportQuickImagePreloader {
+ return publicreportQuickImagePreloader{
+ Image: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*PublicreportImage, PublicreportImageSlice](psql.PreloadRel{
+ Name: "Image",
+ Sides: []psql.PreloadSide{
+ {
+ From: PublicreportQuickImages,
+ To: PublicreportImages,
+ FromColumns: []string{"image_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, PublicreportImages.Columns.Names(), opts...)
+ },
+ Quick: func(opts ...psql.PreloadOption) psql.Preloader {
+ return psql.Preload[*PublicreportQuick, PublicreportQuickSlice](psql.PreloadRel{
+ Name: "Quick",
+ Sides: []psql.PreloadSide{
+ {
+ From: PublicreportQuickImages,
+ To: PublicreportQuicks,
+ FromColumns: []string{"quick_id"},
+ ToColumns: []string{"id"},
+ },
+ },
+ }, PublicreportQuicks.Columns.Names(), opts...)
+ },
+ }
+}
+
+type publicreportQuickImageThenLoader[Q orm.Loadable] struct {
+ Image func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+ Quick func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
+}
+
+func buildPublicreportQuickImageThenLoader[Q orm.Loadable]() publicreportQuickImageThenLoader[Q] {
+ type ImageLoadInterface interface {
+ LoadImage(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+ type QuickLoadInterface interface {
+ LoadQuick(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
+ }
+
+ return publicreportQuickImageThenLoader[Q]{
+ Image: thenLoadBuilder[Q](
+ "Image",
+ func(ctx context.Context, exec bob.Executor, retrieved ImageLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadImage(ctx, exec, mods...)
+ },
+ ),
+ Quick: thenLoadBuilder[Q](
+ "Quick",
+ func(ctx context.Context, exec bob.Executor, retrieved QuickLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ return retrieved.LoadQuick(ctx, exec, mods...)
+ },
+ ),
+ }
+}
+
+// LoadImage loads the publicreportQuickImage's Image into the .R struct
+func (o *PublicreportQuickImage) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Image = nil
+
+ related, err := o.Image(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R.Image = related
+ return nil
+}
+
+// LoadImage loads the publicreportQuickImage's Image into the .R struct
+func (os PublicreportQuickImageSlice) LoadImage(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportImages, err := os.Image(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportImages {
+
+ if !(o.ImageID == rel.ID) {
+ continue
+ }
+
+ o.R.Image = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+// LoadQuick loads the publicreportQuickImage's Quick into the .R struct
+func (o *PublicreportQuickImage) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if o == nil {
+ return nil
+ }
+
+ // Reset the relationship
+ o.R.Quick = nil
+
+ related, err := o.Quick(mods...).One(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ o.R.Quick = related
+ return nil
+}
+
+// LoadQuick loads the publicreportQuickImage's Quick into the .R struct
+func (os PublicreportQuickImageSlice) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
+ if len(os) == 0 {
+ return nil
+ }
+
+ publicreportQuicks, err := os.Quick(mods...).All(ctx, exec)
+ if err != nil {
+ return err
+ }
+
+ for _, o := range os {
+ if o == nil {
+ continue
+ }
+
+ for _, rel := range publicreportQuicks {
+
+ if !(o.QuickID == rel.ID) {
+ continue
+ }
+
+ o.R.Quick = rel
+ break
+ }
+ }
+
+ return nil
+}
+
+type publicreportQuickImageJoins[Q dialect.Joinable] struct {
+ typ string
+ Image modAs[Q, publicreportImageColumns]
+ Quick modAs[Q, publicreportQuickColumns]
+}
+
+func (j publicreportQuickImageJoins[Q]) aliasedAs(alias string) publicreportQuickImageJoins[Q] {
+ return buildPublicreportQuickImageJoins[Q](buildPublicreportQuickImageColumns(alias), j.typ)
+}
+
+func buildPublicreportQuickImageJoins[Q dialect.Joinable](cols publicreportQuickImageColumns, typ string) publicreportQuickImageJoins[Q] {
+ return publicreportQuickImageJoins[Q]{
+ typ: typ,
+ Image: modAs[Q, publicreportImageColumns]{
+ c: PublicreportImages.Columns,
+ f: func(to publicreportImageColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportImages.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.ImageID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ Quick: modAs[Q, publicreportQuickColumns]{
+ c: PublicreportQuicks.Columns,
+ f: func(to publicreportQuickColumns) bob.Mod[Q] {
+ mods := make(mods.QueryMods[Q], 0, 1)
+
+ {
+ mods = append(mods, dialect.Join[Q](typ, PublicreportQuicks.Name().As(to.Alias())).On(
+ to.ID.EQ(cols.QuickID),
+ ))
+ }
+
+ return mods
+ },
+ },
+ }
+}
diff --git a/db/models/publicreport.quick_photo.bob.go b/db/models/publicreport.quick_photo.bob.go
deleted file mode 100644
index 9f5171d4..00000000
--- a/db/models/publicreport.quick_photo.bob.go
+++ /dev/null
@@ -1,678 +0,0 @@
-// Code generated by BobGen psql v0.42.1. DO NOT EDIT.
-// This file is meant to be re-generated in place and/or deleted at any time.
-
-package models
-
-import (
- "context"
- "fmt"
- "io"
-
- "github.com/aarondl/opt/omit"
- "github.com/google/uuid"
- "github.com/stephenafamo/bob"
- "github.com/stephenafamo/bob/dialect/psql"
- "github.com/stephenafamo/bob/dialect/psql/dialect"
- "github.com/stephenafamo/bob/dialect/psql/dm"
- "github.com/stephenafamo/bob/dialect/psql/sm"
- "github.com/stephenafamo/bob/dialect/psql/um"
- "github.com/stephenafamo/bob/expr"
- "github.com/stephenafamo/bob/mods"
- "github.com/stephenafamo/bob/orm"
- "github.com/stephenafamo/bob/types/pgtypes"
-)
-
-// PublicreportQuickPhoto is an object representing the database table.
-type PublicreportQuickPhoto struct {
- ID int32 `db:"id,pk" `
- Size int64 `db:"size" `
- Filename string `db:"filename" `
- QuickID int32 `db:"quick_id" `
- UUID uuid.UUID `db:"uuid" `
-
- R publicreportQuickPhotoR `db:"-" `
-}
-
-// PublicreportQuickPhotoSlice is an alias for a slice of pointers to PublicreportQuickPhoto.
-// This should almost always be used instead of []*PublicreportQuickPhoto.
-type PublicreportQuickPhotoSlice []*PublicreportQuickPhoto
-
-// PublicreportQuickPhotos contains methods to work with the quick_photo table
-var PublicreportQuickPhotos = psql.NewTablex[*PublicreportQuickPhoto, PublicreportQuickPhotoSlice, *PublicreportQuickPhotoSetter]("publicreport", "quick_photo", buildPublicreportQuickPhotoColumns("publicreport.quick_photo"))
-
-// PublicreportQuickPhotosQuery is a query on the quick_photo table
-type PublicreportQuickPhotosQuery = *psql.ViewQuery[*PublicreportQuickPhoto, PublicreportQuickPhotoSlice]
-
-// publicreportQuickPhotoR is where relationships are stored.
-type publicreportQuickPhotoR struct {
- Quick *PublicreportQuick // publicreport.quick_photo.quick_photo_quick_id_fkey
-}
-
-func buildPublicreportQuickPhotoColumns(alias string) publicreportQuickPhotoColumns {
- return publicreportQuickPhotoColumns{
- ColumnsExpr: expr.NewColumnsExpr(
- "id", "size", "filename", "quick_id", "uuid",
- ).WithParent("publicreport.quick_photo"),
- tableAlias: alias,
- ID: psql.Quote(alias, "id"),
- Size: psql.Quote(alias, "size"),
- Filename: psql.Quote(alias, "filename"),
- QuickID: psql.Quote(alias, "quick_id"),
- UUID: psql.Quote(alias, "uuid"),
- }
-}
-
-type publicreportQuickPhotoColumns struct {
- expr.ColumnsExpr
- tableAlias string
- ID psql.Expression
- Size psql.Expression
- Filename psql.Expression
- QuickID psql.Expression
- UUID psql.Expression
-}
-
-func (c publicreportQuickPhotoColumns) Alias() string {
- return c.tableAlias
-}
-
-func (publicreportQuickPhotoColumns) AliasedAs(alias string) publicreportQuickPhotoColumns {
- return buildPublicreportQuickPhotoColumns(alias)
-}
-
-// PublicreportQuickPhotoSetter is used for insert/upsert/update operations
-// All values are optional, and do not have to be set
-// Generated columns are not included
-type PublicreportQuickPhotoSetter struct {
- ID omit.Val[int32] `db:"id,pk" `
- Size omit.Val[int64] `db:"size" `
- Filename omit.Val[string] `db:"filename" `
- QuickID omit.Val[int32] `db:"quick_id" `
- UUID omit.Val[uuid.UUID] `db:"uuid" `
-}
-
-func (s PublicreportQuickPhotoSetter) SetColumns() []string {
- vals := make([]string, 0, 5)
- if s.ID.IsValue() {
- vals = append(vals, "id")
- }
- if s.Size.IsValue() {
- vals = append(vals, "size")
- }
- if s.Filename.IsValue() {
- vals = append(vals, "filename")
- }
- if s.QuickID.IsValue() {
- vals = append(vals, "quick_id")
- }
- if s.UUID.IsValue() {
- vals = append(vals, "uuid")
- }
- return vals
-}
-
-func (s PublicreportQuickPhotoSetter) Overwrite(t *PublicreportQuickPhoto) {
- if s.ID.IsValue() {
- t.ID = s.ID.MustGet()
- }
- if s.Size.IsValue() {
- t.Size = s.Size.MustGet()
- }
- if s.Filename.IsValue() {
- t.Filename = s.Filename.MustGet()
- }
- if s.QuickID.IsValue() {
- t.QuickID = s.QuickID.MustGet()
- }
- if s.UUID.IsValue() {
- t.UUID = s.UUID.MustGet()
- }
-}
-
-func (s *PublicreportQuickPhotoSetter) Apply(q *dialect.InsertQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportQuickPhotos.BeforeInsertHooks.RunHooks(ctx, exec, s)
- })
-
- q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- vals := make([]bob.Expression, 5)
- if s.ID.IsValue() {
- vals[0] = psql.Arg(s.ID.MustGet())
- } else {
- vals[0] = psql.Raw("DEFAULT")
- }
-
- if s.Size.IsValue() {
- vals[1] = psql.Arg(s.Size.MustGet())
- } else {
- vals[1] = psql.Raw("DEFAULT")
- }
-
- if s.Filename.IsValue() {
- vals[2] = psql.Arg(s.Filename.MustGet())
- } else {
- vals[2] = psql.Raw("DEFAULT")
- }
-
- if s.QuickID.IsValue() {
- vals[3] = psql.Arg(s.QuickID.MustGet())
- } else {
- vals[3] = psql.Raw("DEFAULT")
- }
-
- if s.UUID.IsValue() {
- vals[4] = psql.Arg(s.UUID.MustGet())
- } else {
- vals[4] = psql.Raw("DEFAULT")
- }
-
- return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
- }))
-}
-
-func (s PublicreportQuickPhotoSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
- return um.Set(s.Expressions()...)
-}
-
-func (s PublicreportQuickPhotoSetter) Expressions(prefix ...string) []bob.Expression {
- exprs := make([]bob.Expression, 0, 5)
-
- if s.ID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "id")...),
- psql.Arg(s.ID),
- }})
- }
-
- if s.Size.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "size")...),
- psql.Arg(s.Size),
- }})
- }
-
- if s.Filename.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "filename")...),
- psql.Arg(s.Filename),
- }})
- }
-
- if s.QuickID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "quick_id")...),
- psql.Arg(s.QuickID),
- }})
- }
-
- if s.UUID.IsValue() {
- exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
- psql.Quote(append(prefix, "uuid")...),
- psql.Arg(s.UUID),
- }})
- }
-
- return exprs
-}
-
-// FindPublicreportQuickPhoto retrieves a single record by primary key
-// If cols is empty Find will return all columns.
-func FindPublicreportQuickPhoto(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*PublicreportQuickPhoto, error) {
- if len(cols) == 0 {
- return PublicreportQuickPhotos.Query(
- sm.Where(PublicreportQuickPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- ).One(ctx, exec)
- }
-
- return PublicreportQuickPhotos.Query(
- sm.Where(PublicreportQuickPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- sm.Columns(PublicreportQuickPhotos.Columns.Only(cols...)),
- ).One(ctx, exec)
-}
-
-// PublicreportQuickPhotoExists checks the presence of a single record by primary key
-func PublicreportQuickPhotoExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
- return PublicreportQuickPhotos.Query(
- sm.Where(PublicreportQuickPhotos.Columns.ID.EQ(psql.Arg(IDPK))),
- ).Exists(ctx, exec)
-}
-
-// AfterQueryHook is called after PublicreportQuickPhoto is retrieved from the database
-func (o *PublicreportQuickPhoto) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
- var err error
-
- switch queryType {
- case bob.QueryTypeSelect:
- ctx, err = PublicreportQuickPhotos.AfterSelectHooks.RunHooks(ctx, exec, PublicreportQuickPhotoSlice{o})
- case bob.QueryTypeInsert:
- ctx, err = PublicreportQuickPhotos.AfterInsertHooks.RunHooks(ctx, exec, PublicreportQuickPhotoSlice{o})
- case bob.QueryTypeUpdate:
- ctx, err = PublicreportQuickPhotos.AfterUpdateHooks.RunHooks(ctx, exec, PublicreportQuickPhotoSlice{o})
- case bob.QueryTypeDelete:
- ctx, err = PublicreportQuickPhotos.AfterDeleteHooks.RunHooks(ctx, exec, PublicreportQuickPhotoSlice{o})
- }
-
- return err
-}
-
-// primaryKeyVals returns the primary key values of the PublicreportQuickPhoto
-func (o *PublicreportQuickPhoto) primaryKeyVals() bob.Expression {
- return psql.Arg(o.ID)
-}
-
-func (o *PublicreportQuickPhoto) pkEQ() dialect.Expression {
- return psql.Quote("publicreport.quick_photo", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
- }))
-}
-
-// Update uses an executor to update the PublicreportQuickPhoto
-func (o *PublicreportQuickPhoto) Update(ctx context.Context, exec bob.Executor, s *PublicreportQuickPhotoSetter) error {
- v, err := PublicreportQuickPhotos.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
- if err != nil {
- return err
- }
-
- o.R = v.R
- *o = *v
-
- return nil
-}
-
-// Delete deletes a single PublicreportQuickPhoto record with an executor
-func (o *PublicreportQuickPhoto) Delete(ctx context.Context, exec bob.Executor) error {
- _, err := PublicreportQuickPhotos.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
- return err
-}
-
-// Reload refreshes the PublicreportQuickPhoto using the executor
-func (o *PublicreportQuickPhoto) Reload(ctx context.Context, exec bob.Executor) error {
- o2, err := PublicreportQuickPhotos.Query(
- sm.Where(PublicreportQuickPhotos.Columns.ID.EQ(psql.Arg(o.ID))),
- ).One(ctx, exec)
- if err != nil {
- return err
- }
- o2.R = o.R
- *o = *o2
-
- return nil
-}
-
-// AfterQueryHook is called after PublicreportQuickPhotoSlice is retrieved from the database
-func (o PublicreportQuickPhotoSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
- var err error
-
- switch queryType {
- case bob.QueryTypeSelect:
- ctx, err = PublicreportQuickPhotos.AfterSelectHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeInsert:
- ctx, err = PublicreportQuickPhotos.AfterInsertHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeUpdate:
- ctx, err = PublicreportQuickPhotos.AfterUpdateHooks.RunHooks(ctx, exec, o)
- case bob.QueryTypeDelete:
- ctx, err = PublicreportQuickPhotos.AfterDeleteHooks.RunHooks(ctx, exec, o)
- }
-
- return err
-}
-
-func (o PublicreportQuickPhotoSlice) pkIN() dialect.Expression {
- if len(o) == 0 {
- return psql.Raw("NULL")
- }
-
- return psql.Quote("publicreport.quick_photo", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
- pkPairs := make([]bob.Expression, len(o))
- for i, row := range o {
- pkPairs[i] = row.primaryKeyVals()
- }
- return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
- }))
-}
-
-// copyMatchingRows finds models in the given slice that have the same primary key
-// then it first copies the existing relationships from the old model to the new model
-// and then replaces the old model in the slice with the new model
-func (o PublicreportQuickPhotoSlice) copyMatchingRows(from ...*PublicreportQuickPhoto) {
- for i, old := range o {
- for _, new := range from {
- if new.ID != old.ID {
- continue
- }
- new.R = old.R
- o[i] = new
- break
- }
- }
-}
-
-// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
-func (o PublicreportQuickPhotoSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
- return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportQuickPhotos.BeforeUpdateHooks.RunHooks(ctx, exec, o)
- })
-
- q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
- var err error
- switch retrieved := retrieved.(type) {
- case *PublicreportQuickPhoto:
- o.copyMatchingRows(retrieved)
- case []*PublicreportQuickPhoto:
- o.copyMatchingRows(retrieved...)
- case PublicreportQuickPhotoSlice:
- o.copyMatchingRows(retrieved...)
- default:
- // If the retrieved value is not a PublicreportQuickPhoto or a slice of PublicreportQuickPhoto
- // then run the AfterUpdateHooks on the slice
- _, err = PublicreportQuickPhotos.AfterUpdateHooks.RunHooks(ctx, exec, o)
- }
-
- return err
- }))
-
- q.AppendWhere(o.pkIN())
- })
-}
-
-// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
-func (o PublicreportQuickPhotoSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
- return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
- q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
- return PublicreportQuickPhotos.BeforeDeleteHooks.RunHooks(ctx, exec, o)
- })
-
- q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
- var err error
- switch retrieved := retrieved.(type) {
- case *PublicreportQuickPhoto:
- o.copyMatchingRows(retrieved)
- case []*PublicreportQuickPhoto:
- o.copyMatchingRows(retrieved...)
- case PublicreportQuickPhotoSlice:
- o.copyMatchingRows(retrieved...)
- default:
- // If the retrieved value is not a PublicreportQuickPhoto or a slice of PublicreportQuickPhoto
- // then run the AfterDeleteHooks on the slice
- _, err = PublicreportQuickPhotos.AfterDeleteHooks.RunHooks(ctx, exec, o)
- }
-
- return err
- }))
-
- q.AppendWhere(o.pkIN())
- })
-}
-
-func (o PublicreportQuickPhotoSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals PublicreportQuickPhotoSetter) error {
- if len(o) == 0 {
- return nil
- }
-
- _, err := PublicreportQuickPhotos.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
- return err
-}
-
-func (o PublicreportQuickPhotoSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
- if len(o) == 0 {
- return nil
- }
-
- _, err := PublicreportQuickPhotos.Delete(o.DeleteMod()).Exec(ctx, exec)
- return err
-}
-
-func (o PublicreportQuickPhotoSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
- if len(o) == 0 {
- return nil
- }
-
- o2, err := PublicreportQuickPhotos.Query(sm.Where(o.pkIN())).All(ctx, exec)
- if err != nil {
- return err
- }
-
- o.copyMatchingRows(o2...)
-
- return nil
-}
-
-// Quick starts a query for related objects on publicreport.quick
-func (o *PublicreportQuickPhoto) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
- return PublicreportQuicks.Query(append(mods,
- sm.Where(PublicreportQuicks.Columns.ID.EQ(psql.Arg(o.QuickID))),
- )...)
-}
-
-func (os PublicreportQuickPhotoSlice) Quick(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportQuicksQuery {
- pkQuickID := make(pgtypes.Array[int32], 0, len(os))
- for _, o := range os {
- if o == nil {
- continue
- }
- pkQuickID = append(pkQuickID, o.QuickID)
- }
- PKArgExpr := psql.Select(sm.Columns(
- psql.F("unnest", psql.Cast(psql.Arg(pkQuickID), "integer[]")),
- ))
-
- return PublicreportQuicks.Query(append(mods,
- sm.Where(psql.Group(PublicreportQuicks.Columns.ID).OP("IN", PKArgExpr)),
- )...)
-}
-
-func attachPublicreportQuickPhotoQuick0(ctx context.Context, exec bob.Executor, count int, publicreportQuickPhoto0 *PublicreportQuickPhoto, publicreportQuick1 *PublicreportQuick) (*PublicreportQuickPhoto, error) {
- setter := &PublicreportQuickPhotoSetter{
- QuickID: omit.From(publicreportQuick1.ID),
- }
-
- err := publicreportQuickPhoto0.Update(ctx, exec, setter)
- if err != nil {
- return nil, fmt.Errorf("attachPublicreportQuickPhotoQuick0: %w", err)
- }
-
- return publicreportQuickPhoto0, nil
-}
-
-func (publicreportQuickPhoto0 *PublicreportQuickPhoto) InsertQuick(ctx context.Context, exec bob.Executor, related *PublicreportQuickSetter) error {
- var err error
-
- publicreportQuick1, err := PublicreportQuicks.Insert(related).One(ctx, exec)
- if err != nil {
- return fmt.Errorf("inserting related objects: %w", err)
- }
-
- _, err = attachPublicreportQuickPhotoQuick0(ctx, exec, 1, publicreportQuickPhoto0, publicreportQuick1)
- if err != nil {
- return err
- }
-
- publicreportQuickPhoto0.R.Quick = publicreportQuick1
-
- publicreportQuick1.R.QuickPhotos = append(publicreportQuick1.R.QuickPhotos, publicreportQuickPhoto0)
-
- return nil
-}
-
-func (publicreportQuickPhoto0 *PublicreportQuickPhoto) AttachQuick(ctx context.Context, exec bob.Executor, publicreportQuick1 *PublicreportQuick) error {
- var err error
-
- _, err = attachPublicreportQuickPhotoQuick0(ctx, exec, 1, publicreportQuickPhoto0, publicreportQuick1)
- if err != nil {
- return err
- }
-
- publicreportQuickPhoto0.R.Quick = publicreportQuick1
-
- publicreportQuick1.R.QuickPhotos = append(publicreportQuick1.R.QuickPhotos, publicreportQuickPhoto0)
-
- return nil
-}
-
-type publicreportQuickPhotoWhere[Q psql.Filterable] struct {
- ID psql.WhereMod[Q, int32]
- Size psql.WhereMod[Q, int64]
- Filename psql.WhereMod[Q, string]
- QuickID psql.WhereMod[Q, int32]
- UUID psql.WhereMod[Q, uuid.UUID]
-}
-
-func (publicreportQuickPhotoWhere[Q]) AliasedAs(alias string) publicreportQuickPhotoWhere[Q] {
- return buildPublicreportQuickPhotoWhere[Q](buildPublicreportQuickPhotoColumns(alias))
-}
-
-func buildPublicreportQuickPhotoWhere[Q psql.Filterable](cols publicreportQuickPhotoColumns) publicreportQuickPhotoWhere[Q] {
- return publicreportQuickPhotoWhere[Q]{
- ID: psql.Where[Q, int32](cols.ID),
- Size: psql.Where[Q, int64](cols.Size),
- Filename: psql.Where[Q, string](cols.Filename),
- QuickID: psql.Where[Q, int32](cols.QuickID),
- UUID: psql.Where[Q, uuid.UUID](cols.UUID),
- }
-}
-
-func (o *PublicreportQuickPhoto) Preload(name string, retrieved any) error {
- if o == nil {
- return nil
- }
-
- switch name {
- case "Quick":
- rel, ok := retrieved.(*PublicreportQuick)
- if !ok {
- return fmt.Errorf("publicreportQuickPhoto cannot load %T as %q", retrieved, name)
- }
-
- o.R.Quick = rel
-
- if rel != nil {
- rel.R.QuickPhotos = PublicreportQuickPhotoSlice{o}
- }
- return nil
- default:
- return fmt.Errorf("publicreportQuickPhoto has no relationship %q", name)
- }
-}
-
-type publicreportQuickPhotoPreloader struct {
- Quick func(...psql.PreloadOption) psql.Preloader
-}
-
-func buildPublicreportQuickPhotoPreloader() publicreportQuickPhotoPreloader {
- return publicreportQuickPhotoPreloader{
- Quick: func(opts ...psql.PreloadOption) psql.Preloader {
- return psql.Preload[*PublicreportQuick, PublicreportQuickSlice](psql.PreloadRel{
- Name: "Quick",
- Sides: []psql.PreloadSide{
- {
- From: PublicreportQuickPhotos,
- To: PublicreportQuicks,
- FromColumns: []string{"quick_id"},
- ToColumns: []string{"id"},
- },
- },
- }, PublicreportQuicks.Columns.Names(), opts...)
- },
- }
-}
-
-type publicreportQuickPhotoThenLoader[Q orm.Loadable] struct {
- Quick func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
-}
-
-func buildPublicreportQuickPhotoThenLoader[Q orm.Loadable]() publicreportQuickPhotoThenLoader[Q] {
- type QuickLoadInterface interface {
- LoadQuick(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
- }
-
- return publicreportQuickPhotoThenLoader[Q]{
- Quick: thenLoadBuilder[Q](
- "Quick",
- func(ctx context.Context, exec bob.Executor, retrieved QuickLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
- return retrieved.LoadQuick(ctx, exec, mods...)
- },
- ),
- }
-}
-
-// LoadQuick loads the publicreportQuickPhoto's Quick into the .R struct
-func (o *PublicreportQuickPhoto) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
- if o == nil {
- return nil
- }
-
- // Reset the relationship
- o.R.Quick = nil
-
- related, err := o.Quick(mods...).One(ctx, exec)
- if err != nil {
- return err
- }
-
- related.R.QuickPhotos = PublicreportQuickPhotoSlice{o}
-
- o.R.Quick = related
- return nil
-}
-
-// LoadQuick loads the publicreportQuickPhoto's Quick into the .R struct
-func (os PublicreportQuickPhotoSlice) LoadQuick(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
- if len(os) == 0 {
- return nil
- }
-
- publicreportQuicks, err := os.Quick(mods...).All(ctx, exec)
- if err != nil {
- return err
- }
-
- for _, o := range os {
- if o == nil {
- continue
- }
-
- for _, rel := range publicreportQuicks {
-
- if !(o.QuickID == rel.ID) {
- continue
- }
-
- rel.R.QuickPhotos = append(rel.R.QuickPhotos, o)
-
- o.R.Quick = rel
- break
- }
- }
-
- return nil
-}
-
-type publicreportQuickPhotoJoins[Q dialect.Joinable] struct {
- typ string
- Quick modAs[Q, publicreportQuickColumns]
-}
-
-func (j publicreportQuickPhotoJoins[Q]) aliasedAs(alias string) publicreportQuickPhotoJoins[Q] {
- return buildPublicreportQuickPhotoJoins[Q](buildPublicreportQuickPhotoColumns(alias), j.typ)
-}
-
-func buildPublicreportQuickPhotoJoins[Q dialect.Joinable](cols publicreportQuickPhotoColumns, typ string) publicreportQuickPhotoJoins[Q] {
- return publicreportQuickPhotoJoins[Q]{
- typ: typ,
- Quick: modAs[Q, publicreportQuickColumns]{
- c: PublicreportQuicks.Columns,
- f: func(to publicreportQuickColumns) bob.Mod[Q] {
- mods := make(mods.QueryMods[Q], 0, 1)
-
- {
- mods = append(mods, dialect.Join[Q](typ, PublicreportQuicks.Name().As(to.Alias())).On(
- to.ID.EQ(cols.QuickID),
- ))
- }
-
- return mods
- },
- },
- }
-}
diff --git a/go.mod b/go.mod
index 85d2a31f..ef56dc10 100644
--- a/go.mod
+++ b/go.mod
@@ -33,8 +33,17 @@ require (
require (
github.com/ajg/form v1.5.1 // indirect
+ github.com/dsoprea/go-exif/v3 v3.0.1 // indirect
+ github.com/dsoprea/go-iptc v0.0.0-20200609062250-162ae6b44feb // indirect
+ github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20221012074422-4f3f7e934102 // indirect
+ github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
+ github.com/dsoprea/go-photoshop-info-format v0.0.0-20200609050348-3db9b63b202c // indirect
+ github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
+ github.com/go-errors/errors v1.4.2 // indirect
github.com/go-ini/ini v1.67.0 // indirect
+ github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
+ github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
@@ -67,5 +76,6 @@ require (
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index 2b5f8289..c6543560 100644
--- a/go.sum
+++ b/go.sum
@@ -43,6 +43,31 @@ github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
+github.com/dsoprea/go-exif/v2 v2.0.0-20200321225314-640175a69fe4/go.mod h1:Lm2lMM2zx8p4a34ZemkaUV95AnMl4ZvLbCUbwOvLC2E=
+github.com/dsoprea/go-exif/v3 v3.0.0-20200717053412-08f1b6708903/go.mod h1:0nsO1ce0mh5czxGeLo4+OCZ/C6Eo6ZlMWsz7rH/Gxv8=
+github.com/dsoprea/go-exif/v3 v3.0.0-20210428042052-dca55bf8ca15/go.mod h1:cg5SNYKHMmzxsr9X6ZeLh/nfBRHHp5PngtEPcujONtk=
+github.com/dsoprea/go-exif/v3 v3.0.0-20210625224831-a6301f85c82b/go.mod h1:cg5SNYKHMmzxsr9X6ZeLh/nfBRHHp5PngtEPcujONtk=
+github.com/dsoprea/go-exif/v3 v3.0.0-20221003160559-cf5cd88aa559/go.mod h1:rW6DMEv25U9zCtE5ukC7ttBRllXj7g7TAHl7tQrT5No=
+github.com/dsoprea/go-exif/v3 v3.0.0-20221003171958-de6cb6e380a8/go.mod h1:akyZEJZ/k5bmbC9gA612ZLQkcED8enS9vuTiuAkENr0=
+github.com/dsoprea/go-exif/v3 v3.0.1 h1:/IE4iW7gvY7BablV1XY0unqhMv26EYpOquVMwoBo/wc=
+github.com/dsoprea/go-exif/v3 v3.0.1/go.mod h1:10HkA1Wz3h398cDP66L+Is9kKDmlqlIJGPv8pk4EWvc=
+github.com/dsoprea/go-iptc v0.0.0-20200609062250-162ae6b44feb h1:gwjJjUr6FY7zAWVEueFPrcRHhd9+IK81TcItbqw2du4=
+github.com/dsoprea/go-iptc v0.0.0-20200609062250-162ae6b44feb/go.mod h1:kYIdx9N9NaOyD7U6D+YtExN7QhRm+5kq7//yOsRXQtM=
+github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20221012074422-4f3f7e934102 h1:gmTXQdSuuuORRFPTS2uaYpAXU5oUNkXdeYSlZe5NvsE=
+github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20221012074422-4f3f7e934102/go.mod h1:WaARaUjQuSuDCDFAiU/GwzfxMTJBulfEhqEA2Tx6B4Y=
+github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696/go.mod h1:Nm/x2ZUNRW6Fe5C3LxdY1PyZY5wmDv/s5dkPJ/VB3iA=
+github.com/dsoprea/go-logging v0.0.0-20200517223158-a10564966e9d/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
+github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd h1:l+vLbuxptsC6VQyQsfD7NnEC8BZuFpz45PgY+pH8YTg=
+github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
+github.com/dsoprea/go-photoshop-info-format v0.0.0-20200609050348-3db9b63b202c h1:7j5aWACOzROpr+dvMtu8GnI97g9ShLWD72XIELMgn+c=
+github.com/dsoprea/go-photoshop-info-format v0.0.0-20200609050348-3db9b63b202c/go.mod h1:pqKB+ijp27cEcrHxhXVgUUMlSDRuGJJp1E+20Lj5H0E=
+github.com/dsoprea/go-utility v0.0.0-20200711062821-fab8125e9bdf h1:/w4QxepU4AHh3AuO6/g8y/YIIHH5+aKP3Bj8sg5cqhU=
+github.com/dsoprea/go-utility v0.0.0-20200711062821-fab8125e9bdf/go.mod h1:95+K3z2L0mqsVYd6yveIv1lmtT3tcQQ3dVakPySffW8=
+github.com/dsoprea/go-utility/v2 v2.0.0-20200717064901-2fccff4aa15e/go.mod h1:uAzdkPTub5Y9yQwXe8W4m2XuP0tK4a9Q/dantD0+uaU=
+github.com/dsoprea/go-utility/v2 v2.0.0-20221003142440-7a1927d49d9d/go.mod h1:LVjRU0RNUuMDqkPTxcALio0LWPFPXxxFCvVGVAwEpFc=
+github.com/dsoprea/go-utility/v2 v2.0.0-20221003160719-7bc88537c05e/go.mod h1:VZ7cB0pTjm1ADBWhJUOHESu4ZYy9JN+ZPqjfiW09EPU=
+github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje0z+3UQ5YjYiSRRzVdtamFpvBQXKwMglWqw=
+github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
@@ -56,6 +81,11 @@ github.com/go-chi/hostrouter v0.3.0 h1:75it1eO3FvkG8te1CvU6Kvr3WzAZNEBbo8xIrxUKL
github.com/go-chi/hostrouter v0.3.0/go.mod h1:KLB+7PH/ceOr6FCmMyWD2Dmql/clpOe+y7I7CUeTkaQ=
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
+github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
+github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
+github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
+github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
+github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -64,11 +94,17 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
+github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4/FHQWkvVRmgijNXRfzkIDHh23ggEo=
+github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
+github.com/golang/geo v0.0.0-20200319012246-673a6f80352d/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
+github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
+github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
@@ -88,6 +124,8 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jaswdr/faker/v2 v2.8.1 h1:2AcPgHDBXYQregFUH9LgVZKfFupc4SIquYhp29sf5wQ=
github.com/jaswdr/faker/v2 v2.8.1/go.mod h1:jZq+qzNQr8/P+5fHd9t3txe2GNPnthrTfohtnJ7B+68=
+github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
@@ -247,6 +285,7 @@ go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXe
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
@@ -255,9 +294,16 @@ golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/y
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
@@ -268,11 +314,16 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -309,6 +360,10 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/public-report/image-upload.go b/public-report/image-upload.go
new file mode 100644
index 00000000..ea40a0cd
--- /dev/null
+++ b/public-report/image-upload.go
@@ -0,0 +1,182 @@
+package publicreport
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "image"
+ _ "image/gif" // register GIF format
+ _ "image/jpeg" // register JPEG format
+ _ "image/png" // register PNG format
+ "io"
+ "mime/multipart"
+ "net/http"
+ "time"
+
+ "github.com/aarondl/opt/omit"
+ "github.com/dsoprea/go-exif/v3"
+ exifcommon "github.com/dsoprea/go-exif/v3/common"
+ //"github.com/dsoprea/go-jpeg-image-structure/v2"
+ "github.com/Gleipnir-Technology/nidus-sync/db/models"
+ "github.com/Gleipnir-Technology/nidus-sync/userfile"
+ "github.com/google/uuid"
+ "github.com/rs/zerolog/log"
+ "github.com/stephenafamo/bob"
+ "github.com/stephenafamo/bob/dialect/psql"
+ "github.com/stephenafamo/bob/dialect/psql/um"
+)
+
+type ExifCollection struct {
+ GPS *exif.GpsInfo
+ Tags map[string]string
+}
+
+type ImageUpload struct {
+ Bounds image.Rectangle
+ ContentType string
+ Exif ExifCollection
+ Format string
+
+ UploadFilesize int
+ UploadFilename string
+ UUID uuid.UUID
+}
+
+func extractExif(file_bytes []byte) (result ExifCollection, err error) {
+
+ raw_exif, err := exif.SearchAndExtractExifWithReader(bytes.NewReader(file_bytes))
+ if err != nil {
+ return result, fmt.Errorf("Failed to find exif: %w", err)
+ }
+ im, err := exifcommon.NewIfdMappingWithStandard()
+ if err != nil {
+ return result, fmt.Errorf("Failed to create new idf mapping: %w", err)
+ }
+ ti := exif.NewTagIndex()
+ _, index, err := exif.Collect(im, ti, raw_exif)
+ if err != nil {
+ return result, fmt.Errorf("Failed to collect exif: %w", err)
+ }
+ ifd, err := index.RootIfd.ChildWithIfdPath(exifcommon.IfdGpsInfoStandardIfdIdentity)
+ if err != nil {
+ return result, fmt.Errorf("Failed to find gps exif: %w", err)
+ }
+ gi, err := ifd.GpsInfo()
+ if err != nil {
+ log.Info().Err(err).Msg("Failed to get GPS info for uploaded image")
+ result.GPS = nil
+ } else {
+ result.GPS = gi
+ }
+ result.Tags = make(map[string]string, 0)
+
+ tags, _, err := exif.GetFlatExifData(raw_exif, &exif.ScanOptions{})
+ if err != nil {
+ return result, fmt.Errorf("Failed to gather flat exif: %w", err)
+ }
+ for _, t := range tags {
+ result.Tags[t.TagName] = t.Formatted
+ }
+ log.Info().Str("GPS", fmt.Sprintf("%s", gi)).Int("count", len(result.Tags)).Msg("Extracted exif tags")
+ return result, nil
+}
+
+func extractImageUpload(headers *multipart.FileHeader) (upload ImageUpload, err error) {
+ file, err := headers.Open()
+ if err != nil {
+ return upload, fmt.Errorf("Failed to open header: %w", err)
+ }
+ defer file.Close()
+
+ file_bytes, err := io.ReadAll(file)
+ content_type := http.DetectContentType(file_bytes)
+
+ exif, err := extractExif(file_bytes)
+ if err != nil {
+ //return upload, fmt.Errorf("Failed to extract EXIF data: %w", err)
+ log.Warn().Err(err).Msg("Failed to extract EXIF data")
+ }
+
+ i, format, err := image.Decode(bytes.NewReader(file_bytes))
+ if err != nil {
+ return upload, fmt.Errorf("Failed to decode image file: %w", err)
+ }
+
+ u, err := uuid.NewUUID()
+ if err != nil {
+ return upload, fmt.Errorf("Failed to create quick report photo uuid", err)
+ }
+ err = userfile.PublicImageFileContentWrite(u, bytes.NewReader(file_bytes))
+ if err != nil {
+ return upload, fmt.Errorf("Failed to write image file to disk: %w", err)
+ }
+ log.Info().Int("size", len(file_bytes)).Str("uploaded_filename", headers.Filename).Str("content-type", content_type).Str("uuid", u.String()).Msg("Saved an uploaded file to disk")
+ return ImageUpload{
+ Bounds: i.Bounds(),
+ ContentType: content_type,
+ Exif: exif,
+ Format: format,
+ UploadFilename: headers.Filename,
+ UploadFilesize: len(file_bytes),
+ UUID: u,
+ }, nil
+}
+
+func extractImageUploads(r *http.Request) (uploads []ImageUpload, err error) {
+ uploads = make([]ImageUpload, 0)
+ for _, fheaders := range r.MultipartForm.File {
+ for _, headers := range fheaders {
+ upload, err := extractImageUpload(headers)
+ if err != nil {
+ return make([]ImageUpload, 0), fmt.Errorf("Failed to extract photo upload: %w", err)
+ }
+ uploads = append(uploads, upload)
+ }
+ }
+ return uploads, nil
+}
+
+func saveImageUploads(ctx context.Context, tx bob.Tx, uploads []ImageUpload) (models.PublicreportImageSlice, error) {
+ images := make(models.PublicreportImageSlice, 0)
+ for _, u := range uploads {
+ image, err := models.PublicreportImages.Insert(&models.PublicreportImageSetter{
+ ContentType: omit.From(u.ContentType),
+
+ Created: omit.From(time.Now()),
+ //Location: omitnull.From(nil),
+ ResolutionX: omit.From(int32(u.Bounds.Max.X)),
+ ResolutionY: omit.From(int32(u.Bounds.Max.Y)),
+ StorageUUID: omit.From(u.UUID),
+ StorageSize: omit.From(int64(u.UploadFilesize)),
+ UploadedFilename: omit.From(u.UploadFilename),
+ }).One(ctx, tx)
+ if err != nil {
+ return images, fmt.Errorf("Failed to create photo records: %w", err)
+ }
+
+ // TODO: figure out how to do this via the setter...?
+ if u.Exif.GPS != nil {
+ _, err = psql.Update(
+ um.Table("publicreport.image"),
+ um.SetCol("location").To(fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", u.Exif.GPS.Longitude.Decimal(), u.Exif.GPS.Latitude.Decimal())),
+ um.Where(psql.Quote("id").EQ(psql.Arg(image.ID))),
+ ).Exec(ctx, tx)
+ }
+
+ exif_setters := make([]*models.PublicreportImageExifSetter, 0)
+ for k, v := range u.Exif.Tags {
+ exif_setters = append(exif_setters, &models.PublicreportImageExifSetter{
+ ImageID: omit.From(image.ID),
+ Name: omit.From(k),
+ Value: omit.From(v),
+ })
+ }
+ _, err = models.PublicreportImageExifs.Insert(bob.ToMods(exif_setters...)).Exec(ctx, tx)
+ if err != nil {
+ return images, fmt.Errorf("Failed to create photo exif records: %w", err)
+ }
+ images = append(images, image)
+ log.Info().Int32("id", image.ID).Int("tags", len(u.Exif.Tags)).Msg("Saved an uploaded file to the database")
+ }
+ return images, nil
+}
diff --git a/public-report/photo-upload.go b/public-report/photo-upload.go
deleted file mode 100644
index 6d40946f..00000000
--- a/public-report/photo-upload.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package publicreport
-
-import (
- "bytes"
- "fmt"
- "net/http"
-
- "github.com/Gleipnir-Technology/nidus-sync/userfile"
- "github.com/google/uuid"
- "github.com/rs/zerolog/log"
-)
-
-type PhotoUpload struct {
- Filename string
- Size int64
- UUID uuid.UUID
-}
-
-func extractPhotoUploads(r *http.Request) (uploads []PhotoUpload, err error) {
- uploads = make([]PhotoUpload, 0)
- for _, fheaders := range r.MultipartForm.File {
- for _, headers := range fheaders {
- file, err := headers.Open()
-
- if err != nil {
- return uploads, fmt.Errorf("Failed to open header: %v", err)
- }
-
- defer file.Close()
-
- buff := make([]byte, 512)
- file.Read(buff)
-
- file.Seek(0, 0)
- contentType := http.DetectContentType(buff)
- var sizeBuff bytes.Buffer
- fileSize, err := sizeBuff.ReadFrom(file)
- if err != nil {
- return uploads, fmt.Errorf("Failed to read file: %v", err)
- }
- file.Seek(0, 0)
- log.Info().Int64("size", fileSize).Str("filename", headers.Filename).Str("content-type", contentType).Msg("Got an uploaded file")
- u, err := uuid.NewUUID()
- if err != nil {
- return uploads, fmt.Errorf("Failed to create quick report photo uuid", err)
- }
- err = userfile.PublicImageFileContentWrite(u, file)
- if err != nil {
- return uploads, fmt.Errorf("Failed to write image file to disk: %v", err)
- }
- uploads = append(uploads, PhotoUpload{
- Size: fileSize,
- Filename: headers.Filename,
- UUID: u,
- })
- }
- }
- return uploads, nil
-}
diff --git a/public-report/pool.go b/public-report/pool.go
index 5f5d5004..6872c8a7 100644
--- a/public-report/pool.go
+++ b/public-report/pool.go
@@ -13,6 +13,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/htmlpage"
"github.com/aarondl/opt/omit"
"github.com/rs/zerolog/log"
+ "github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/um"
)
@@ -90,6 +91,14 @@ func postPool(w http.ResponseWriter, r *http.Request) {
return
}
+ ctx := r.Context()
+ tx, err := db.PGInstance.BobDB.BeginTx(ctx, nil)
+ if err != nil {
+ respondError(w, "Failed to create transaction", err, http.StatusInternalServerError)
+ return
+ }
+ defer tx.Rollback(ctx)
+
setter := models.PublicreportPoolSetter{
AccessComments: omit.From(access_comments),
AccessGate: omit.From(access_gate),
@@ -121,7 +130,7 @@ func postPool(w http.ResponseWriter, r *http.Request) {
Status: omit.From(enums.PublicreportReportstatustypeReported),
Subscribe: omit.From(subscribe),
}
- pool, err := models.PublicreportPools.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
+ pool, err := models.PublicreportPools.Insert(&setter).One(ctx, tx)
if err != nil {
respondError(w, "Failed to create database record", err, http.StatusInternalServerError)
return
@@ -138,30 +147,31 @@ func postPool(w http.ResponseWriter, r *http.Request) {
um.SetCol("h3cell").ToArg(geospatial.Cell),
um.SetCol("location").To(geospatial.GeometryQuery),
um.Where(psql.Quote("id").EQ(psql.Arg(pool.ID))),
- ).Exec(r.Context(), db.PGInstance.BobDB)
+ ).Exec(ctx, tx)
if err != nil {
respondError(w, "Failed to insert publicreport.pool", err, http.StatusInternalServerError)
return
}
}
log.Info().Int32("id", pool.ID).Str("public_id", pool.PublicID).Msg("Created pool report")
- photoSetters := make([]*models.PublicreportPoolPhotoSetter, 0)
- uploads, err := extractPhotoUploads(r)
+ uploads, err := extractImageUploads(r)
if err != nil {
- respondError(w, "Failed to extract photo uploads", err, http.StatusInternalServerError)
+ respondError(w, "Failed to extract image uploads", err, http.StatusInternalServerError)
return
}
- for _, u := range uploads {
- photoSetters = append(photoSetters, &models.PublicreportPoolPhotoSetter{
- Filename: omit.From(u.Filename),
- Size: omit.From(u.Size),
- UUID: omit.From(u.UUID),
+ images, err := saveImageUploads(r.Context(), tx, uploads)
+ setters := make([]*models.PublicreportPoolImageSetter, 0)
+ for _, image := range images {
+ setters = append(setters, &models.PublicreportPoolImageSetter{
+ ImageID: omit.From(int32(image.ID)),
+ PoolID: omit.From(int32(pool.ID)),
})
}
- err = pool.InsertPoolPhotos(r.Context(), db.PGInstance.BobDB, photoSetters...)
+ _, err = models.PublicreportPoolImages.Insert(bob.ToMods(setters...)).Exec(r.Context(), tx)
if err != nil {
- respondError(w, "Failed to create photo records", err, http.StatusInternalServerError)
+ respondError(w, "Failed to save upload relationships", err, http.StatusInternalServerError)
return
}
+ tx.Commit(ctx)
http.Redirect(w, r, fmt.Sprintf("/pool-submit-complete?report=%s", public_id), http.StatusFound)
}
diff --git a/public-report/quick.go b/public-report/quick.go
index 1509df56..e076d425 100644
--- a/public-report/quick.go
+++ b/public-report/quick.go
@@ -14,6 +14,7 @@ import (
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/rs/zerolog/log"
+ "github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/um"
)
@@ -70,6 +71,14 @@ func postQuick(w http.ResponseWriter, r *http.Request) {
respondError(w, "Failed to create quick report public ID", err, http.StatusInternalServerError)
return
}
+ ctx := r.Context()
+ tx, err := db.PGInstance.BobDB.BeginTx(ctx, nil)
+ if err != nil {
+ respondError(w, "Failed to create transaction", err, http.StatusInternalServerError)
+ return
+ }
+ defer tx.Rollback(ctx)
+
c, err := h3utils.GetCell(longitude, latitude, 15)
setter := models.PublicreportQuickSetter{
Address: omit.From(""),
@@ -82,7 +91,7 @@ func postQuick(w http.ResponseWriter, r *http.Request) {
ReporterPhone: omit.From(""),
Status: omit.From(enums.PublicreportReportstatustypeReported),
}
- quick, err := models.PublicreportQuicks.Insert(&setter).One(r.Context(), db.PGInstance.BobDB)
+ quick, err := models.PublicreportQuicks.Insert(&setter).One(ctx, tx)
if err != nil {
respondError(w, "Failed to create database record", err, http.StatusInternalServerError)
return
@@ -91,29 +100,37 @@ func postQuick(w http.ResponseWriter, r *http.Request) {
um.Table("publicreport.quick"),
um.SetCol("location").To(fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", longitude, latitude)),
um.Where(psql.Quote("id").EQ(psql.Arg(quick.ID))),
- ).Exec(r.Context(), db.PGInstance.BobDB)
+ ).Exec(ctx, tx)
if err != nil {
respondError(w, "Failed to insert publicreport", err, http.StatusInternalServerError)
return
}
log.Info().Float64("latitude", latitude).Float64("longitude", longitude).Msg("Got upload")
- photoSetters := make([]*models.PublicreportQuickPhotoSetter, 0)
- uploads, err := extractPhotoUploads(r)
+ uploads, err := extractImageUploads(r)
+ log.Info().Int("len", len(uploads)).Msg("extracted uploads")
if err != nil {
- respondError(w, "Failed to extract photo uploads", err, http.StatusInternalServerError)
+ respondError(w, "Failed to extract image uploads", err, http.StatusInternalServerError)
return
}
- for _, u := range uploads {
- photoSetters = append(photoSetters, &models.PublicreportQuickPhotoSetter{
- Filename: omit.From(u.Filename),
- Size: omit.From(u.Size),
- UUID: omit.From(u.UUID),
+ images, err := saveImageUploads(ctx, tx, uploads)
+ if err != nil {
+ respondError(w, "Failed to save image uploads", err, http.StatusInternalServerError)
+ return
+ }
+ log.Info().Int("len", len(images)).Msg("saved uploads")
+ setters := make([]*models.PublicreportQuickImageSetter, 0)
+ for _, image := range images {
+ setters = append(setters, &models.PublicreportQuickImageSetter{
+ ImageID: omit.From(int32(image.ID)),
+ QuickID: omit.From(int32(quick.ID)),
})
}
- err = quick.InsertQuickPhotos(r.Context(), db.PGInstance.BobDB, photoSetters...)
+ _, err = models.PublicreportQuickImages.Insert(bob.ToMods(setters...)).Exec(ctx, tx)
if err != nil {
- respondError(w, "Failed to create photo records", err, http.StatusInternalServerError)
+ respondError(w, "Failed to save reference to images", err, http.StatusInternalServerError)
return
}
+ log.Info().Int("len", len(images)).Msg("saved uploads")
+ tx.Commit(ctx)
http.Redirect(w, r, fmt.Sprintf("/quick-submit-complete?report=%s", u), http.StatusFound)
}
diff --git a/userfile/userfile.go b/userfile/userfile.go
index 2608d975..794450e0 100644
--- a/userfile/userfile.go
+++ b/userfile/userfile.go
@@ -3,11 +3,11 @@ package userfile
import (
"fmt"
"io"
- "log"
"os"
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/google/uuid"
+ "github.com/rs/zerolog/log"
)
func AudioFileContentPathRaw(audioUUID string) string {
@@ -27,7 +27,7 @@ func AudioFileContentWrite(audioUUID uuid.UUID, body io.Reader) error {
filepath := AudioFileContentPathRaw(audioUUID.String())
dst, err := os.Create(filepath)
if err != nil {
- log.Printf("Failed to create audio file at %s: %v\n", filepath, err)
+ log.Error().Err(err).Str("filepath", filepath).Msg("Failed to create audio file")
return fmt.Errorf("Failed to create audio file at %s: %v", filepath, err)
}
defer dst.Close()
@@ -37,7 +37,7 @@ func AudioFileContentWrite(audioUUID uuid.UUID, body io.Reader) error {
if err != nil {
return fmt.Errorf("Unable to save file to create audio file at %s: %v", filepath, err)
}
- log.Printf("Saved audio content to %s\n", filepath)
+ log.Info().Str("filepath", filepath).Msg("Save audio file content")
return nil
}
func ImageFileContentPathRaw(uid string) string {
@@ -65,7 +65,7 @@ func PublicImageFileContentWrite(uid uuid.UUID, body io.Reader) error {
filepath := PublicImageFileContentPathRaw(uid.String())
dst, err := os.Create(filepath)
if err != nil {
- log.Printf("Failed to create public image file at %s: %v\n", filepath, err)
+ log.Error().Err(err).Str("filepath", filepath).Msg("Failed to create public image file")
return fmt.Errorf("Failed to create public image file at %s: %v", filepath, err)
}
defer dst.Close()
@@ -75,7 +75,7 @@ func PublicImageFileContentWrite(uid uuid.UUID, body io.Reader) error {
if err != nil {
return fmt.Errorf("Unable to save file to create audio file at %s: %v", filepath, err)
}
- log.Printf("Saved audio content to %s\n", filepath)
+ log.Info().Str("filepath", filepath).Msg("Saved public report image file content")
return nil
}
func PublicImageFileContentPathRaw(uid string) string {
From 8ab0b78e6e6ac390da3659d3c40ecf8326a10693 Mon Sep 17 00:00:00 2001
From: Eli Ribble
Date: Fri, 16 Jan 2026 21:16:59 +0000
Subject: [PATCH 0050/1453] Make sure they consent to get notifications in the
UI.
---
public-report/template/quick-submit-complete.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/public-report/template/quick-submit-complete.html b/public-report/template/quick-submit-complete.html
index 35dc6673..da711c4b 100644
--- a/public-report/template/quick-submit-complete.html
+++ b/public-report/template/quick-submit-complete.html
@@ -59,7 +59,7 @@
Provide your contact information to receive updates about your report.
-
-