Compare commits

...

43 Commits

Author SHA1 Message Date
Matthew Kilgore
8f03a8e2e9 Remove old ent generated things that should have already been removed. 2025-12-13 21:47:10 -05:00
Matthew Kilgore
e198c2aba2 Actually finish merge things 2025-12-13 21:36:53 -05:00
Matthew Kilgore
798426bebf Finish merge stuff with main 2025-12-13 21:23:45 -05:00
Matthew Kilgore
44f488db77 Merge remote-tracking branch 'origin/main' into mk/merge-entities
# Conflicts:
#	backend/app/api/static/docs/docs.go
#	backend/app/api/static/docs/openapi-3.json
#	backend/app/api/static/docs/openapi-3.yaml
#	backend/app/api/static/docs/swagger.json
#	backend/app/api/static/docs/swagger.yaml
#	backend/go.mod
#	backend/go.sum
#	backend/internal/data/ent/attachment.go
#	backend/internal/data/ent/attachment_create.go
#	backend/internal/data/ent/attachment_query.go
#	backend/internal/data/ent/attachment_update.go
#	backend/internal/data/ent/client.go
#	backend/internal/data/ent/ent.go
#	backend/internal/data/ent/entityfield.go
#	backend/internal/data/ent/group.go
#	backend/internal/data/ent/group/group.go
#	backend/internal/data/ent/group/where.go
#	backend/internal/data/ent/group_create.go
#	backend/internal/data/ent/group_query.go
#	backend/internal/data/ent/group_update.go
#	backend/internal/data/ent/has_id.go
#	backend/internal/data/ent/hook/hook.go
#	backend/internal/data/ent/item.go
#	backend/internal/data/ent/item_create.go
#	backend/internal/data/ent/item_delete.go
#	backend/internal/data/ent/item_query.go
#	backend/internal/data/ent/item_update.go
#	backend/internal/data/ent/itemfield_create.go
#	backend/internal/data/ent/itemfield_delete.go
#	backend/internal/data/ent/itemfield_query.go
#	backend/internal/data/ent/itemfield_update.go
#	backend/internal/data/ent/label.go
#	backend/internal/data/ent/label_create.go
#	backend/internal/data/ent/label_query.go
#	backend/internal/data/ent/label_update.go
#	backend/internal/data/ent/location.go
#	backend/internal/data/ent/location_create.go
#	backend/internal/data/ent/location_delete.go
#	backend/internal/data/ent/location_query.go
#	backend/internal/data/ent/location_update.go
#	backend/internal/data/ent/maintenanceentry.go
#	backend/internal/data/ent/maintenanceentry_create.go
#	backend/internal/data/ent/maintenanceentry_query.go
#	backend/internal/data/ent/maintenanceentry_update.go
#	backend/internal/data/ent/migrate/schema.go
#	backend/internal/data/ent/mutation.go
#	backend/internal/data/ent/predicate/predicate.go
#	backend/internal/data/ent/runtime.go
#	backend/internal/data/ent/schema/group.go
#	backend/internal/data/ent/tx.go
#	backend/internal/data/ent/user.go
#	backend/internal/data/ent/user_create.go
#	backend/internal/data/ent/user_update.go
#	backend/internal/data/repo/repo_entity_attachments.go
#	backend/internal/data/repo/repo_items.go
#	backend/internal/data/repo/repo_items_search_test.go
#	backend/internal/data/repo/repos_all.go
#	docs/en/api/openapi-3.0.json
#	docs/en/api/openapi-3.0.yaml
#	docs/en/api/swagger-2.0.json
#	docs/en/api/swagger-2.0.yaml
#	frontend/lib/api/types/data-contracts.ts
2025-12-13 21:19:43 -05:00
Matthew Kilgore
462c5d20ac Complete merge of main into branch 2025-10-05 18:59:14 -04:00
Matthew Kilgore
b8cca4b383 Merge branch 'main' into mk/merge-entities
# Conflicts:
#	backend/app/api/static/docs/docs.go
#	backend/app/api/static/docs/swagger.json
#	backend/internal/data/repo/repo_items.go
#	docs/en/api/swagger-2.0.json
#	frontend/lib/api/types/data-contracts.ts
2025-10-05 18:58:28 -04:00
Matthew Kilgore
9c121f235c Start putting things together for the new entities repository. 2025-10-05 18:52:21 -04:00
Matthew Kilgore
9f16aad83f Commit to change branch 2025-09-21 16:35:56 -04:00
Matthew Kilgore
ab1fd674ee Add entitytypes delete method 2025-09-11 22:18:15 -04:00
Matthew Kilgore
c0cb5794f3 Lint the things 2025-09-10 22:12:52 -04:00
Matthew Kilgore
3f2ae368ba API stuff for entity types 2025-09-10 21:34:39 -04:00
Matthew Kilgore
5456390b63 What should be a working Postgres migration 2025-09-10 20:28:02 -04:00
Matthew Kilgore
fa9b7af117 Working locations/items tree 2025-09-06 17:37:30 -04:00
Matthew Kilgore
e7f5866465 Further progress on sqlite 2025-09-05 22:44:40 -04:00
Matthew Kilgore
8f4ed9afd2 Slow progress, but we're getting there. 2025-09-05 21:18:18 -04:00
Matthew Kilgore
234302e50b Merge remote-tracking branch 'origin/main' into mk/merge-entities 2025-09-05 20:18:26 -04:00
Matthew Kilgore
564bd8ca06 Get main into this PR.
Done on ✈️
2025-09-02 15:09:42 -04:00
Matthew Kilgore
e00cebb7fa Merge branch 'refs/heads/main' into mk/merge-entities
# Conflicts:
#	backend/app/api/static/docs/docs.go
#	backend/app/api/static/docs/swagger.json
#	backend/go.mod
#	backend/go.sum
#	backend/internal/data/ent/entity_predicates_test.go
#	backend/internal/data/repo/repo_items.go
#	docs/en/api/openapi-2.0.json
2025-09-02 14:54:20 -04:00
Matthew Kilgore
b107ab026a Refactor entity attachment handling and update API routes for entities 2025-07-27 18:20:34 -04:00
Matthew Kilgore
a35e92ba72 Weird issue with go.mod file 2025-07-27 17:45:15 -04:00
Matthew Kilgore
77b14f3a55 More merge fixing 2025-07-27 17:42:58 -04:00
Matthew Kilgore
64907bbb3a Cleanup merge 2025-07-27 17:37:56 -04:00
Matthew Kilgore
de1491133b Merge branch 'main' into mk/merge-entities
# Conflicts:
#	.github/workflows/binaries-publish.yaml
#	.github/workflows/e2e-partial.yaml
#	.github/workflows/partial-backend.yaml
#	.github/workflows/partial-frontend.yaml
#	backend/app/api/handlers/v1/v1_ctrl_items.go
#	backend/go.mod
#	backend/go.sum
#	backend/internal/data/ent/attachment.go
#	backend/internal/data/ent/attachment/attachment.go
#	backend/internal/data/ent/attachment/where.go
#	backend/internal/data/ent/attachment_create.go
#	backend/internal/data/ent/attachment_query.go
#	backend/internal/data/ent/attachment_update.go
#	backend/internal/data/ent/migrate/schema.go
#	backend/internal/data/ent/mutation.go
#	backend/internal/data/repo/repo_item_attachments.go
#	backend/internal/data/repo/repo_items.go
2025-07-27 17:31:33 -04:00
Matthew Kilgore
6518db2c02 WIP: still working things out 2025-06-02 21:45:54 -04:00
Matthew Kilgore
fa50f3aa86 fix: missing column from entities migration for postgres 2025-06-01 12:02:19 -04:00
Matthew Kilgore
1fa0bdc351 fix: conflicting migrations 2025-06-01 11:56:04 -04:00
Matthew Kilgore
2a486ec0cf WIP: Postgres migrations 2025-06-01 11:52:10 -04:00
Matthew Kilgore
b989cf0f0a WIP: Place holder while I switch devices 2025-05-31 18:35:22 -04:00
Matthew Kilgore
b61edf1c99 fix: completely broken test 2025-05-26 15:00:37 -04:00
Matthew Kilgore
be7f276438 fix: completely broken code 2025-05-26 14:58:13 -04:00
Matthew Kilgore
51657d6ce6 fix: bad edge design for location column 2025-05-26 13:38:17 -04:00
Matthew Kilgore
635ad2672a chore: better column name for location entity type check 2025-05-26 13:22:30 -04:00
Matthew Kilgore
b0693cba08 ci: fix golang dependencies cache path 2025-05-26 13:20:41 -04:00
Matthew Kilgore
2789c1c977 Let's go crazy with user defined types 2025-05-13 21:21:40 -04:00
Matthew Kilgore
a085f95ef9 Fix docs openapi json 2025-05-10 21:42:21 -04:00
Matthew Kilgore
22cb2f868b For some reason swaggo doesn't mark the endpoints as deprecated 2025-05-10 21:30:21 -04:00
Matthew Kilgore
c9473699d7 Merge remote-tracking branch 'origin/mk/merge-entities' into mk/merge-entities 2025-05-10 21:21:42 -04:00
Matthew Kilgore
ed53026d48 Initial test SQL migration, and deprecation of items and locations APIs (soon to be replaced) 2025-05-10 21:21:27 -04:00
Matt Kilgore
666237d277 Merge branch 'main' into mk/merge-entities 2025-05-08 09:11:10 -04:00
Matthew Kilgore
d8e8bf41a2 Application can run (although no DB changes yet) 2025-05-07 21:52:07 -04:00
Matthew Kilgore
fbe56c4403 In theory fix repo_items.go 2025-05-07 21:35:58 -04:00
Matthew Kilgore
aa4de3c259 Add location relationship to prevent stupid complexity 2025-05-07 21:15:08 -04:00
Matthew Kilgore
8bf9578bd2 WIP: start entity merge stuff (very broken) 2025-05-07 20:41:29 -04:00
125 changed files with 24496 additions and 16387 deletions

87
.vscode/launch.json vendored
View File

@@ -1,47 +1,44 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"compounds": [
{
"name": "Full Stack",
"configurations": ["Launch Backend", "Launch Frontend"],
"stopAll": true
}
],
"configurations": [
{
"name": "Launch Backend",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/backend/app/api/",
"args": [],
"env": {
"HBOX_DEMO": "true",
"HBOX_LOG_LEVEL": "debug",
"HBOX_DEBUG_ENABLED": "true"
},
"console": "integratedTerminal",
},
{
"name": "Launch Frontend",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeArgs": [
"run",
"dev"
],
"cwd": "${workspaceFolder}/frontend",
"serverReadyAction": {
"action": "debugWithChrome",
"pattern": "Local: +http://localhost:([0-9]+)",
"uriFormat": "http://localhost:%s",
"webRoot": "${workspaceFolder}/frontend"
},
"console": "integratedTerminal",
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"compounds": [
{
"name": "Full Stack",
"configurations": ["Launch Backend", "Launch Frontend"],
"stopAll": true
}
],
"configurations": [
{
"name": "Launch Backend",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/backend/app/api/",
"args": [],
"env": {
"HBOX_DEMO": "true",
"HBOX_LOG_LEVEL": "debug",
"HBOX_DEBUG_ENABLED": "true"
},
"console": "integratedTerminal"
},
{
"name": "Launch Frontend",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["run", "dev"],
"cwd": "${workspaceFolder}/frontend",
"serverReadyAction": {
"action": "debugWithChrome",
"pattern": "Local: +http://localhost:([0-9]+)",
"uriFormat": "http://localhost:%s",
"webRoot": "${workspaceFolder}/frontend"
},
"console": "integratedTerminal"
}
]
}

View File

@@ -0,0 +1 @@
package v1

View File

@@ -0,0 +1,243 @@
package v1
import (
"errors"
"net/http"
"net/url"
"path/filepath"
"strconv"
"strings"
"github.com/hay-kot/httpkit/errchain"
"github.com/hay-kot/httpkit/server"
"github.com/rs/zerolog/log"
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"github.com/sysadminsmedia/homebox/backend/internal/sys/validate"
"gocloud.dev/blob"
_ "gocloud.dev/blob/azureblob"
_ "gocloud.dev/blob/fileblob"
_ "gocloud.dev/blob/gcsblob"
_ "gocloud.dev/blob/memblob"
_ "gocloud.dev/blob/s3blob"
)
type (
EntityAttachmentToken struct {
Token string `json:"token"`
}
)
// HandleEntityAttachmentCreate godocs
//
// @Summary Create Item Attachment
// @Tags Items Attachments
// @Accept multipart/form-data
// @Produce json
// @Param id path string true "Item ID"
// @Param file formData file true "File attachment"
// @Param type formData string false "Type of file"
// @Param primary formData bool false "Is this the primary attachment"
// @Param name formData string true "name of the file including extension"
// @Success 200 {object} repo.ItemOut
// @Failure 422 {object} validate.ErrorResponse
// @Router /v1/entities/{id}/attachments [POST]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityAttachmentCreate() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)
if err != nil {
log.Err(err).Msg("failed to parse multipart form")
return validate.NewRequestError(errors.New("failed to parse multipart form"), http.StatusBadRequest)
}
errs := validate.NewFieldErrors()
file, _, err := r.FormFile("file")
if err != nil {
switch {
case errors.Is(err, http.ErrMissingFile):
log.Debug().Msg("file for attachment is missing")
errs = errs.Append("file", "file is required")
default:
log.Err(err).Msg("failed to get file from form")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
}
attachmentName := r.FormValue("name")
if attachmentName == "" {
log.Debug().Msg("failed to get name from form")
errs = errs.Append("name", "name is required")
}
if !errs.Nil() {
return server.JSON(w, http.StatusUnprocessableEntity, errs)
}
attachmentType := r.FormValue("type")
if attachmentType == "" {
// Attempt to auto-detect the type of the file
ext := filepath.Ext(attachmentName)
switch strings.ToLower(ext) {
case ".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tiff", ".avif", ".ico", ".heic", ".jxl":
attachmentType = attachment.TypePhoto.String()
default:
attachmentType = attachment.TypeAttachment.String()
}
}
primary, err := strconv.ParseBool(r.FormValue("primary"))
if err != nil {
log.Debug().Msg("failed to parse primary from form")
primary = false
}
id, err := ctrl.routeID(r)
if err != nil {
return err
}
ctx := services.NewContext(r.Context())
item, err := ctrl.svc.Items.AttachmentAdd(
ctx,
id,
attachmentName,
attachment.Type(attachmentType),
primary,
file,
)
if err != nil {
log.Err(err).Msg("failed to add attachment")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
return server.JSON(w, http.StatusCreated, item)
}
}
// HandleEntityAttachmentGet godocs
//
// @Summary Get Item Attachment
// @Tags Items Attachments
// @Produce application/octet-stream
// @Param id path string true "Item ID"
// @Param attachment_id path string true "Attachment ID"
// @Success 200 {object} ItemAttachmentToken
// @Router /v1/entities/{id}/attachments/{attachment_id} [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityAttachmentGet() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
// HandleEntityAttachmentDelete godocs
//
// @Summary Delete Item Attachment
// @Tags Items Attachments
// @Param id path string true "Item ID"
// @Param attachment_id path string true "Attachment ID"
// @Success 204
// @Router /v1/entities/{id}/attachments/{attachment_id} [DELETE]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityAttachmentDelete() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
// HandleEntityAttachmentUpdate godocs
//
// @Summary Update Item Attachment
// @Tags Items Attachments
// @Param id path string true "Item ID"
// @Param attachment_id path string true "Attachment ID"
// @Param payload body repo.EntityAttachmentUpdate true "Attachment Update"
// @Success 200 {object} repo.ItemOut
// @Router /v1/entities/{id}/attachments/{attachment_id} [PUT]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityAttachmentUpdate() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
func (ctrl *V1Controller) handleEntityAttachmentsHandler(w http.ResponseWriter, r *http.Request) error {
ID, err := ctrl.routeID(r)
if err != nil {
return err
}
attachmentID, err := ctrl.routeUUID(r, "attachment_id")
if err != nil {
return err
}
ctx := services.NewContext(r.Context())
switch r.Method {
case http.MethodGet:
doc, err := ctrl.svc.Items.AttachmentPath(r.Context(), ctx.GID, attachmentID)
if err != nil {
log.Err(err).Msg("failed to get attachment path")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
bucket, err := blob.OpenBucket(ctx, ctrl.repo.Attachments.GetConnString())
if err != nil {
log.Err(err).Msg("failed to open bucket")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
file, err := bucket.NewReader(ctx, doc.Path, nil)
if err != nil {
log.Err(err).Msg("failed to open file")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
defer func(file *blob.Reader) {
err := file.Close()
if err != nil {
log.Err(err).Msg("failed to close file")
}
}(file)
defer func(bucket *blob.Bucket) {
err := bucket.Close()
if err != nil {
log.Err(err).Msg("failed to close bucket")
}
}(bucket)
// Set the Content-Disposition header for RFC6266 compliance
disposition := "attachment; filename*=UTF-8''" + url.QueryEscape(doc.Title)
w.Header().Set("Content-Disposition", disposition)
http.ServeContent(w, r, doc.Title, doc.CreatedAt, file)
return nil
// Delete Attachment Handler
case http.MethodDelete:
err = ctrl.svc.Items.AttachmentDelete(r.Context(), ctx.GID, ID, attachmentID)
if err != nil {
log.Err(err).Msg("failed to delete attachment")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
return server.JSON(w, http.StatusNoContent, nil)
// Update Attachment Handler
case http.MethodPut:
var attachment repo.EntityAttachmentUpdate
err = server.Decode(r, &attachment)
if err != nil {
log.Err(err).Msg("failed to decode attachment")
return validate.NewRequestError(err, http.StatusBadRequest)
}
attachment.ID = attachmentID
val, err := ctrl.svc.Items.AttachmentUpdate(ctx, ctx.GID, ID, &attachment)
if err != nil {
log.Err(err).Msg("failed to update attachment")
return validate.NewRequestError(err, http.StatusInternalServerError)
}
return server.JSON(w, http.StatusOK, val)
}
return nil
}

View File

@@ -0,0 +1,99 @@
package v1
import (
"net/http"
"github.com/google/uuid"
"github.com/hay-kot/httpkit/errchain"
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
)
// HandleEntityTypesGetAll godoc
//
// @Summary Query All Entity Types
// @Tags EntityTypes
// @Produce json
// @Success 200 {array} repo.EntityType[]
// @Router /v1/entitytype [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityTypesGetAll() errchain.HandlerFunc {
fn := func(r *http.Request) ([]repo.EntityType, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.EntityType.GetEntityTypesByGroupID(auth, auth.GID)
}
return adapters.Command(fn, http.StatusOK)
}
// HandleEntityTypeGetOne godoc
//
// @Summary Get One Entity Type
// @Tags EntityTypes
// @Produce json
// @Param id path string true "Entity Type ID"
// @Success 200 {object} repo.EntityType
// @Router /v1/entitytype/{id} [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityTypeGetOne() errchain.HandlerFunc {
fn := func(r *http.Request, entityTypeID uuid.UUID) (repo.EntityType, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.EntityType.GetOneByGroup(auth, auth.GID, entityTypeID)
}
return adapters.CommandID("id", fn, http.StatusOK)
}
// HandleEntityTypeCreate godoc
//
// @Summary Create Entity Type
// @Tags EntityTypes
// @Accept json
// @Produce json
// @Param payload body repo.EntityTypeCreate true "Entity Type Data"
// @Success 201 {object} repo.EntityType
// @Router /v1/entitytype [POST]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityTypeCreate() errchain.HandlerFunc {
fn := func(r *http.Request, body repo.EntityTypeCreate) (repo.EntityType, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.EntityType.CreateEntityType(auth, auth.GID, body)
}
return adapters.Action(fn, http.StatusCreated)
}
// HandleEntityTypeUpdate godoc
//
// @Summary Update Entity Type
// @Tags EntityTypes
// @Accept json
// @Produce json
// @Param id path string true "Entity Type ID"
// @Param payload body repo.EntityTypeUpdate true "Entity Type Data"
// @Success 200 {object} repo.EntityType
// @Router /v1/entitytype/{id} [PUT]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityTypeUpdate() errchain.HandlerFunc {
fn := func(r *http.Request, entityTypeID uuid.UUID, body repo.EntityTypeUpdate) (repo.EntityType, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.EntityType.UpdateEntityType(auth, auth.GID, entityTypeID, body)
}
return adapters.ActionID("id", fn, http.StatusOK)
}
// HandleEntityTypeDelete godoc
//
// @Summary Delete Entity Type
// @Tags EntityTypes
// @Param id path string true "Entity Type ID"
// @Param payload body repo.EntityTypeDelete true "Entity Type Delete Options"
// @Success 204
// @Router /v1/entitytype/{id} [DELETE]
// @Security Bearer
func (ctrl *V1Controller) HandleEntityTypeDelete() errchain.HandlerFunc {
fn := func(r *http.Request, entityTypeID uuid.UUID, body repo.EntityTypeDelete) (any, error) {
auth := services.NewContext(r.Context())
err := ctrl.repo.EntityType.DeleteEntityType(auth, auth.GID, entityTypeID, body)
return nil, err
}
return adapters.ActionID("id", fn, http.StatusNoContent)
}

View File

@@ -22,7 +22,7 @@ import (
// HandleItemsGetAll godoc
//
// @Summary Query All Items
// @Summary (Deprecated) Query All Items
// @Tags Items
// @Produce json
// @Param q query string false "search string"
@@ -34,6 +34,7 @@ import (
// @Success 200 {object} repo.PaginationResult[repo.ItemSummary]{}
// @Router /v1/items [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
extractQuery := func(r *http.Request) repo.ItemQuery {
params := r.URL.Query()
@@ -112,13 +113,14 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
// HandleItemFullPath godoc
//
// @Summary Get the full path of an item
// @Summary (Deprecated) Get the full path of an item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
// @Success 200 {object} []repo.ItemPath
// @Router /v1/items/{id}/path [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemFullPath() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID) ([]repo.ItemPath, error) {
auth := services.NewContext(r.Context())
@@ -154,13 +156,15 @@ func (ctrl *V1Controller) HandleItemFullPath() errchain.HandlerFunc {
// HandleItemsCreate godoc
//
// @Summary Create Item
// @Tags Items
// @Produce json
// @Param payload body repo.ItemCreate true "Item Data"
// @Success 201 {object} repo.ItemSummary
// @Router /v1/items [POST]
// @Security Bearer
// @Summary Create Item
// @Tags Items
// @Accept json
// @Produce json
// @Param payload body repo.ItemCreate true "Item Data"
// @Success 201 {object} repo.ItemSummary
// @Router /v1/items [POST]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemsCreate() errchain.HandlerFunc {
fn := func(r *http.Request, body repo.ItemCreate) (repo.ItemOut, error) {
return ctrl.svc.Items.Create(services.NewContext(r.Context()), body)
@@ -171,13 +175,14 @@ func (ctrl *V1Controller) HandleItemsCreate() errchain.HandlerFunc {
// HandleItemGet godocs
//
// @Summary Get Item
// @Summary (Deprecated) Get Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
// @Success 200 {object} repo.ItemOut
// @Router /v1/items/{id} [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemGet() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID) (repo.ItemOut, error) {
auth := services.NewContext(r.Context())
@@ -190,13 +195,14 @@ func (ctrl *V1Controller) HandleItemGet() errchain.HandlerFunc {
// HandleItemDelete godocs
//
// @Summary Delete Item
// @Summary (Deprecated) Delete Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
// @Success 204
// @Router /v1/items/{id} [DELETE]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemDelete() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID) (any, error) {
auth := services.NewContext(r.Context())
@@ -209,7 +215,7 @@ func (ctrl *V1Controller) HandleItemDelete() errchain.HandlerFunc {
// HandleItemUpdate godocs
//
// @Summary Update Item
// @Summary (Deprecated) Update Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
@@ -217,6 +223,7 @@ func (ctrl *V1Controller) HandleItemDelete() errchain.HandlerFunc {
// @Success 200 {object} repo.ItemOut
// @Router /v1/items/{id} [PUT]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemUpdate() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID, body repo.ItemUpdate) (repo.ItemOut, error) {
auth := services.NewContext(r.Context())
@@ -230,7 +237,7 @@ func (ctrl *V1Controller) HandleItemUpdate() errchain.HandlerFunc {
// HandleItemPatch godocs
//
// @Summary Update Item
// @Summary (Deprecated) Update Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
@@ -238,6 +245,7 @@ func (ctrl *V1Controller) HandleItemUpdate() errchain.HandlerFunc {
// @Success 200 {object} repo.ItemOut
// @Router /v1/items/{id} [Patch]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemPatch() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID, body repo.ItemPatch) (repo.ItemOut, error) {
auth := services.NewContext(r.Context())
@@ -275,13 +283,14 @@ func (ctrl *V1Controller) HandleItemDuplicate() errchain.HandlerFunc {
// HandleGetAllCustomFieldNames godocs
//
// @Summary Get All Custom Field Names
// @Summary (Deprecated) Get All Custom Field Names
// @Tags Items
// @Produce json
// @Success 200
// @Router /v1/items/fields [GET]
// @Success 200 {object} []string
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleGetAllCustomFieldNames() errchain.HandlerFunc {
fn := func(r *http.Request) ([]string, error) {
auth := services.NewContext(r.Context())
@@ -293,13 +302,14 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldNames() errchain.HandlerFunc {
// HandleGetAllCustomFieldValues godocs
//
// @Summary Get All Custom Field Values
// @Summary (Deprecated) Get All Custom Field Values
// @Tags Items
// @Produce json
// @Success 200
// @Router /v1/items/fields/values [GET]
// @Success 200 {object} []string
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleGetAllCustomFieldValues() errchain.HandlerFunc {
type query struct {
Field string `schema:"field" validate:"required"`
@@ -315,14 +325,15 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldValues() errchain.HandlerFunc {
// HandleItemsImport godocs
//
// @Summary Import Items
// @Tags Items
// @Accept multipart/form-data
// @Produce json
// @Success 204
// @Param csv formData file true "Image to upload"
// @Router /v1/items/import [Post]
// @Security Bearer
// @Summary (Deprecated) Import Items
// @Tags Items
// @Accept multipart/form-data
// @Produce json
// @Success 204
// @Param csv formData file true "Image to upload"
// @Router /v1/items/import [Post]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemsImport() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)
@@ -351,11 +362,12 @@ func (ctrl *V1Controller) HandleItemsImport() errchain.HandlerFunc {
// HandleItemsExport godocs
//
// @Summary Export Items
// @Summary (Deprecated) Export Items
// @Tags Items
// @Success 200 {string} string "text/csv"
// @Router /v1/items/export [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemsExport() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
ctx := services.NewContext(r.Context())

View File

@@ -45,6 +45,7 @@ type (
// @Failure 422 {object} validate.ErrorResponse
// @Router /v1/items/{id}/attachments [POST]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)
@@ -130,6 +131,7 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc {
// @Success 200 {object} ItemAttachmentToken
// @Router /v1/items/{id}/attachments/{attachment_id} [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemAttachmentGet() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
@@ -143,6 +145,7 @@ func (ctrl *V1Controller) HandleItemAttachmentGet() errchain.HandlerFunc {
// @Success 204
// @Router /v1/items/{id}/attachments/{attachment_id} [DELETE]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemAttachmentDelete() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
@@ -153,10 +156,11 @@ func (ctrl *V1Controller) HandleItemAttachmentDelete() errchain.HandlerFunc {
// @Tags Items Attachments
// @Param id path string true "Item ID"
// @Param attachment_id path string true "Attachment ID"
// @Param payload body repo.ItemAttachmentUpdate true "Attachment Update"
// @Param payload body repo.EntityAttachmentUpdate true "Attachment Update"
// @Success 200 {object} repo.ItemOut
// @Router /v1/items/{id}/attachments/{attachment_id} [PUT]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleItemAttachmentUpdate() errchain.HandlerFunc {
return ctrl.handleItemAttachmentsHandler
}
@@ -222,7 +226,7 @@ func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r
// Update Attachment Handler
case http.MethodPut:
var attachment repo.ItemAttachmentUpdate
var attachment repo.EntityAttachmentUpdate
err = server.Decode(r, &attachment)
if err != nil {
log.Err(err).Msg("failed to decode attachment")

View File

@@ -28,9 +28,9 @@ func generateOrPrint(ctrl *V1Controller, w http.ResponseWriter, r *http.Request,
_, err = w.Write([]byte("Printed!"))
return err
} else {
return labelmaker.GenerateLabel(w, &params, ctrl.config)
}
return labelmaker.GenerateLabel(w, &params, ctrl.config)
}
// HandleGetLocationLabel godoc

View File

@@ -14,13 +14,14 @@ import (
// HandleLocationTreeQuery godoc
//
// @Summary Get Locations Tree
// @Summary (Deprecated) Get Locations Tree
// @Tags Locations
// @Produce json
// @Param withItems query bool false "include items in response tree"
// @Success 200 {object} []repo.TreeItem
// @Router /v1/locations/tree [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationTreeQuery() errchain.HandlerFunc {
fn := func(r *http.Request, query repo.TreeQuery) ([]repo.TreeItem, error) {
auth := services.NewContext(r.Context())
@@ -32,13 +33,14 @@ func (ctrl *V1Controller) HandleLocationTreeQuery() errchain.HandlerFunc {
// HandleLocationGetAll godoc
//
// @Summary Get All Locations
// @Tags Locations
// @Produce json
// @Param filterChildren query bool false "Filter locations with parents"
// @Success 200 {object} []repo.LocationOutCount
// @Router /v1/locations [GET]
// @Security Bearer
// @Summary (Deprecated) Get All Locations
// @Tags Locations
// @Produce json
// @Param filterChildren query bool false "Filter locations with parents"
// @Success 200 {object} []repo.LocationOutCount
// @Router /v1/locations [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationGetAll() errchain.HandlerFunc {
fn := func(r *http.Request, q repo.LocationQuery) ([]repo.LocationOutCount, error) {
auth := services.NewContext(r.Context())
@@ -50,13 +52,14 @@ func (ctrl *V1Controller) HandleLocationGetAll() errchain.HandlerFunc {
// HandleLocationCreate godoc
//
// @Summary Create Location
// @Summary (Deprecated) Create Location
// @Tags Locations
// @Produce json
// @Param payload body repo.LocationCreate true "Location Data"
// @Success 200 {object} repo.LocationSummary
// @Router /v1/locations [POST]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationCreate() errchain.HandlerFunc {
fn := func(r *http.Request, createData repo.LocationCreate) (repo.LocationOut, error) {
auth := services.NewContext(r.Context())
@@ -68,13 +71,14 @@ func (ctrl *V1Controller) HandleLocationCreate() errchain.HandlerFunc {
// HandleLocationDelete godoc
//
// @Summary Delete Location
// @Summary (Deprecated) Delete Location
// @Tags Locations
// @Produce json
// @Param id path string true "Location ID"
// @Success 204
// @Router /v1/locations/{id} [DELETE]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationDelete() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID) (any, error) {
auth := services.NewContext(r.Context())
@@ -129,13 +133,14 @@ func (ctrl *V1Controller) GetLocationWithPrice(auth context.Context, gid uuid.UU
// HandleLocationGet godoc
//
// @Summary Get Location
// @Summary (Deprecated) Get Location
// @Tags Locations
// @Produce json
// @Param id path string true "Location ID"
// @Success 200 {object} repo.LocationOut
// @Router /v1/locations/{id} [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationGet() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID) (repo.LocationOut, error) {
auth := services.NewContext(r.Context())
@@ -149,7 +154,7 @@ func (ctrl *V1Controller) HandleLocationGet() errchain.HandlerFunc {
// HandleLocationUpdate godoc
//
// @Summary Update Location
// @Summary (Deprecated) Update Location
// @Tags Locations
// @Produce json
// @Param id path string true "Location ID"
@@ -157,6 +162,7 @@ func (ctrl *V1Controller) HandleLocationGet() errchain.HandlerFunc {
// @Success 200 {object} repo.LocationOut
// @Router /v1/locations/{id} [PUT]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleLocationUpdate() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID, body repo.LocationUpdate) (repo.LocationOut, error) {
auth := services.NewContext(r.Context())

View File

@@ -10,7 +10,7 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
)
// HandleMaintenanceLogGet godoc
// HandleMaintenanceItemsLogGet godoc
//
// @Summary Get Maintenance Log
// @Tags Item Maintenance
@@ -20,6 +20,26 @@ import (
// @Success 200 {array} repo.MaintenanceEntryWithDetails[]
// @Router /v1/items/{id}/maintenance [GET]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleMaintenanceItemsLogGet() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID, filters repo.MaintenanceFilters) ([]repo.MaintenanceEntryWithDetails, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.MaintEntry.GetMaintenanceByItemID(auth, auth.GID, ID, filters)
}
return adapters.QueryID("id", fn, http.StatusOK)
}
// HandleMaintenanceLogGet godoc
//
// @Summary Get Maintenance Log
// @Tags Item Maintenance
// @Produce json
// @Param id path string true "Item ID"
// @Param filters query repo.MaintenanceFilters false "which maintenance to retrieve"
// @Success 200 {array} repo.MaintenanceEntryWithDetails[]
// @Router /v1/entities/{id}/maintenance [GET]
// @Security Bearer
func (ctrl *V1Controller) HandleMaintenanceLogGet() errchain.HandlerFunc {
fn := func(r *http.Request, ID uuid.UUID, filters repo.MaintenanceFilters) ([]repo.MaintenanceEntryWithDetails, error) {
auth := services.NewContext(r.Context())
@@ -29,7 +49,7 @@ func (ctrl *V1Controller) HandleMaintenanceLogGet() errchain.HandlerFunc {
return adapters.QueryID("id", fn, http.StatusOK)
}
// HandleMaintenanceEntryCreate godoc
// HandleMaintenanceItemsEntryCreate godoc
//
// @Summary Create Maintenance Entry
// @Tags Item Maintenance
@@ -39,6 +59,26 @@ func (ctrl *V1Controller) HandleMaintenanceLogGet() errchain.HandlerFunc {
// @Success 201 {object} repo.MaintenanceEntry
// @Router /v1/items/{id}/maintenance [POST]
// @Security Bearer
// @Deprecated
func (ctrl *V1Controller) HandleMaintenanceItemsEntryCreate() errchain.HandlerFunc {
fn := func(r *http.Request, itemID uuid.UUID, body repo.MaintenanceEntryCreate) (repo.MaintenanceEntry, error) {
auth := services.NewContext(r.Context())
return ctrl.repo.MaintEntry.Create(auth, itemID, body)
}
return adapters.ActionID("id", fn, http.StatusCreated)
}
// HandleMaintenanceEntryCreate godoc
//
// @Summary Create Maintenance Entry
// @Tags Item Maintenance
// @Produce json
// @Param id path string true "Item ID"
// @Param payload body repo.MaintenanceEntryCreate true "Entry Data"
// @Success 201 {object} repo.MaintenanceEntry
// @Router /v1/entities/{id}/maintenance [POST]
// @Security Bearer
func (ctrl *V1Controller) HandleMaintenanceEntryCreate() errchain.HandlerFunc {
fn := func(r *http.Request, itemID uuid.UUID, body repo.MaintenanceEntryCreate) (repo.MaintenanceEntry, error) {
auth := services.NewContext(r.Context())

View File

@@ -1,9 +1,10 @@
package v1
import (
"net/http"
"github.com/hay-kot/httpkit/errchain"
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
"net/http"
)
// HandleBillOfMaterialsExport godoc

View File

@@ -109,6 +109,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Post("/actions/set-primary-photos", chain.ToHandlerFunc(v1Ctrl.HandleSetPrimaryPhotos(), userMW...))
r.Post("/actions/create-missing-thumbnails", chain.ToHandlerFunc(v1Ctrl.HandleCreateMissingThumbnails(), userMW...))
// TODO: Remove after some time
r.Get("/locations", chain.ToHandlerFunc(v1Ctrl.HandleLocationGetAll(), userMW...))
r.Post("/locations", chain.ToHandlerFunc(v1Ctrl.HandleLocationCreate(), userMW...))
r.Get("/locations/tree", chain.ToHandlerFunc(v1Ctrl.HandleLocationTreeQuery(), userMW...))
@@ -122,6 +123,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Put("/labels/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLabelUpdate(), userMW...))
r.Delete("/labels/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLabelDelete(), userMW...))
// Deprecated, TODO: Remove after some time
r.Get("/items", chain.ToHandlerFunc(v1Ctrl.HandleItemsGetAll(), userMW...))
r.Post("/items", chain.ToHandlerFunc(v1Ctrl.HandleItemsCreate(), userMW...))
r.Post("/items/import", chain.ToHandlerFunc(v1Ctrl.HandleItemsImport(), userMW...))
@@ -129,6 +131,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Get("/items/fields", chain.ToHandlerFunc(v1Ctrl.HandleGetAllCustomFieldNames(), userMW...))
r.Get("/items/fields/values", chain.ToHandlerFunc(v1Ctrl.HandleGetAllCustomFieldValues(), userMW...))
// Deprecated, TODO: Remove after some time
r.Get("/items/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemGet(), userMW...))
r.Get("/items/{id}/path", chain.ToHandlerFunc(v1Ctrl.HandleItemFullPath(), userMW...))
r.Put("/items/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemUpdate(), userMW...))
@@ -136,12 +139,28 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Delete("/items/{id}", chain.ToHandlerFunc(v1Ctrl.HandleItemDelete(), userMW...))
r.Post("/items/{id}/duplicate", chain.ToHandlerFunc(v1Ctrl.HandleItemDuplicate(), userMW...))
// Asset-Like endpoints
assetMW := []errchain.Middleware{
a.mwAuthToken,
a.mwRoles(RoleModeOr, authroles.RoleUser.String(), authroles.RoleAttachments.String()),
}
// Deprecated, TODO: Remove after some time
r.Get("/items/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentGet(), assetMW...))
r.Post("/items/{id}/attachments", chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentCreate(), userMW...))
r.Put("/items/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentUpdate(), userMW...))
r.Delete("/items/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentDelete(), userMW...))
r.Get("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceLogGet(), userMW...))
r.Post("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryCreate(), userMW...))
r.Get("/entities/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityAttachmentGet(), assetMW...))
r.Post("/entities/{id}/attachments", chain.ToHandlerFunc(v1Ctrl.HandleEntityAttachmentCreate(), userMW...))
r.Put("/entities/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityAttachmentUpdate(), userMW...))
r.Delete("/entities/{id}/attachments/{attachment_id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityAttachmentDelete(), userMW...))
// Deprecated, TODO: Remove after some time
r.Get("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceItemsLogGet(), userMW...))
r.Post("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceItemsEntryCreate(), userMW...))
r.Get("/entities/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceLogGet(), userMW...))
r.Post("/entities/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryCreate(), userMW...))
r.Get("/assets/{id}", chain.ToHandlerFunc(v1Ctrl.HandleAssetGet(), userMW...))
@@ -165,19 +184,9 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Delete("/notifiers/{id}", chain.ToHandlerFunc(v1Ctrl.HandleDeleteNotifier(), userMW...))
r.Post("/notifiers/test", chain.ToHandlerFunc(v1Ctrl.HandlerNotifierTest(), userMW...))
// Asset-Like endpoints
assetMW := []errchain.Middleware{
a.mwAuthToken,
a.mwRoles(RoleModeOr, authroles.RoleUser.String(), authroles.RoleAttachments.String()),
}
r.Get("/products/search-from-barcode", chain.ToHandlerFunc(v1Ctrl.HandleProductSearchFromBarcode(a.conf.Barcode), userMW...))
r.Get("/qrcode", chain.ToHandlerFunc(v1Ctrl.HandleGenerateQRCode(), assetMW...))
r.Get(
"/items/{id}/attachments/{attachment_id}",
chain.ToHandlerFunc(v1Ctrl.HandleItemAttachmentGet(), assetMW...),
)
// Labelmaker
r.Get("/labelmaker/location/{id}", chain.ToHandlerFunc(v1Ctrl.HandleGetLocationLabel(), userMW...))
@@ -187,6 +196,30 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
// Reporting Services
r.Get("/reporting/bill-of-materials", chain.ToHandlerFunc(v1Ctrl.HandleBillOfMaterialsExport(), userMW...))
// Entity Types
r.Get("/entitytype", chain.ToHandlerFunc(v1Ctrl.HandleEntityTypesGetAll(), userMW...))
r.Post("/entitytype", chain.ToHandlerFunc(v1Ctrl.HandleEntityTypeCreate(), userMW...))
r.Get("/entitytype/{id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityTypeGetOne(), userMW...))
r.Put("/entitytype/{id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityTypeUpdate(), userMW...))
r.Delete("/entitytype/{id}", chain.ToHandlerFunc(v1Ctrl.HandleEntityTypeDelete(), userMW...))
// TODO: Implement all of these endpoints for real
/*
r.Get("/entities")
r.Post("/entities")
r.Get("/entities/tree")
r.Post("/entities/import")
r.Get("/entities/export")
r.Get("/entities/fields")
r.Get("/entities/fields/values")
r.Get("/entities/{id}")
r.Get("/entities/{id}/path")
r.Put("/entities/{id}")
r.Patch("/entities/{id}")
r.Delete("/entities/{id}")
r.Post("/entities/{id}/duplicate")
*/
r.NotFound(http.NotFound)
})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@ toolchain go1.24.3
require (
entgo.io/ent v0.14.5
github.com/ardanlabs/conf/v3 v3.9.0
github.com/ardanlabs/conf/v3 v3.10.0
github.com/containrrr/shoutrrr v0.8.0
github.com/coreos/go-oidc/v3 v3.17.0
github.com/evanoberholster/imagemeta v0.3.1
@@ -15,7 +15,7 @@ require (
github.com/gen2brain/jpegxl v0.4.5
github.com/gen2brain/webp v0.5.5
github.com/go-chi/chi/v5 v5.2.3
github.com/go-playground/validator/v10 v10.28.0
github.com/go-playground/validator/v10 v10.29.0
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/google/uuid v1.6.0
@@ -40,10 +40,10 @@ require (
gocloud.dev/pubsub/kafkapubsub v0.44.0
gocloud.dev/pubsub/natspubsub v0.44.0
gocloud.dev/pubsub/rabbitpubsub v0.44.0
golang.org/x/crypto v0.45.0
golang.org/x/image v0.33.0
golang.org/x/oauth2 v0.33.0
golang.org/x/text v0.31.0
golang.org/x/crypto v0.46.0
golang.org/x/image v0.34.0
golang.org/x/oauth2 v0.34.0
golang.org/x/text v0.32.0
modernc.org/sqlite v1.40.1
)
@@ -111,15 +111,15 @@ require (
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-openapi/jsonpointer v0.22.3 // indirect
github.com/go-openapi/jsonreference v0.21.3 // indirect
github.com/go-openapi/spec v0.22.1 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/jsonreference v0.21.4 // indirect
github.com/go-openapi/spec v0.22.2 // indirect
github.com/go-openapi/swag/conv v0.25.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
@@ -181,27 +181,27 @@ require (
go.opentelemetry.io/contrib/detectors/gcp v1.38.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.39.0 // indirect
golang.org/x/tools v0.40.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/api v0.257.0 // indirect
google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2 // indirect
google.golang.org/grpc v1.77.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.67.1 // indirect
modernc.org/mathutil v1.7.1 // indirect

View File

@@ -81,6 +81,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/ardanlabs/conf/v3 v3.9.0 h1:aRBYHeD39/OkuaEXYIEoi4wvF3OnS7jUAPxXyLfEu20=
github.com/ardanlabs/conf/v3 v3.9.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk=
github.com/ardanlabs/conf/v3 v3.10.0 h1:qIrJ/WBmH/hFQ/IX4xH9LX9LzwK44T9aEOy78M+4S+0=
github.com/ardanlabs/conf/v3 v3.10.0/go.mod h1:XlL9P0quWP4m1weOVFmlezabinbZLI05niDof/+Ochk=
github.com/aws/aws-sdk-go-v2 v1.39.6 h1:2JrPCVgWJm7bm83BDwY5z8ietmeJUbh3O2ACnn+Xsqk=
github.com/aws/aws-sdk-go-v2 v1.39.6/go.mod h1:c9pm7VwuW0UPxAEYGyTmyurVcNrbF6Rt/wixFqDhcjE=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 h1:DHctwEM8P8iTXFxC/QK0MRjwEpWQeM9yzidCRjldUz0=
@@ -174,6 +176,8 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik=
github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gen2brain/avif v0.4.4 h1:Ga/ss7qcWWQm2bxFpnjYjhJsNfZrWs5RsyklgFjKRSE=
github.com/gen2brain/avif v0.4.4/go.mod h1:/XCaJcjZraQwKVhpu9aEd9aLOssYOawLvhMBtmHVGqk=
github.com/gen2brain/heic v0.4.6 h1:sNh3mfaEZLmDJnFc5WoLxCzh/wj5GwfJScPfvF5CNJE=
@@ -197,10 +201,16 @@ github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNP
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
github.com/go-openapi/jsonpointer v0.22.3 h1:dKMwfV4fmt6Ah90zloTbUKWMD+0he+12XYAsPotrkn8=
github.com/go-openapi/jsonpointer v0.22.3/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo=
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc=
github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4=
github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8=
github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4=
github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k=
github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA=
github.com/go-openapi/spec v0.22.2 h1:KEU4Fb+Lp1qg0V4MxrSCPv403ZjBl8Lx1a83gIPU8Qc=
github.com/go-openapi/spec v0.22.2/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs=
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4=
github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU=
@@ -230,6 +240,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
github.com/go-playground/validator/v10 v10.29.0 h1:lQlF5VNJWNlRbRZNeOIkWElR+1LL/OuHcc0Kp14w1xk=
github.com/go-playground/validator/v10 v10.29.0/go.mod h1:D6QxqeMlgIPuT02L66f2ccrZ7AGgHkzKmmTMZhk/Kc4=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
@@ -455,16 +467,26 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/X
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0 h1:6VjV6Et+1Hd2iLZEPtdV7vie80Yyqf7oikJLjQ/myi0=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.37.0/go.mod h1:u8hcp8ji5gaM/RfcOo8z9NMnf1pVLfVY7lBY2VOGuUU=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
@@ -485,13 +507,21 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY=
golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0=
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 h1:MDfG8Cvcqlt9XXrmEiD4epKn7VJHZO84hejP9Jmp0MM=
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8=
golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
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-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -501,12 +531,18 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo=
golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.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-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -522,6 +558,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@@ -531,6 +569,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -538,6 +578,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
@@ -552,10 +594,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 h1:
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2 h1:2I6GHUeJ/4shcDpoUlLs/2WPnhg7yJwvXtqcMJt9liA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251213004720-97cd9d5aeac2/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM=
google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

View File

@@ -2,11 +2,12 @@ package services
import (
"context"
"github.com/sysadminsmedia/homebox/backend/internal/sys/config"
"log"
"os"
"testing"
"github.com/sysadminsmedia/homebox/backend/internal/sys/config"
_ "github.com/mattn/go-sqlite3"
"github.com/sysadminsmedia/homebox/backend/internal/core/currencies"
"github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"

View File

@@ -2,12 +2,13 @@ package services
import (
"context"
"io"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
"io"
)
func (svc *ItemService) AttachmentPath(ctx context.Context, gid uuid.UUID, attachmentID uuid.UUID) (*ent.Attachment, error) {
@@ -19,7 +20,7 @@ func (svc *ItemService) AttachmentPath(ctx context.Context, gid uuid.UUID, attac
return attachment, nil
}
func (svc *ItemService) AttachmentUpdate(ctx Context, gid uuid.UUID, itemID uuid.UUID, data *repo.ItemAttachmentUpdate) (repo.ItemOut, error) {
func (svc *ItemService) AttachmentUpdate(ctx Context, gid uuid.UUID, itemID uuid.UUID, data *repo.EntityAttachmentUpdate) (repo.ItemOut, error) {
// Update Attachment
attachment, err := svc.repo.Attachments.Update(ctx, gid, data.ID, data)
if err != nil {
@@ -47,7 +48,7 @@ func (svc *ItemService) AttachmentAdd(ctx Context, itemID uuid.UUID, filename st
}
// Create the attachment
_, err = svc.repo.Attachments.Create(ctx, itemID, repo.ItemCreateAttachment{Title: filename, Content: file}, attachmentType, primary)
_, err = svc.repo.Attachments.Create(ctx, itemID, repo.EntityCreateAttachment{Title: filename, Content: file}, attachmentType, primary)
if err != nil {
log.Err(err).Msg("failed to create attachment")
return repo.ItemOut{}, err

View File

@@ -105,6 +105,12 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
}
}
log.Debug().Msg("creating default entity types")
err := svc.repos.EntityType.CreateDefaultEntityTypes(ctx, usr.GroupID)
if err != nil {
return repo.UserOut{}, err
}
log.Debug().Msg("creating default locations")
for _, location := range defaultLocations() {
_, err := svc.repos.Locations.Create(ctx, usr.GroupID, location)

View File

@@ -11,7 +11,7 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
)
// Attachment is the model entity for the Attachment schema.
@@ -37,14 +37,14 @@ type Attachment struct {
// The values are being populated by the AttachmentQuery when eager-loading is set.
Edges AttachmentEdges `json:"edges"`
attachment_thumbnail *uuid.UUID
item_attachments *uuid.UUID
entity_attachments *uuid.UUID
selectValues sql.SelectValues
}
// AttachmentEdges holds the relations/edges for other nodes in the graph.
type AttachmentEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// Thumbnail holds the value of the thumbnail edge.
Thumbnail *Attachment `json:"thumbnail,omitempty"`
// loadedTypes holds the information for reporting if a
@@ -52,15 +52,15 @@ type AttachmentEdges struct {
loadedTypes [2]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AttachmentEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e AttachmentEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// ThumbnailOrErr returns the Thumbnail value or an error if the edge
@@ -89,7 +89,7 @@ func (*Attachment) scanValues(columns []string) ([]any, error) {
values[i] = new(uuid.UUID)
case attachment.ForeignKeys[0]: // attachment_thumbnail
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case attachment.ForeignKeys[1]: // item_attachments
case attachment.ForeignKeys[1]: // entity_attachments
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -163,10 +163,10 @@ func (_m *Attachment) assignValues(columns []string, values []any) error {
}
case attachment.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field item_attachments", values[i])
return fmt.Errorf("unexpected type %T for field entity_attachments", values[i])
} else if value.Valid {
_m.item_attachments = new(uuid.UUID)
*_m.item_attachments = *value.S.(*uuid.UUID)
_m.entity_attachments = new(uuid.UUID)
*_m.entity_attachments = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -181,9 +181,9 @@ func (_m *Attachment) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the Attachment entity.
func (_m *Attachment) QueryItem() *ItemQuery {
return NewAttachmentClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the Attachment entity.
func (_m *Attachment) QueryEntity() *EntityQuery {
return NewAttachmentClient(_m.config).QueryEntity(_m)
}
// QueryThumbnail queries the "thumbnail" edge of the Attachment entity.

View File

@@ -30,19 +30,19 @@ const (
FieldPath = "path"
// FieldMimeType holds the string denoting the mime_type field in the database.
FieldMimeType = "mime_type"
// EdgeItem holds the string denoting the item edge name in mutations.
EdgeItem = "item"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// EdgeThumbnail holds the string denoting the thumbnail edge name in mutations.
EdgeThumbnail = "thumbnail"
// Table holds the table name of the attachment in the database.
Table = "attachments"
// ItemTable is the table that holds the item relation/edge.
ItemTable = "attachments"
// ItemInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemInverseTable = "items"
// ItemColumn is the table column denoting the item relation/edge.
ItemColumn = "item_attachments"
// EntityTable is the table that holds the entity relation/edge.
EntityTable = "attachments"
// EntityInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntityInverseTable = "entities"
// EntityColumn is the table column denoting the entity relation/edge.
EntityColumn = "entity_attachments"
// ThumbnailTable is the table that holds the thumbnail relation/edge.
ThumbnailTable = "attachments"
// ThumbnailColumn is the table column denoting the thumbnail relation/edge.
@@ -65,7 +65,7 @@ var Columns = []string{
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"attachment_thumbnail",
"item_attachments",
"entity_attachments",
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -175,10 +175,10 @@ func ByMimeType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMimeType, opts...).ToFunc()
}
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
}
}
@@ -188,11 +188,11 @@ func ByThumbnailField(field string, opts ...sql.OrderTermOption) OrderOption {
sqlgraph.OrderByNeighborTerms(s, newThumbnailStep(), sql.OrderByField(field, opts...))
}
}
func newItemStep() *sqlgraph.Step {
func newEntityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
}
func newThumbnailStep() *sqlgraph.Step {

View File

@@ -391,21 +391,21 @@ func MimeTypeContainsFold(v string) predicate.Attachment {
return predicate.Attachment(sql.FieldContainsFold(FieldMimeType, v))
}
// HasItem applies the HasEdge predicate on the "item" edge.
func HasItem() predicate.Attachment {
// HasEntity applies the HasEdge predicate on the "entity" edge.
func HasEntity() predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemWith applies the HasEdge predicate on the "item" edge with a given conditions (other predicates).
func HasItemWith(preds ...predicate.Item) predicate.Attachment {
// HasEntityWith applies the HasEdge predicate on the "entity" edge with a given conditions (other predicates).
func HasEntityWith(preds ...predicate.Entity) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) {
step := newItemStep()
step := newEntityStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
)
// AttachmentCreate is the builder for creating a Attachment entity.
@@ -134,23 +134,23 @@ func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate {
return _c
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_c *AttachmentCreate) SetItemID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetEntityID(id)
return _c
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_c *AttachmentCreate) SetNillableItemID(id *uuid.UUID) *AttachmentCreate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_c *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate {
if id != nil {
_c = _c.SetItemID(*id)
_c = _c.SetEntityID(*id)
}
return _c
}
// SetItem sets the "item" edge to the Item entity.
func (_c *AttachmentCreate) SetItem(v *Item) *AttachmentCreate {
return _c.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate {
return _c.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -332,21 +332,21 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
_node.MimeType = value
}
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.item_attachments = &nodes[0]
_node.entity_attachments = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ThumbnailIDs(); len(nodes) > 0 {

View File

@@ -13,7 +13,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -24,7 +24,7 @@ type AttachmentQuery struct {
order []attachment.OrderOption
inters []Interceptor
predicates []predicate.Attachment
withItem *ItemQuery
withEntity *EntityQuery
withThumbnail *AttachmentQuery
withFKs bool
// intermediate query (i.e. traversal path).
@@ -63,9 +63,9 @@ func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery {
return _q
}
// QueryItem chains the current query on the "item" edge.
func (_q *AttachmentQuery) QueryItem() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntity chains the current query on the "entity" edge.
func (_q *AttachmentQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -76,8 +76,8 @@ func (_q *AttachmentQuery) QueryItem() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(attachment.Table, attachment.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -299,7 +299,7 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery {
order: append([]attachment.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Attachment{}, _q.predicates...),
withItem: _q.withItem.Clone(),
withEntity: _q.withEntity.Clone(),
withThumbnail: _q.withThumbnail.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
@@ -307,14 +307,14 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery {
}
}
// WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntity tells the query-builder to eager-load the nodes that are connected to
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItem = query
_q.withEntity = query
return _q
}
@@ -409,11 +409,11 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withItem != nil,
_q.withEntity != nil,
_q.withThumbnail != nil,
}
)
if _q.withItem != nil || _q.withThumbnail != nil {
if _q.withEntity != nil || _q.withThumbnail != nil {
withFKs = true
}
if withFKs {
@@ -437,9 +437,9 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withItem; query != nil {
if err := _q.loadItem(ctx, query, nodes, nil,
func(n *Attachment, e *Item) { n.Edges.Item = e }); err != nil {
if query := _q.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != nil {
return nil, err
}
}
@@ -452,14 +452,14 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
return nodes, nil
}
func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Item)) error {
func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*Attachment)
for i := range nodes {
if nodes[i].item_attachments == nil {
if nodes[i].entity_attachments == nil {
continue
}
fk := *nodes[i].item_attachments
fk := *nodes[i].entity_attachments
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -468,7 +468,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
if len(ids) == 0 {
return nil
}
query.Where(item.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -476,7 +476,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "item_attachments" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "entity_attachments" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)

View File

@@ -13,7 +13,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -106,23 +106,23 @@ func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate {
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdate) SetItemID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableItemID(id *uuid.UUID) *AttachmentUpdate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdate) SetItem(v *Item) *AttachmentUpdate {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate {
return _u.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -149,9 +149,9 @@ func (_u *AttachmentUpdate) Mutation() *AttachmentMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdate) ClearItem() *AttachmentUpdate {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate {
_u.mutation.ClearEntity()
return _u
}
@@ -237,28 +237,28 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error)
if value, ok := _u.mutation.MimeType(); ok {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -391,23 +391,23 @@ func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateO
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdateOne) SetItemID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableItemID(id *uuid.UUID) *AttachmentUpdateOne {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) SetItem(v *Item) *AttachmentUpdateOne {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne {
return _u.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -434,9 +434,9 @@ func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) ClearItem() *AttachmentUpdateOne {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne {
_u.mutation.ClearEntity()
return _u
}
@@ -552,28 +552,28 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
if value, ok := _u.mutation.MimeType(); ok {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

File diff suppressed because it is too large Load Diff

View File

@@ -15,13 +15,13 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
@@ -89,13 +89,13 @@ func checkColumn(t, c string) error {
attachment.Table: attachment.ValidColumn,
authroles.Table: authroles.ValidColumn,
authtokens.Table: authtokens.ValidColumn,
entity.Table: entity.ValidColumn,
entityfield.Table: entityfield.ValidColumn,
entitytype.Table: entitytype.ValidColumn,
group.Table: group.ValidColumn,
groupinvitationtoken.Table: groupinvitationtoken.ValidColumn,
item.Table: item.ValidColumn,
itemfield.Table: itemfield.ValidColumn,
itemtemplate.Table: itemtemplate.ValidColumn,
label.Table: label.ValidColumn,
location.Table: location.ValidColumn,
maintenanceentry.Table: maintenanceentry.ValidColumn,
notifier.Table: notifier.ValidColumn,
templatefield.Table: templatefield.ValidColumn,

View File

@@ -10,13 +10,13 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
)
// Item is the model entity for the Item schema.
type Item struct {
// Entity is the model entity for the Entity schema.
type Entity struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -40,8 +40,8 @@ type Item struct {
Archived bool `json:"archived,omitempty"`
// AssetID holds the value of the "asset_id" field.
AssetID int `json:"asset_id,omitempty"`
// SyncChildItemsLocations holds the value of the "sync_child_items_locations" field.
SyncChildItemsLocations bool `json:"sync_child_items_locations,omitempty"`
// SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" field.
SyncChildEntitiesLocations bool `json:"sync_child_entities_locations,omitempty"`
// SerialNumber holds the value of the "serial_number" field.
SerialNumber string `json:"serial_number,omitempty"`
// ModelNumber holds the value of the "model_number" field.
@@ -69,40 +69,45 @@ type Item struct {
// SoldNotes holds the value of the "sold_notes" field.
SoldNotes string `json:"sold_notes,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ItemQuery when eager-loading is set.
Edges ItemEdges `json:"edges"`
group_items *uuid.UUID
item_children *uuid.UUID
location_items *uuid.UUID
selectValues sql.SelectValues
// The values are being populated by the EntityQuery when eager-loading is set.
Edges EntityEdges `json:"edges"`
entity_parent *uuid.UUID
entity_location *uuid.UUID
entity_type_entities *uuid.UUID
group_entities *uuid.UUID
selectValues sql.SelectValues
}
// ItemEdges holds the relations/edges for other nodes in the graph.
type ItemEdges struct {
// EntityEdges holds the relations/edges for other nodes in the graph.
type EntityEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Parent holds the value of the parent edge.
Parent *Item `json:"parent,omitempty"`
// Children holds the value of the children edge.
Children []*Item `json:"children,omitempty"`
Children []*Entity `json:"children,omitempty"`
// Parent holds the value of the parent edge.
Parent *Entity `json:"parent,omitempty"`
// Entity holds the value of the entity edge.
Entity []*Entity `json:"entity,omitempty"`
// Location holds the value of the location edge.
Location *Entity `json:"location,omitempty"`
// Label holds the value of the label edge.
Label []*Label `json:"label,omitempty"`
// Location holds the value of the location edge.
Location *Location `json:"location,omitempty"`
// Type holds the value of the type edge.
Type *EntityType `json:"type,omitempty"`
// Fields holds the value of the fields edge.
Fields []*ItemField `json:"fields,omitempty"`
Fields []*EntityField `json:"fields,omitempty"`
// MaintenanceEntries holds the value of the maintenance_entries edge.
MaintenanceEntries []*MaintenanceEntry `json:"maintenance_entries,omitempty"`
// Attachments holds the value of the attachments edge.
Attachments []*Attachment `json:"attachments,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [8]bool
loadedTypes [10]bool
}
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) GroupOrErr() (*Group, error) {
func (e EntityEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[0] {
@@ -111,50 +116,70 @@ func (e ItemEdges) GroupOrErr() (*Group, error) {
return nil, &NotLoadedError{edge: "group"}
}
// ParentOrErr returns the Parent value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) ParentOrErr() (*Item, error) {
if e.Parent != nil {
return e.Parent, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "parent"}
}
// ChildrenOrErr returns the Children value or an error if the edge
// was not loaded in eager-loading.
func (e ItemEdges) ChildrenOrErr() ([]*Item, error) {
if e.loadedTypes[2] {
func (e EntityEdges) ChildrenOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Children, nil
}
return nil, &NotLoadedError{edge: "children"}
}
// ParentOrErr returns the Parent value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) ParentOrErr() (*Entity, error) {
if e.Parent != nil {
return e.Parent, nil
} else if e.loadedTypes[2] {
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "parent"}
}
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) EntityOrErr() ([]*Entity, error) {
if e.loadedTypes[3] {
return e.Entity, nil
}
return nil, &NotLoadedError{edge: "entity"}
}
// LocationOrErr returns the Location value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) LocationOrErr() (*Entity, error) {
if e.Location != nil {
return e.Location, nil
} else if e.loadedTypes[4] {
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "location"}
}
// LabelOrErr returns the Label value or an error if the edge
// was not loaded in eager-loading.
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
if e.loadedTypes[3] {
func (e EntityEdges) LabelOrErr() ([]*Label, error) {
if e.loadedTypes[5] {
return e.Label, nil
}
return nil, &NotLoadedError{edge: "label"}
}
// LocationOrErr returns the Location value or an error if the edge
// TypeOrErr returns the Type value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemEdges) LocationOrErr() (*Location, error) {
if e.Location != nil {
return e.Location, nil
} else if e.loadedTypes[4] {
return nil, &NotFoundError{label: location.Label}
func (e EntityEdges) TypeOrErr() (*EntityType, error) {
if e.Type != nil {
return e.Type, nil
} else if e.loadedTypes[6] {
return nil, &NotFoundError{label: entitytype.Label}
}
return nil, &NotLoadedError{edge: "location"}
return nil, &NotLoadedError{edge: "type"}
}
// FieldsOrErr returns the Fields value or an error if the edge
// was not loaded in eager-loading.
func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) {
if e.loadedTypes[5] {
func (e EntityEdges) FieldsOrErr() ([]*EntityField, error) {
if e.loadedTypes[7] {
return e.Fields, nil
}
return nil, &NotLoadedError{edge: "fields"}
@@ -162,8 +187,8 @@ func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) {
// MaintenanceEntriesOrErr returns the MaintenanceEntries value or an error if the edge
// was not loaded in eager-loading.
func (e ItemEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
if e.loadedTypes[6] {
func (e EntityEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
if e.loadedTypes[8] {
return e.MaintenanceEntries, nil
}
return nil, &NotLoadedError{edge: "maintenance_entries"}
@@ -171,35 +196,37 @@ func (e ItemEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
// AttachmentsOrErr returns the Attachments value or an error if the edge
// was not loaded in eager-loading.
func (e ItemEdges) AttachmentsOrErr() ([]*Attachment, error) {
if e.loadedTypes[7] {
func (e EntityEdges) AttachmentsOrErr() ([]*Attachment, error) {
if e.loadedTypes[9] {
return e.Attachments, nil
}
return nil, &NotLoadedError{edge: "attachments"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Item) scanValues(columns []string) ([]any, error) {
func (*Entity) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case item.FieldInsured, item.FieldArchived, item.FieldSyncChildItemsLocations, item.FieldLifetimeWarranty:
case entity.FieldInsured, entity.FieldArchived, entity.FieldSyncChildEntitiesLocations, entity.FieldLifetimeWarranty:
values[i] = new(sql.NullBool)
case item.FieldPurchasePrice, item.FieldSoldPrice:
case entity.FieldPurchasePrice, entity.FieldSoldPrice:
values[i] = new(sql.NullFloat64)
case item.FieldQuantity, item.FieldAssetID:
case entity.FieldQuantity, entity.FieldAssetID:
values[i] = new(sql.NullInt64)
case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes:
case entity.FieldName, entity.FieldDescription, entity.FieldImportRef, entity.FieldNotes, entity.FieldSerialNumber, entity.FieldModelNumber, entity.FieldManufacturer, entity.FieldWarrantyDetails, entity.FieldPurchaseFrom, entity.FieldSoldTo, entity.FieldSoldNotes:
values[i] = new(sql.NullString)
case item.FieldCreatedAt, item.FieldUpdatedAt, item.FieldWarrantyExpires, item.FieldPurchaseTime, item.FieldSoldTime:
case entity.FieldCreatedAt, entity.FieldUpdatedAt, entity.FieldWarrantyExpires, entity.FieldPurchaseTime, entity.FieldSoldTime:
values[i] = new(sql.NullTime)
case item.FieldID:
case entity.FieldID:
values[i] = new(uuid.UUID)
case item.ForeignKeys[0]: // group_items
case entity.ForeignKeys[0]: // entity_parent
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case item.ForeignKeys[1]: // item_children
case entity.ForeignKeys[1]: // entity_location
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case item.ForeignKeys[2]: // location_items
case entity.ForeignKeys[2]: // entity_type_entities
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case entity.ForeignKeys[3]: // group_entities
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -209,183 +236,190 @@ func (*Item) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Item fields.
func (_m *Item) assignValues(columns []string, values []any) error {
// to the Entity fields.
func (_m *Entity) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case item.FieldID:
case entity.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case item.FieldCreatedAt:
case entity.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case item.FieldUpdatedAt:
case entity.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case item.FieldName:
case entity.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case item.FieldDescription:
case entity.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case item.FieldImportRef:
case entity.FieldImportRef:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field import_ref", values[i])
} else if value.Valid {
_m.ImportRef = value.String
}
case item.FieldNotes:
case entity.FieldNotes:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field notes", values[i])
} else if value.Valid {
_m.Notes = value.String
}
case item.FieldQuantity:
case entity.FieldQuantity:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field quantity", values[i])
} else if value.Valid {
_m.Quantity = int(value.Int64)
}
case item.FieldInsured:
case entity.FieldInsured:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field insured", values[i])
} else if value.Valid {
_m.Insured = value.Bool
}
case item.FieldArchived:
case entity.FieldArchived:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field archived", values[i])
} else if value.Valid {
_m.Archived = value.Bool
}
case item.FieldAssetID:
case entity.FieldAssetID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field asset_id", values[i])
} else if value.Valid {
_m.AssetID = int(value.Int64)
}
case item.FieldSyncChildItemsLocations:
case entity.FieldSyncChildEntitiesLocations:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field sync_child_items_locations", values[i])
return fmt.Errorf("unexpected type %T for field sync_child_entities_locations", values[i])
} else if value.Valid {
_m.SyncChildItemsLocations = value.Bool
_m.SyncChildEntitiesLocations = value.Bool
}
case item.FieldSerialNumber:
case entity.FieldSerialNumber:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field serial_number", values[i])
} else if value.Valid {
_m.SerialNumber = value.String
}
case item.FieldModelNumber:
case entity.FieldModelNumber:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field model_number", values[i])
} else if value.Valid {
_m.ModelNumber = value.String
}
case item.FieldManufacturer:
case entity.FieldManufacturer:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field manufacturer", values[i])
} else if value.Valid {
_m.Manufacturer = value.String
}
case item.FieldLifetimeWarranty:
case entity.FieldLifetimeWarranty:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field lifetime_warranty", values[i])
} else if value.Valid {
_m.LifetimeWarranty = value.Bool
}
case item.FieldWarrantyExpires:
case entity.FieldWarrantyExpires:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field warranty_expires", values[i])
} else if value.Valid {
_m.WarrantyExpires = value.Time
}
case item.FieldWarrantyDetails:
case entity.FieldWarrantyDetails:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field warranty_details", values[i])
} else if value.Valid {
_m.WarrantyDetails = value.String
}
case item.FieldPurchaseTime:
case entity.FieldPurchaseTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field purchase_time", values[i])
} else if value.Valid {
_m.PurchaseTime = value.Time
}
case item.FieldPurchaseFrom:
case entity.FieldPurchaseFrom:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field purchase_from", values[i])
} else if value.Valid {
_m.PurchaseFrom = value.String
}
case item.FieldPurchasePrice:
case entity.FieldPurchasePrice:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field purchase_price", values[i])
} else if value.Valid {
_m.PurchasePrice = value.Float64
}
case item.FieldSoldTime:
case entity.FieldSoldTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field sold_time", values[i])
} else if value.Valid {
_m.SoldTime = value.Time
}
case item.FieldSoldTo:
case entity.FieldSoldTo:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sold_to", values[i])
} else if value.Valid {
_m.SoldTo = value.String
}
case item.FieldSoldPrice:
case entity.FieldSoldPrice:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field sold_price", values[i])
} else if value.Valid {
_m.SoldPrice = value.Float64
}
case item.FieldSoldNotes:
case entity.FieldSoldNotes:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sold_notes", values[i])
} else if value.Valid {
_m.SoldNotes = value.String
}
case item.ForeignKeys[0]:
case entity.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field group_items", values[i])
return fmt.Errorf("unexpected type %T for field entity_parent", values[i])
} else if value.Valid {
_m.group_items = new(uuid.UUID)
*_m.group_items = *value.S.(*uuid.UUID)
_m.entity_parent = new(uuid.UUID)
*_m.entity_parent = *value.S.(*uuid.UUID)
}
case item.ForeignKeys[1]:
case entity.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field item_children", values[i])
return fmt.Errorf("unexpected type %T for field entity_location", values[i])
} else if value.Valid {
_m.item_children = new(uuid.UUID)
*_m.item_children = *value.S.(*uuid.UUID)
_m.entity_location = new(uuid.UUID)
*_m.entity_location = *value.S.(*uuid.UUID)
}
case item.ForeignKeys[2]:
case entity.ForeignKeys[2]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field location_items", values[i])
return fmt.Errorf("unexpected type %T for field entity_type_entities", values[i])
} else if value.Valid {
_m.location_items = new(uuid.UUID)
*_m.location_items = *value.S.(*uuid.UUID)
_m.entity_type_entities = new(uuid.UUID)
*_m.entity_type_entities = *value.S.(*uuid.UUID)
}
case entity.ForeignKeys[3]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field group_entities", values[i])
} else if value.Valid {
_m.group_entities = new(uuid.UUID)
*_m.group_entities = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -394,74 +428,84 @@ func (_m *Item) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Item.
// Value returns the ent.Value that was dynamically selected and assigned to the Entity.
// This includes values selected through modifiers, order, etc.
func (_m *Item) Value(name string) (ent.Value, error) {
func (_m *Entity) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroup queries the "group" edge of the Item entity.
func (_m *Item) QueryGroup() *GroupQuery {
return NewItemClient(_m.config).QueryGroup(_m)
// QueryGroup queries the "group" edge of the Entity entity.
func (_m *Entity) QueryGroup() *GroupQuery {
return NewEntityClient(_m.config).QueryGroup(_m)
}
// QueryParent queries the "parent" edge of the Item entity.
func (_m *Item) QueryParent() *ItemQuery {
return NewItemClient(_m.config).QueryParent(_m)
// QueryChildren queries the "children" edge of the Entity entity.
func (_m *Entity) QueryChildren() *EntityQuery {
return NewEntityClient(_m.config).QueryChildren(_m)
}
// QueryChildren queries the "children" edge of the Item entity.
func (_m *Item) QueryChildren() *ItemQuery {
return NewItemClient(_m.config).QueryChildren(_m)
// QueryParent queries the "parent" edge of the Entity entity.
func (_m *Entity) QueryParent() *EntityQuery {
return NewEntityClient(_m.config).QueryParent(_m)
}
// QueryLabel queries the "label" edge of the Item entity.
func (_m *Item) QueryLabel() *LabelQuery {
return NewItemClient(_m.config).QueryLabel(_m)
// QueryEntity queries the "entity" edge of the Entity entity.
func (_m *Entity) QueryEntity() *EntityQuery {
return NewEntityClient(_m.config).QueryEntity(_m)
}
// QueryLocation queries the "location" edge of the Item entity.
func (_m *Item) QueryLocation() *LocationQuery {
return NewItemClient(_m.config).QueryLocation(_m)
// QueryLocation queries the "location" edge of the Entity entity.
func (_m *Entity) QueryLocation() *EntityQuery {
return NewEntityClient(_m.config).QueryLocation(_m)
}
// QueryFields queries the "fields" edge of the Item entity.
func (_m *Item) QueryFields() *ItemFieldQuery {
return NewItemClient(_m.config).QueryFields(_m)
// QueryLabel queries the "label" edge of the Entity entity.
func (_m *Entity) QueryLabel() *LabelQuery {
return NewEntityClient(_m.config).QueryLabel(_m)
}
// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Item entity.
func (_m *Item) QueryMaintenanceEntries() *MaintenanceEntryQuery {
return NewItemClient(_m.config).QueryMaintenanceEntries(_m)
// QueryType queries the "type" edge of the Entity entity.
func (_m *Entity) QueryType() *EntityTypeQuery {
return NewEntityClient(_m.config).QueryType(_m)
}
// QueryAttachments queries the "attachments" edge of the Item entity.
func (_m *Item) QueryAttachments() *AttachmentQuery {
return NewItemClient(_m.config).QueryAttachments(_m)
// QueryFields queries the "fields" edge of the Entity entity.
func (_m *Entity) QueryFields() *EntityFieldQuery {
return NewEntityClient(_m.config).QueryFields(_m)
}
// Update returns a builder for updating this Item.
// Note that you need to call Item.Unwrap() before calling this method if this Item
// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Entity entity.
func (_m *Entity) QueryMaintenanceEntries() *MaintenanceEntryQuery {
return NewEntityClient(_m.config).QueryMaintenanceEntries(_m)
}
// QueryAttachments queries the "attachments" edge of the Entity entity.
func (_m *Entity) QueryAttachments() *AttachmentQuery {
return NewEntityClient(_m.config).QueryAttachments(_m)
}
// Update returns a builder for updating this Entity.
// Note that you need to call Entity.Unwrap() before calling this method if this Entity
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Item) Update() *ItemUpdateOne {
return NewItemClient(_m.config).UpdateOne(_m)
func (_m *Entity) Update() *EntityUpdateOne {
return NewEntityClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Item entity that was returned from a transaction after it was closed,
// Unwrap unwraps the Entity entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *Item) Unwrap() *Item {
func (_m *Entity) Unwrap() *Entity {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Item is not a transactional entity")
panic("ent: Entity is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Item) String() string {
func (_m *Entity) String() string {
var builder strings.Builder
builder.WriteString("Item(")
builder.WriteString("Entity(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -493,8 +537,8 @@ func (_m *Item) String() string {
builder.WriteString("asset_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AssetID))
builder.WriteString(", ")
builder.WriteString("sync_child_items_locations=")
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildItemsLocations))
builder.WriteString("sync_child_entities_locations=")
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildEntitiesLocations))
builder.WriteString(", ")
builder.WriteString("serial_number=")
builder.WriteString(_m.SerialNumber)
@@ -538,5 +582,5 @@ func (_m *Item) String() string {
return builder.String()
}
// Items is a parsable slice of Item.
type Items []*Item
// Entities is a parsable slice of Entity.
type Entities []*Entity

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package item
package entity
import (
"time"
@@ -11,8 +11,8 @@ import (
)
const (
// Label holds the string label denoting the item type in the database.
Label = "item"
// Label holds the string label denoting the entity type in the database.
Label = "entity"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
@@ -35,8 +35,8 @@ const (
FieldArchived = "archived"
// FieldAssetID holds the string denoting the asset_id field in the database.
FieldAssetID = "asset_id"
// FieldSyncChildItemsLocations holds the string denoting the sync_child_items_locations field in the database.
FieldSyncChildItemsLocations = "sync_child_items_locations"
// FieldSyncChildEntitiesLocations holds the string denoting the sync_child_entities_locations field in the database.
FieldSyncChildEntitiesLocations = "sync_child_entities_locations"
// FieldSerialNumber holds the string denoting the serial_number field in the database.
FieldSerialNumber = "serial_number"
// FieldModelNumber holds the string denoting the model_number field in the database.
@@ -65,73 +65,85 @@ const (
FieldSoldNotes = "sold_notes"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// EdgeLabel holds the string denoting the label edge name in mutations.
EdgeLabel = "label"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// EdgeLocation holds the string denoting the location edge name in mutations.
EdgeLocation = "location"
// EdgeLabel holds the string denoting the label edge name in mutations.
EdgeLabel = "label"
// EdgeType holds the string denoting the type edge name in mutations.
EdgeType = "type"
// EdgeFields holds the string denoting the fields edge name in mutations.
EdgeFields = "fields"
// EdgeMaintenanceEntries holds the string denoting the maintenance_entries edge name in mutations.
EdgeMaintenanceEntries = "maintenance_entries"
// EdgeAttachments holds the string denoting the attachments edge name in mutations.
EdgeAttachments = "attachments"
// Table holds the table name of the item in the database.
Table = "items"
// Table holds the table name of the entity in the database.
Table = "entities"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "items"
GroupTable = "entities"
// GroupInverseTable is the table name for the Group entity.
// It exists in this package in order to avoid circular dependency with the "group" package.
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
GroupColumn = "group_items"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "items"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "item_children"
GroupColumn = "group_entities"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "items"
ChildrenTable = "entities"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "item_children"
ChildrenColumn = "entity_parent"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "entities"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "entity_parent"
// EntityTable is the table that holds the entity relation/edge.
EntityTable = "entities"
// EntityColumn is the table column denoting the entity relation/edge.
EntityColumn = "entity_location"
// LocationTable is the table that holds the location relation/edge.
LocationTable = "entities"
// LocationColumn is the table column denoting the location relation/edge.
LocationColumn = "entity_location"
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
LabelTable = "label_items"
LabelTable = "label_entities"
// LabelInverseTable is the table name for the Label entity.
// It exists in this package in order to avoid circular dependency with the "label" package.
LabelInverseTable = "labels"
// LocationTable is the table that holds the location relation/edge.
LocationTable = "items"
// LocationInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationInverseTable = "locations"
// LocationColumn is the table column denoting the location relation/edge.
LocationColumn = "location_items"
// TypeTable is the table that holds the type relation/edge.
TypeTable = "entities"
// TypeInverseTable is the table name for the EntityType entity.
// It exists in this package in order to avoid circular dependency with the "entitytype" package.
TypeInverseTable = "entity_types"
// TypeColumn is the table column denoting the type relation/edge.
TypeColumn = "entity_type_entities"
// FieldsTable is the table that holds the fields relation/edge.
FieldsTable = "item_fields"
// FieldsInverseTable is the table name for the ItemField entity.
// It exists in this package in order to avoid circular dependency with the "itemfield" package.
FieldsInverseTable = "item_fields"
FieldsTable = "entity_fields"
// FieldsInverseTable is the table name for the EntityField entity.
// It exists in this package in order to avoid circular dependency with the "entityfield" package.
FieldsInverseTable = "entity_fields"
// FieldsColumn is the table column denoting the fields relation/edge.
FieldsColumn = "item_fields"
FieldsColumn = "entity_fields"
// MaintenanceEntriesTable is the table that holds the maintenance_entries relation/edge.
MaintenanceEntriesTable = "maintenance_entries"
// MaintenanceEntriesInverseTable is the table name for the MaintenanceEntry entity.
// It exists in this package in order to avoid circular dependency with the "maintenanceentry" package.
MaintenanceEntriesInverseTable = "maintenance_entries"
// MaintenanceEntriesColumn is the table column denoting the maintenance_entries relation/edge.
MaintenanceEntriesColumn = "item_id"
MaintenanceEntriesColumn = "entity_id"
// AttachmentsTable is the table that holds the attachments relation/edge.
AttachmentsTable = "attachments"
// AttachmentsInverseTable is the table name for the Attachment entity.
// It exists in this package in order to avoid circular dependency with the "attachment" package.
AttachmentsInverseTable = "attachments"
// AttachmentsColumn is the table column denoting the attachments relation/edge.
AttachmentsColumn = "item_attachments"
AttachmentsColumn = "entity_attachments"
)
// Columns holds all SQL columns for item fields.
// Columns holds all SQL columns for entity fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
@@ -144,7 +156,7 @@ var Columns = []string{
FieldInsured,
FieldArchived,
FieldAssetID,
FieldSyncChildItemsLocations,
FieldSyncChildEntitiesLocations,
FieldSerialNumber,
FieldModelNumber,
FieldManufacturer,
@@ -160,18 +172,19 @@ var Columns = []string{
FieldSoldNotes,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "items"
// ForeignKeys holds the SQL foreign-keys that are owned by the "entities"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"group_items",
"item_children",
"location_items",
"entity_parent",
"entity_location",
"entity_type_entities",
"group_entities",
}
var (
// LabelPrimaryKey and LabelColumn2 are the table columns denoting the
// primary key for the label relation (M2M).
LabelPrimaryKey = []string{"label_id", "item_id"}
LabelPrimaryKey = []string{"label_id", "entity_id"}
)
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -212,8 +225,8 @@ var (
DefaultArchived bool
// DefaultAssetID holds the default value on creation for the "asset_id" field.
DefaultAssetID int
// DefaultSyncChildItemsLocations holds the default value on creation for the "sync_child_items_locations" field.
DefaultSyncChildItemsLocations bool
// DefaultSyncChildEntitiesLocations holds the default value on creation for the "sync_child_entities_locations" field.
DefaultSyncChildEntitiesLocations bool
// SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
SerialNumberValidator func(string) error
// ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
@@ -234,7 +247,7 @@ var (
DefaultID func() uuid.UUID
)
// OrderOption defines the ordering options for the Item queries.
// OrderOption defines the ordering options for the Entity queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
@@ -292,9 +305,9 @@ func ByAssetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAssetID, opts...).ToFunc()
}
// BySyncChildItemsLocations orders the results by the sync_child_items_locations field.
func BySyncChildItemsLocations(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSyncChildItemsLocations, opts...).ToFunc()
// BySyncChildEntitiesLocations orders the results by the sync_child_entities_locations field.
func BySyncChildEntitiesLocations(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSyncChildEntitiesLocations, opts...).ToFunc()
}
// BySerialNumber orders the results by the serial_number field.
@@ -369,13 +382,6 @@ func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
}
}
// ByParentField orders the results by parent field.
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
}
}
// ByChildrenCount orders the results by children count.
func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -390,6 +396,34 @@ func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByParentField orders the results by parent field.
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
}
}
// ByEntityCount orders the results by entity count.
func ByEntityCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEntityStep(), opts...)
}
}
// ByEntity orders the results by entity terms.
func ByEntity(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByLocationField orders the results by location field.
func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
}
}
// ByLabelCount orders the results by label count.
func ByLabelCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -404,10 +438,10 @@ func ByLabel(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByLocationField orders the results by location field.
func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByTypeField orders the results by type field.
func ByTypeField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newTypeStep(), sql.OrderByField(field, opts...))
}
}
@@ -459,18 +493,32 @@ func newGroupStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newChildrenStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
sqlgraph.Edge(sqlgraph.O2M, true, ChildrenTable, ChildrenColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, ParentTable, ParentColumn),
)
}
func newEntityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, EntityTable, EntityColumn),
)
}
func newLocationStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, LocationTable, LocationColumn),
)
}
func newLabelStep() *sqlgraph.Step {
@@ -480,11 +528,11 @@ func newLabelStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
)
}
func newLocationStep() *sqlgraph.Step {
func newTypeStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LocationInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, LocationTable, LocationColumn),
sqlgraph.To(TypeInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, TypeTable, TypeColumn),
)
}
func newFieldsStep() *sqlgraph.Step {

1667
backend/internal/data/ent/entity/where.go generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -8,30 +8,30 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ItemDelete is the builder for deleting a Item entity.
type ItemDelete struct {
// EntityDelete is the builder for deleting a Entity entity.
type EntityDelete struct {
config
hooks []Hook
mutation *ItemMutation
mutation *EntityMutation
}
// Where appends a list predicates to the ItemDelete builder.
func (_d *ItemDelete) Where(ps ...predicate.Item) *ItemDelete {
// Where appends a list predicates to the EntityDelete builder.
func (_d *EntityDelete) Where(ps ...predicate.Entity) *EntityDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *ItemDelete) Exec(ctx context.Context) (int, error) {
func (_d *EntityDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *ItemDelete) ExecX(ctx context.Context) int {
func (_d *EntityDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
@@ -39,8 +39,8 @@ func (_d *ItemDelete) ExecX(ctx context.Context) int {
return n
}
func (_d *ItemDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
func (_d *EntityDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(entity.Table, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -56,32 +56,32 @@ func (_d *ItemDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err
}
// ItemDeleteOne is the builder for deleting a single Item entity.
type ItemDeleteOne struct {
_d *ItemDelete
// EntityDeleteOne is the builder for deleting a single Entity entity.
type EntityDeleteOne struct {
_d *EntityDelete
}
// Where appends a list predicates to the ItemDelete builder.
func (_d *ItemDeleteOne) Where(ps ...predicate.Item) *ItemDeleteOne {
// Where appends a list predicates to the EntityDelete builder.
func (_d *EntityDeleteOne) Where(ps ...predicate.Entity) *EntityDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *ItemDeleteOne) Exec(ctx context.Context) error {
func (_d *EntityDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{item.Label}
return &NotFoundError{entity.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *ItemDeleteOne) ExecX(ctx context.Context) {
func (_d *EntityDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -2,25 +2,25 @@ package ent
import (
"entgo.io/ent/dialect/sql"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/pkgs/textutils"
)
// AccentInsensitiveContains creates a predicate that performs accent-insensitive text search.
// It normalizes both the database field value and the search value for comparison.
func AccentInsensitiveContains(field string, searchValue string) predicate.Item {
func AccentInsensitiveContains(field string, searchValue string) predicate.Entity {
if searchValue == "" {
return predicate.Item(func(s *sql.Selector) {
return func(s *sql.Selector) {
// Return a predicate that never matches if search is empty
s.Where(sql.False())
})
}
}
// Normalize the search value
normalizedSearch := textutils.NormalizeSearchQuery(searchValue)
return predicate.Item(func(s *sql.Selector) {
return func(s *sql.Selector) {
dialect := s.Dialect()
switch dialect {
@@ -50,7 +50,7 @@ func AccentInsensitiveContains(field string, searchValue string) predicate.Item
"%"+normalizedSearch+"%",
))
}
})
}
}
// buildSQLiteNormalizeExpression creates a SQLite expression to normalize accented characters
@@ -90,31 +90,31 @@ func buildGenericNormalizeExpression(fieldExpr string) string {
}
// ItemNameAccentInsensitiveContains creates an accent-insensitive search predicate for the item name field.
func ItemNameAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldName, value)
func ItemNameAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldName, value)
}
// ItemDescriptionAccentInsensitiveContains creates an accent-insensitive search predicate for the item description field.
func ItemDescriptionAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldDescription, value)
func ItemDescriptionAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldDescription, value)
}
// ItemSerialNumberAccentInsensitiveContains creates an accent-insensitive search predicate for the item serial number field.
func ItemSerialNumberAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldSerialNumber, value)
func ItemSerialNumberAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldSerialNumber, value)
}
// ItemModelNumberAccentInsensitiveContains creates an accent-insensitive search predicate for the item model number field.
func ItemModelNumberAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldModelNumber, value)
func ItemModelNumberAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldModelNumber, value)
}
// ItemManufacturerAccentInsensitiveContains creates an accent-insensitive search predicate for the item manufacturer field.
func ItemManufacturerAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldManufacturer, value)
func ItemManufacturerAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldManufacturer, value)
}
// ItemNotesAccentInsensitiveContains creates an accent-insensitive search predicate for the item notes field.
func ItemNotesAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldNotes, value)
func ItemNotesAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldNotes, value)
}

View File

@@ -10,12 +10,12 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
)
// ItemField is the model entity for the ItemField schema.
type ItemField struct {
// EntityField is the model entity for the EntityField schema.
type EntityField struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -28,7 +28,7 @@ type ItemField struct {
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Type holds the value of the "type" field.
Type itemfield.Type `json:"type,omitempty"`
Type entityfield.Type `json:"type,omitempty"`
// TextValue holds the value of the "text_value" field.
TextValue string `json:"text_value,omitempty"`
// NumberValue holds the value of the "number_value" field.
@@ -38,48 +38,48 @@ type ItemField struct {
// TimeValue holds the value of the "time_value" field.
TimeValue time.Time `json:"time_value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ItemFieldQuery when eager-loading is set.
Edges ItemFieldEdges `json:"edges"`
item_fields *uuid.UUID
selectValues sql.SelectValues
// The values are being populated by the EntityFieldQuery when eager-loading is set.
Edges EntityFieldEdges `json:"edges"`
entity_fields *uuid.UUID
selectValues sql.SelectValues
}
// ItemFieldEdges holds the relations/edges for other nodes in the graph.
type ItemFieldEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// EntityFieldEdges holds the relations/edges for other nodes in the graph.
type EntityFieldEdges struct {
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemFieldEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e EntityFieldEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ItemField) scanValues(columns []string) ([]any, error) {
func (*EntityField) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case itemfield.FieldBooleanValue:
case entityfield.FieldBooleanValue:
values[i] = new(sql.NullBool)
case itemfield.FieldNumberValue:
case entityfield.FieldNumberValue:
values[i] = new(sql.NullInt64)
case itemfield.FieldName, itemfield.FieldDescription, itemfield.FieldType, itemfield.FieldTextValue:
case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue:
values[i] = new(sql.NullString)
case itemfield.FieldCreatedAt, itemfield.FieldUpdatedAt, itemfield.FieldTimeValue:
case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue:
values[i] = new(sql.NullTime)
case itemfield.FieldID:
case entityfield.FieldID:
values[i] = new(uuid.UUID)
case itemfield.ForeignKeys[0]: // item_fields
case entityfield.ForeignKeys[0]: // entity_fields
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -89,79 +89,79 @@ func (*ItemField) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ItemField fields.
func (_m *ItemField) assignValues(columns []string, values []any) error {
// to the EntityField fields.
func (_m *EntityField) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case itemfield.FieldID:
case entityfield.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case itemfield.FieldCreatedAt:
case entityfield.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case itemfield.FieldUpdatedAt:
case entityfield.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case itemfield.FieldName:
case entityfield.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case itemfield.FieldDescription:
case entityfield.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case itemfield.FieldType:
case entityfield.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = itemfield.Type(value.String)
_m.Type = entityfield.Type(value.String)
}
case itemfield.FieldTextValue:
case entityfield.FieldTextValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field text_value", values[i])
} else if value.Valid {
_m.TextValue = value.String
}
case itemfield.FieldNumberValue:
case entityfield.FieldNumberValue:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field number_value", values[i])
} else if value.Valid {
_m.NumberValue = int(value.Int64)
}
case itemfield.FieldBooleanValue:
case entityfield.FieldBooleanValue:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field boolean_value", values[i])
} else if value.Valid {
_m.BooleanValue = value.Bool
}
case itemfield.FieldTimeValue:
case entityfield.FieldTimeValue:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field time_value", values[i])
} else if value.Valid {
_m.TimeValue = value.Time
}
case itemfield.ForeignKeys[0]:
case entityfield.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field item_fields", values[i])
return fmt.Errorf("unexpected type %T for field entity_fields", values[i])
} else if value.Valid {
_m.item_fields = new(uuid.UUID)
*_m.item_fields = *value.S.(*uuid.UUID)
_m.entity_fields = new(uuid.UUID)
*_m.entity_fields = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -170,39 +170,39 @@ func (_m *ItemField) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ItemField.
// Value returns the ent.Value that was dynamically selected and assigned to the EntityField.
// This includes values selected through modifiers, order, etc.
func (_m *ItemField) Value(name string) (ent.Value, error) {
func (_m *EntityField) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the ItemField entity.
func (_m *ItemField) QueryItem() *ItemQuery {
return NewItemFieldClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the EntityField entity.
func (_m *EntityField) QueryEntity() *EntityQuery {
return NewEntityFieldClient(_m.config).QueryEntity(_m)
}
// Update returns a builder for updating this ItemField.
// Note that you need to call ItemField.Unwrap() before calling this method if this ItemField
// Update returns a builder for updating this EntityField.
// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *ItemField) Update() *ItemFieldUpdateOne {
return NewItemFieldClient(_m.config).UpdateOne(_m)
func (_m *EntityField) Update() *EntityFieldUpdateOne {
return NewEntityFieldClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the ItemField entity that was returned from a transaction after it was closed,
// Unwrap unwraps the EntityField entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *ItemField) Unwrap() *ItemField {
func (_m *EntityField) Unwrap() *EntityField {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: ItemField is not a transactional entity")
panic("ent: EntityField is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *ItemField) String() string {
func (_m *EntityField) String() string {
var builder strings.Builder
builder.WriteString("ItemField(")
builder.WriteString("EntityField(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -234,5 +234,5 @@ func (_m *ItemField) String() string {
return builder.String()
}
// ItemFields is a parsable slice of ItemField.
type ItemFields []*ItemField
// EntityFields is a parsable slice of EntityField.
type EntityFields []*EntityField

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package itemfield
package entityfield
import (
"fmt"
@@ -12,8 +12,8 @@ import (
)
const (
// Label holds the string label denoting the itemfield type in the database.
Label = "item_field"
// Label holds the string label denoting the entityfield type in the database.
Label = "entity_field"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
@@ -34,20 +34,20 @@ const (
FieldBooleanValue = "boolean_value"
// FieldTimeValue holds the string denoting the time_value field in the database.
FieldTimeValue = "time_value"
// EdgeItem holds the string denoting the item edge name in mutations.
EdgeItem = "item"
// Table holds the table name of the itemfield in the database.
Table = "item_fields"
// ItemTable is the table that holds the item relation/edge.
ItemTable = "item_fields"
// ItemInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemInverseTable = "items"
// ItemColumn is the table column denoting the item relation/edge.
ItemColumn = "item_fields"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// Table holds the table name of the entityfield in the database.
Table = "entity_fields"
// EntityTable is the table that holds the entity relation/edge.
EntityTable = "entity_fields"
// EntityInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntityInverseTable = "entities"
// EntityColumn is the table column denoting the entity relation/edge.
EntityColumn = "entity_fields"
)
// Columns holds all SQL columns for itemfield fields.
// Columns holds all SQL columns for entityfield fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
@@ -61,10 +61,10 @@ var Columns = []string{
FieldTimeValue,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "item_fields"
// ForeignKeys holds the SQL foreign-keys that are owned by the "entity_fields"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"item_fields",
"entity_fields",
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -124,11 +124,11 @@ func TypeValidator(_type Type) error {
case TypeText, TypeNumber, TypeBoolean, TypeTime:
return nil
default:
return fmt.Errorf("itemfield: invalid enum value for type field: %q", _type)
return fmt.Errorf("entityfield: invalid enum value for type field: %q", _type)
}
}
// OrderOption defines the ordering options for the ItemField queries.
// OrderOption defines the ordering options for the EntityField queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
@@ -181,16 +181,16 @@ func ByTimeValue(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTimeValue, opts...).ToFunc()
}
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
}
}
func newItemStep() *sqlgraph.Step {
func newEntityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
}

View File

@@ -0,0 +1,550 @@
// Code generated by ent, DO NOT EDIT.
package entityfield
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldUpdatedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldName, v))
}
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldDescription, v))
}
// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ.
func TextValue(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldTextValue, v))
}
// NumberValue applies equality check predicate on the "number_value" field. It's identical to NumberValueEQ.
func NumberValue(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldNumberValue, v))
}
// BooleanValue applies equality check predicate on the "boolean_value" field. It's identical to BooleanValueEQ.
func BooleanValue(v bool) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldBooleanValue, v))
}
// TimeValue applies equality check predicate on the "time_value" field. It's identical to TimeValueEQ.
func TimeValue(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldTimeValue, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldUpdatedAt, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContainsFold(FieldName, v))
}
// DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldDescription, v))
}
// DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldDescription, v))
}
// DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldDescription, vs...))
}
// DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldDescription, vs...))
}
// DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldDescription, v))
}
// DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldDescription, v))
}
// DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldDescription, v))
}
// DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldDescription, v))
}
// DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContains(FieldDescription, v))
}
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasPrefix(FieldDescription, v))
}
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasSuffix(FieldDescription, v))
}
// DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.EntityField {
return predicate.EntityField(sql.FieldIsNull(FieldDescription))
}
// DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.EntityField {
return predicate.EntityField(sql.FieldNotNull(FieldDescription))
}
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEqualFold(FieldDescription, v))
}
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContainsFold(FieldDescription, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldType, vs...))
}
// TextValueEQ applies the EQ predicate on the "text_value" field.
func TextValueEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldTextValue, v))
}
// TextValueNEQ applies the NEQ predicate on the "text_value" field.
func TextValueNEQ(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldTextValue, v))
}
// TextValueIn applies the In predicate on the "text_value" field.
func TextValueIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldTextValue, vs...))
}
// TextValueNotIn applies the NotIn predicate on the "text_value" field.
func TextValueNotIn(vs ...string) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldTextValue, vs...))
}
// TextValueGT applies the GT predicate on the "text_value" field.
func TextValueGT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldTextValue, v))
}
// TextValueGTE applies the GTE predicate on the "text_value" field.
func TextValueGTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldTextValue, v))
}
// TextValueLT applies the LT predicate on the "text_value" field.
func TextValueLT(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldTextValue, v))
}
// TextValueLTE applies the LTE predicate on the "text_value" field.
func TextValueLTE(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldTextValue, v))
}
// TextValueContains applies the Contains predicate on the "text_value" field.
func TextValueContains(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContains(FieldTextValue, v))
}
// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field.
func TextValueHasPrefix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasPrefix(FieldTextValue, v))
}
// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field.
func TextValueHasSuffix(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldHasSuffix(FieldTextValue, v))
}
// TextValueIsNil applies the IsNil predicate on the "text_value" field.
func TextValueIsNil() predicate.EntityField {
return predicate.EntityField(sql.FieldIsNull(FieldTextValue))
}
// TextValueNotNil applies the NotNil predicate on the "text_value" field.
func TextValueNotNil() predicate.EntityField {
return predicate.EntityField(sql.FieldNotNull(FieldTextValue))
}
// TextValueEqualFold applies the EqualFold predicate on the "text_value" field.
func TextValueEqualFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldEqualFold(FieldTextValue, v))
}
// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field.
func TextValueContainsFold(v string) predicate.EntityField {
return predicate.EntityField(sql.FieldContainsFold(FieldTextValue, v))
}
// NumberValueEQ applies the EQ predicate on the "number_value" field.
func NumberValueEQ(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldNumberValue, v))
}
// NumberValueNEQ applies the NEQ predicate on the "number_value" field.
func NumberValueNEQ(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldNumberValue, v))
}
// NumberValueIn applies the In predicate on the "number_value" field.
func NumberValueIn(vs ...int) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldNumberValue, vs...))
}
// NumberValueNotIn applies the NotIn predicate on the "number_value" field.
func NumberValueNotIn(vs ...int) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldNumberValue, vs...))
}
// NumberValueGT applies the GT predicate on the "number_value" field.
func NumberValueGT(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldNumberValue, v))
}
// NumberValueGTE applies the GTE predicate on the "number_value" field.
func NumberValueGTE(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldNumberValue, v))
}
// NumberValueLT applies the LT predicate on the "number_value" field.
func NumberValueLT(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldNumberValue, v))
}
// NumberValueLTE applies the LTE predicate on the "number_value" field.
func NumberValueLTE(v int) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldNumberValue, v))
}
// NumberValueIsNil applies the IsNil predicate on the "number_value" field.
func NumberValueIsNil() predicate.EntityField {
return predicate.EntityField(sql.FieldIsNull(FieldNumberValue))
}
// NumberValueNotNil applies the NotNil predicate on the "number_value" field.
func NumberValueNotNil() predicate.EntityField {
return predicate.EntityField(sql.FieldNotNull(FieldNumberValue))
}
// BooleanValueEQ applies the EQ predicate on the "boolean_value" field.
func BooleanValueEQ(v bool) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldBooleanValue, v))
}
// BooleanValueNEQ applies the NEQ predicate on the "boolean_value" field.
func BooleanValueNEQ(v bool) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldBooleanValue, v))
}
// TimeValueEQ applies the EQ predicate on the "time_value" field.
func TimeValueEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldEQ(FieldTimeValue, v))
}
// TimeValueNEQ applies the NEQ predicate on the "time_value" field.
func TimeValueNEQ(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNEQ(FieldTimeValue, v))
}
// TimeValueIn applies the In predicate on the "time_value" field.
func TimeValueIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldIn(FieldTimeValue, vs...))
}
// TimeValueNotIn applies the NotIn predicate on the "time_value" field.
func TimeValueNotIn(vs ...time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldNotIn(FieldTimeValue, vs...))
}
// TimeValueGT applies the GT predicate on the "time_value" field.
func TimeValueGT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGT(FieldTimeValue, v))
}
// TimeValueGTE applies the GTE predicate on the "time_value" field.
func TimeValueGTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldGTE(FieldTimeValue, v))
}
// TimeValueLT applies the LT predicate on the "time_value" field.
func TimeValueLT(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLT(FieldTimeValue, v))
}
// TimeValueLTE applies the LTE predicate on the "time_value" field.
func TimeValueLTE(v time.Time) predicate.EntityField {
return predicate.EntityField(sql.FieldLTE(FieldTimeValue, v))
}
// HasEntity applies the HasEdge predicate on the "entity" edge.
func HasEntity() predicate.EntityField {
return predicate.EntityField(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasEntityWith applies the HasEdge predicate on the "entity" edge with a given conditions (other predicates).
func HasEntityWith(preds ...predicate.Entity) predicate.EntityField {
return predicate.EntityField(func(s *sql.Selector) {
step := newEntityStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.EntityField) predicate.EntityField {
return predicate.EntityField(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.EntityField) predicate.EntityField {
return predicate.EntityField(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.EntityField) predicate.EntityField {
return predicate.EntityField(sql.NotPredicates(p))
}

View File

@@ -11,25 +11,25 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
)
// ItemFieldCreate is the builder for creating a ItemField entity.
type ItemFieldCreate struct {
// EntityFieldCreate is the builder for creating a EntityField entity.
type EntityFieldCreate struct {
config
mutation *ItemFieldMutation
mutation *EntityFieldMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (_c *ItemFieldCreate) SetCreatedAt(v time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetCreatedAt(v time.Time) *EntityFieldCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableCreatedAt(v *time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableCreatedAt(v *time.Time) *EntityFieldCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
@@ -37,13 +37,13 @@ func (_c *ItemFieldCreate) SetNillableCreatedAt(v *time.Time) *ItemFieldCreate {
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *ItemFieldCreate) SetUpdatedAt(v time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetUpdatedAt(v time.Time) *EntityFieldCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableUpdatedAt(v *time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableUpdatedAt(v *time.Time) *EntityFieldCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
@@ -51,19 +51,19 @@ func (_c *ItemFieldCreate) SetNillableUpdatedAt(v *time.Time) *ItemFieldCreate {
}
// SetName sets the "name" field.
func (_c *ItemFieldCreate) SetName(v string) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetName(v string) *EntityFieldCreate {
_c.mutation.SetName(v)
return _c
}
// SetDescription sets the "description" field.
func (_c *ItemFieldCreate) SetDescription(v string) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetDescription(v string) *EntityFieldCreate {
_c.mutation.SetDescription(v)
return _c
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableDescription(v *string) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableDescription(v *string) *EntityFieldCreate {
if v != nil {
_c.SetDescription(*v)
}
@@ -71,19 +71,19 @@ func (_c *ItemFieldCreate) SetNillableDescription(v *string) *ItemFieldCreate {
}
// SetType sets the "type" field.
func (_c *ItemFieldCreate) SetType(v itemfield.Type) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetType(v entityfield.Type) *EntityFieldCreate {
_c.mutation.SetType(v)
return _c
}
// SetTextValue sets the "text_value" field.
func (_c *ItemFieldCreate) SetTextValue(v string) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetTextValue(v string) *EntityFieldCreate {
_c.mutation.SetTextValue(v)
return _c
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableTextValue(v *string) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableTextValue(v *string) *EntityFieldCreate {
if v != nil {
_c.SetTextValue(*v)
}
@@ -91,13 +91,13 @@ func (_c *ItemFieldCreate) SetNillableTextValue(v *string) *ItemFieldCreate {
}
// SetNumberValue sets the "number_value" field.
func (_c *ItemFieldCreate) SetNumberValue(v int) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNumberValue(v int) *EntityFieldCreate {
_c.mutation.SetNumberValue(v)
return _c
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableNumberValue(v *int) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableNumberValue(v *int) *EntityFieldCreate {
if v != nil {
_c.SetNumberValue(*v)
}
@@ -105,13 +105,13 @@ func (_c *ItemFieldCreate) SetNillableNumberValue(v *int) *ItemFieldCreate {
}
// SetBooleanValue sets the "boolean_value" field.
func (_c *ItemFieldCreate) SetBooleanValue(v bool) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetBooleanValue(v bool) *EntityFieldCreate {
_c.mutation.SetBooleanValue(v)
return _c
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableBooleanValue(v *bool) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableBooleanValue(v *bool) *EntityFieldCreate {
if v != nil {
_c.SetBooleanValue(*v)
}
@@ -119,13 +119,13 @@ func (_c *ItemFieldCreate) SetNillableBooleanValue(v *bool) *ItemFieldCreate {
}
// SetTimeValue sets the "time_value" field.
func (_c *ItemFieldCreate) SetTimeValue(v time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetTimeValue(v time.Time) *EntityFieldCreate {
_c.mutation.SetTimeValue(v)
return _c
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableTimeValue(v *time.Time) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableTimeValue(v *time.Time) *EntityFieldCreate {
if v != nil {
_c.SetTimeValue(*v)
}
@@ -133,51 +133,51 @@ func (_c *ItemFieldCreate) SetNillableTimeValue(v *time.Time) *ItemFieldCreate {
}
// SetID sets the "id" field.
func (_c *ItemFieldCreate) SetID(v uuid.UUID) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetID(v uuid.UUID) *EntityFieldCreate {
_c.mutation.SetID(v)
return _c
}
// SetNillableID sets the "id" field if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableID(v *uuid.UUID) *ItemFieldCreate {
func (_c *EntityFieldCreate) SetNillableID(v *uuid.UUID) *EntityFieldCreate {
if v != nil {
_c.SetID(*v)
}
return _c
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_c *ItemFieldCreate) SetItemID(id uuid.UUID) *ItemFieldCreate {
_c.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_c *EntityFieldCreate) SetEntityID(id uuid.UUID) *EntityFieldCreate {
_c.mutation.SetEntityID(id)
return _c
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_c *ItemFieldCreate) SetNillableItemID(id *uuid.UUID) *ItemFieldCreate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableEntityID(id *uuid.UUID) *EntityFieldCreate {
if id != nil {
_c = _c.SetItemID(*id)
_c = _c.SetEntityID(*id)
}
return _c
}
// SetItem sets the "item" edge to the Item entity.
func (_c *ItemFieldCreate) SetItem(v *Item) *ItemFieldCreate {
return _c.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *EntityFieldCreate) SetEntity(v *Entity) *EntityFieldCreate {
return _c.SetEntityID(v.ID)
}
// Mutation returns the ItemFieldMutation object of the builder.
func (_c *ItemFieldCreate) Mutation() *ItemFieldMutation {
// Mutation returns the EntityFieldMutation object of the builder.
func (_c *EntityFieldCreate) Mutation() *EntityFieldMutation {
return _c.mutation
}
// Save creates the ItemField in the database.
func (_c *ItemFieldCreate) Save(ctx context.Context) (*ItemField, error) {
// Save creates the EntityField in the database.
func (_c *EntityFieldCreate) Save(ctx context.Context) (*EntityField, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *ItemFieldCreate) SaveX(ctx context.Context) *ItemField {
func (_c *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -186,86 +186,86 @@ func (_c *ItemFieldCreate) SaveX(ctx context.Context) *ItemField {
}
// Exec executes the query.
func (_c *ItemFieldCreate) Exec(ctx context.Context) error {
func (_c *EntityFieldCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *ItemFieldCreate) ExecX(ctx context.Context) {
func (_c *EntityFieldCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *ItemFieldCreate) defaults() {
func (_c *EntityFieldCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := itemfield.DefaultCreatedAt()
v := entityfield.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := itemfield.DefaultUpdatedAt()
v := entityfield.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.BooleanValue(); !ok {
v := itemfield.DefaultBooleanValue
v := entityfield.DefaultBooleanValue
_c.mutation.SetBooleanValue(v)
}
if _, ok := _c.mutation.TimeValue(); !ok {
v := itemfield.DefaultTimeValue()
v := entityfield.DefaultTimeValue()
_c.mutation.SetTimeValue(v)
}
if _, ok := _c.mutation.ID(); !ok {
v := itemfield.DefaultID()
v := entityfield.DefaultID()
_c.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *ItemFieldCreate) check() error {
func (_c *EntityFieldCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemField.created_at"`)}
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityField.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemField.updated_at"`)}
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityField.updated_at"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemField.name"`)}
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityField.name"`)}
}
if v, ok := _c.mutation.Name(); ok {
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
}
}
if v, ok := _c.mutation.Description(); ok {
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
}
}
if _, ok := _c.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "ItemField.type"`)}
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "EntityField.type"`)}
}
if v, ok := _c.mutation.GetType(); ok {
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
}
}
if v, ok := _c.mutation.TextValue(); ok {
if err := itemfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)}
if err := entityfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
}
}
if _, ok := _c.mutation.BooleanValue(); !ok {
return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "ItemField.boolean_value"`)}
return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "EntityField.boolean_value"`)}
}
if _, ok := _c.mutation.TimeValue(); !ok {
return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "ItemField.time_value"`)}
return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "EntityField.time_value"`)}
}
return nil
}
func (_c *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
func (_c *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error) {
if err := _c.check(); err != nil {
return nil, err
}
@@ -288,92 +288,92 @@ func (_c *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
return _node, nil
}
func (_c *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) {
func (_c *EntityFieldCreate) createSpec() (*EntityField, *sqlgraph.CreateSpec) {
var (
_node = &ItemField{config: _c.config}
_spec = sqlgraph.NewCreateSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
_node = &EntityField{config: _c.config}
_spec = sqlgraph.NewCreateSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
)
if id, ok := _c.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = &id
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(itemfield.FieldCreatedAt, field.TypeTime, value)
_spec.SetField(entityfield.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(itemfield.FieldName, field.TypeString, value)
_spec.SetField(entityfield.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Description(); ok {
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
_node.Description = value
}
if value, ok := _c.mutation.GetType(); ok {
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
_node.Type = value
}
if value, ok := _c.mutation.TextValue(); ok {
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
_node.TextValue = value
}
if value, ok := _c.mutation.NumberValue(); ok {
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
_node.NumberValue = value
}
if value, ok := _c.mutation.BooleanValue(); ok {
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
_node.BooleanValue = value
}
if value, ok := _c.mutation.TimeValue(); ok {
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
_node.TimeValue = value
}
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.item_fields = &nodes[0]
_node.entity_fields = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// ItemFieldCreateBulk is the builder for creating many ItemField entities in bulk.
type ItemFieldCreateBulk struct {
// EntityFieldCreateBulk is the builder for creating many EntityField entities in bulk.
type EntityFieldCreateBulk struct {
config
err error
builders []*ItemFieldCreate
builders []*EntityFieldCreate
}
// Save creates the ItemField entities in the database.
func (_c *ItemFieldCreateBulk) Save(ctx context.Context) ([]*ItemField, error) {
// Save creates the EntityField entities in the database.
func (_c *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*ItemField, len(_c.builders))
nodes := make([]*EntityField, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ItemFieldMutation)
mutation, ok := m.(*EntityFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
@@ -416,7 +416,7 @@ func (_c *ItemFieldCreateBulk) Save(ctx context.Context) ([]*ItemField, error) {
}
// SaveX is like Save, but panics if an error occurs.
func (_c *ItemFieldCreateBulk) SaveX(ctx context.Context) []*ItemField {
func (_c *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -425,13 +425,13 @@ func (_c *ItemFieldCreateBulk) SaveX(ctx context.Context) []*ItemField {
}
// Exec executes the query.
func (_c *ItemFieldCreateBulk) Exec(ctx context.Context) error {
func (_c *EntityFieldCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *ItemFieldCreateBulk) ExecX(ctx context.Context) {
func (_c *EntityFieldCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -8,30 +8,30 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ItemFieldDelete is the builder for deleting a ItemField entity.
type ItemFieldDelete struct {
// EntityFieldDelete is the builder for deleting a EntityField entity.
type EntityFieldDelete struct {
config
hooks []Hook
mutation *ItemFieldMutation
mutation *EntityFieldMutation
}
// Where appends a list predicates to the ItemFieldDelete builder.
func (_d *ItemFieldDelete) Where(ps ...predicate.ItemField) *ItemFieldDelete {
// Where appends a list predicates to the EntityFieldDelete builder.
func (_d *EntityFieldDelete) Where(ps ...predicate.EntityField) *EntityFieldDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *ItemFieldDelete) Exec(ctx context.Context) (int, error) {
func (_d *EntityFieldDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *ItemFieldDelete) ExecX(ctx context.Context) int {
func (_d *EntityFieldDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
@@ -39,8 +39,8 @@ func (_d *ItemFieldDelete) ExecX(ctx context.Context) int {
return n
}
func (_d *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
func (_d *EntityFieldDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -56,32 +56,32 @@ func (_d *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err
}
// ItemFieldDeleteOne is the builder for deleting a single ItemField entity.
type ItemFieldDeleteOne struct {
_d *ItemFieldDelete
// EntityFieldDeleteOne is the builder for deleting a single EntityField entity.
type EntityFieldDeleteOne struct {
_d *EntityFieldDelete
}
// Where appends a list predicates to the ItemFieldDelete builder.
func (_d *ItemFieldDeleteOne) Where(ps ...predicate.ItemField) *ItemFieldDeleteOne {
// Where appends a list predicates to the EntityFieldDelete builder.
func (_d *EntityFieldDeleteOne) Where(ps ...predicate.EntityField) *EntityFieldDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *ItemFieldDeleteOne) Exec(ctx context.Context) error {
func (_d *EntityFieldDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{itemfield.Label}
return &NotFoundError{entityfield.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *ItemFieldDeleteOne) ExecX(ctx context.Context) {
func (_d *EntityFieldDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -12,59 +12,59 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ItemFieldQuery is the builder for querying ItemField entities.
type ItemFieldQuery struct {
// EntityFieldQuery is the builder for querying EntityField entities.
type EntityFieldQuery struct {
config
ctx *QueryContext
order []itemfield.OrderOption
order []entityfield.OrderOption
inters []Interceptor
predicates []predicate.ItemField
withItem *ItemQuery
predicates []predicate.EntityField
withEntity *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ItemFieldQuery builder.
func (_q *ItemFieldQuery) Where(ps ...predicate.ItemField) *ItemFieldQuery {
// Where adds a new predicate for the EntityFieldQuery builder.
func (_q *EntityFieldQuery) Where(ps ...predicate.EntityField) *EntityFieldQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *ItemFieldQuery) Limit(limit int) *ItemFieldQuery {
func (_q *EntityFieldQuery) Limit(limit int) *EntityFieldQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *ItemFieldQuery) Offset(offset int) *ItemFieldQuery {
func (_q *EntityFieldQuery) Offset(offset int) *EntityFieldQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *ItemFieldQuery) Unique(unique bool) *ItemFieldQuery {
func (_q *EntityFieldQuery) Unique(unique bool) *EntityFieldQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *ItemFieldQuery) Order(o ...itemfield.OrderOption) *ItemFieldQuery {
func (_q *EntityFieldQuery) Order(o ...entityfield.OrderOption) *EntityFieldQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryItem chains the current query on the "item" edge.
func (_q *ItemFieldQuery) QueryItem() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntity chains the current query on the "entity" edge.
func (_q *EntityFieldQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -74,9 +74,9 @@ func (_q *ItemFieldQuery) QueryItem() *ItemQuery {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(itemfield.Table, itemfield.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn),
sqlgraph.From(entityfield.Table, entityfield.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -84,21 +84,21 @@ func (_q *ItemFieldQuery) QueryItem() *ItemQuery {
return query
}
// First returns the first ItemField entity from the query.
// Returns a *NotFoundError when no ItemField was found.
func (_q *ItemFieldQuery) First(ctx context.Context) (*ItemField, error) {
// First returns the first EntityField entity from the query.
// Returns a *NotFoundError when no EntityField was found.
func (_q *EntityFieldQuery) First(ctx context.Context) (*EntityField, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{itemfield.Label}
return nil, &NotFoundError{entityfield.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *ItemFieldQuery) FirstX(ctx context.Context) *ItemField {
func (_q *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
@@ -106,22 +106,22 @@ func (_q *ItemFieldQuery) FirstX(ctx context.Context) *ItemField {
return node
}
// FirstID returns the first ItemField ID from the query.
// Returns a *NotFoundError when no ItemField ID was found.
func (_q *ItemFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
// FirstID returns the first EntityField ID from the query.
// Returns a *NotFoundError when no EntityField ID was found.
func (_q *EntityFieldQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{itemfield.Label}
err = &NotFoundError{entityfield.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
func (_q *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
@@ -129,10 +129,10 @@ func (_q *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
return id
}
// Only returns a single ItemField entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ItemField entity is found.
// Returns a *NotFoundError when no ItemField entities are found.
func (_q *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) {
// Only returns a single EntityField entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one EntityField entity is found.
// Returns a *NotFoundError when no EntityField entities are found.
func (_q *EntityFieldQuery) Only(ctx context.Context) (*EntityField, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
@@ -141,14 +141,14 @@ func (_q *ItemFieldQuery) Only(ctx context.Context) (*ItemField, error) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{itemfield.Label}
return nil, &NotFoundError{entityfield.Label}
default:
return nil, &NotSingularError{itemfield.Label}
return nil, &NotSingularError{entityfield.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField {
func (_q *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
@@ -156,10 +156,10 @@ func (_q *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField {
return node
}
// OnlyID is like Only, but returns the only ItemField ID in the query.
// Returns a *NotSingularError when more than one ItemField ID is found.
// OnlyID is like Only, but returns the only EntityField ID in the query.
// Returns a *NotSingularError when more than one EntityField ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
func (_q *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
@@ -168,15 +168,15 @@ func (_q *ItemFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)
case 1:
id = ids[0]
case 0:
err = &NotFoundError{itemfield.Label}
err = &NotFoundError{entityfield.Label}
default:
err = &NotSingularError{itemfield.Label}
err = &NotSingularError{entityfield.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
func (_q *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
@@ -184,18 +184,18 @@ func (_q *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
return id
}
// All executes the query and returns a list of ItemFields.
func (_q *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) {
// All executes the query and returns a list of EntityFields.
func (_q *EntityFieldQuery) All(ctx context.Context) ([]*EntityField, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ItemField, *ItemFieldQuery]()
return withInterceptors[[]*ItemField](ctx, _q, qr, _q.inters)
qr := querierAll[[]*EntityField, *EntityFieldQuery]()
return withInterceptors[[]*EntityField](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *ItemFieldQuery) AllX(ctx context.Context) []*ItemField {
func (_q *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
@@ -203,20 +203,20 @@ func (_q *ItemFieldQuery) AllX(ctx context.Context) []*ItemField {
return nodes
}
// IDs executes the query and returns a list of ItemField IDs.
func (_q *ItemFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
// IDs executes the query and returns a list of EntityField IDs.
func (_q *EntityFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil {
if err = _q.Select(entityfield.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
func (_q *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
@@ -225,16 +225,16 @@ func (_q *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
}
// Count returns the count of the given query.
func (_q *ItemFieldQuery) Count(ctx context.Context) (int, error) {
func (_q *EntityFieldQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*ItemFieldQuery](), _q.inters)
return withInterceptors[int](ctx, _q, querierCount[*EntityFieldQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *ItemFieldQuery) CountX(ctx context.Context) int {
func (_q *EntityFieldQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
@@ -243,7 +243,7 @@ func (_q *ItemFieldQuery) CountX(ctx context.Context) int {
}
// Exist returns true if the query has elements in the graph.
func (_q *ItemFieldQuery) Exist(ctx context.Context) (bool, error) {
func (_q *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
@@ -256,7 +256,7 @@ func (_q *ItemFieldQuery) Exist(ctx context.Context) (bool, error) {
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *ItemFieldQuery) ExistX(ctx context.Context) bool {
func (_q *EntityFieldQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
@@ -264,33 +264,33 @@ func (_q *ItemFieldQuery) ExistX(ctx context.Context) bool {
return exist
}
// Clone returns a duplicate of the ItemFieldQuery builder, including all associated steps. It can be
// Clone returns a duplicate of the EntityFieldQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *ItemFieldQuery) Clone() *ItemFieldQuery {
func (_q *EntityFieldQuery) Clone() *EntityFieldQuery {
if _q == nil {
return nil
}
return &ItemFieldQuery{
return &EntityFieldQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]itemfield.OrderOption{}, _q.order...),
order: append([]entityfield.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.ItemField{}, _q.predicates...),
withItem: _q.withItem.Clone(),
predicates: append([]predicate.EntityField{}, _q.predicates...),
withEntity: _q.withEntity.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntity tells the query-builder to eager-load the nodes that are connected to
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *EntityFieldQuery) WithEntity(opts ...func(*EntityQuery)) *EntityFieldQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItem = query
_q.withEntity = query
return _q
}
@@ -304,15 +304,15 @@ func (_q *ItemFieldQuery) WithItem(opts ...func(*ItemQuery)) *ItemFieldQuery {
// Count int `json:"count,omitempty"`
// }
//
// client.ItemField.Query().
// GroupBy(itemfield.FieldCreatedAt).
// client.EntityField.Query().
// GroupBy(entityfield.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGroupBy {
func (_q *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityFieldGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &ItemFieldGroupBy{build: _q}
grbuild := &EntityFieldGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = itemfield.Label
grbuild.label = entityfield.Label
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -326,23 +326,23 @@ func (_q *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGrou
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ItemField.Query().
// Select(itemfield.FieldCreatedAt).
// client.EntityField.Query().
// Select(entityfield.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect {
func (_q *EntityFieldQuery) Select(fields ...string) *EntityFieldSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &ItemFieldSelect{ItemFieldQuery: _q}
sbuild.label = itemfield.Label
sbuild := &EntityFieldSelect{EntityFieldQuery: _q}
sbuild.label = entityfield.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ItemFieldSelect configured with the given aggregations.
func (_q *ItemFieldQuery) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
// Aggregate returns a EntityFieldSelect configured with the given aggregations.
func (_q *EntityFieldQuery) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *ItemFieldQuery) prepareQuery(ctx context.Context) error {
func (_q *EntityFieldQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
@@ -354,7 +354,7 @@ func (_q *ItemFieldQuery) prepareQuery(ctx context.Context) error {
}
}
for _, f := range _q.ctx.Fields {
if !itemfield.ValidColumn(f) {
if !entityfield.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
@@ -368,26 +368,26 @@ func (_q *ItemFieldQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (_q *ItemFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemField, error) {
func (_q *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityField, error) {
var (
nodes = []*ItemField{}
nodes = []*EntityField{}
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withItem != nil,
_q.withEntity != nil,
}
)
if _q.withItem != nil {
if _q.withEntity != nil {
withFKs = true
}
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.ForeignKeys...)
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ItemField).scanValues(nil, columns)
return (*EntityField).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &ItemField{config: _q.config}
node := &EntityField{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
@@ -401,23 +401,23 @@ func (_q *ItemFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*It
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withItem; query != nil {
if err := _q.loadItem(ctx, query, nodes, nil,
func(n *ItemField, e *Item) { n.Edges.Item = e }); err != nil {
if query := _q.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *EntityField, e *Entity) { n.Edges.Entity = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*ItemField, init func(*ItemField), assign func(*ItemField, *Item)) error {
func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*EntityField, init func(*EntityField), assign func(*EntityField, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*ItemField)
nodeids := make(map[uuid.UUID][]*EntityField)
for i := range nodes {
if nodes[i].item_fields == nil {
if nodes[i].entity_fields == nil {
continue
}
fk := *nodes[i].item_fields
fk := *nodes[i].entity_fields
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -426,7 +426,7 @@ func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
if len(ids) == 0 {
return nil
}
query.Where(item.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -434,7 +434,7 @@ func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "item_fields" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "entity_fields" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
@@ -443,7 +443,7 @@ func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
return nil
}
func (_q *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) {
func (_q *EntityFieldQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
@@ -452,8 +452,8 @@ func (_q *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
func (_q *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
@@ -462,9 +462,9 @@ func (_q *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.FieldID)
for i := range fields {
if fields[i] != itemfield.FieldID {
if fields[i] != entityfield.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
@@ -492,12 +492,12 @@ func (_q *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (_q *ItemFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
func (_q *EntityFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(itemfield.Table)
t1 := builder.Table(entityfield.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = itemfield.Columns
columns = entityfield.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
@@ -524,28 +524,28 @@ func (_q *ItemFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
// ItemFieldGroupBy is the group-by builder for ItemField entities.
type ItemFieldGroupBy struct {
// EntityFieldGroupBy is the group-by builder for EntityField entities.
type EntityFieldGroupBy struct {
selector
build *ItemFieldQuery
build *EntityFieldQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *ItemFieldGroupBy) Aggregate(fns ...AggregateFunc) *ItemFieldGroupBy {
func (_g *EntityFieldGroupBy) Aggregate(fns ...AggregateFunc) *EntityFieldGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *ItemFieldGroupBy) Scan(ctx context.Context, v any) error {
func (_g *EntityFieldGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ItemFieldQuery, *ItemFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *ItemFieldGroupBy) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error {
func (_g *EntityFieldGroupBy) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
@@ -572,28 +572,28 @@ func (_g *ItemFieldGroupBy) sqlScan(ctx context.Context, root *ItemFieldQuery, v
return sql.ScanSlice(rows, v)
}
// ItemFieldSelect is the builder for selecting fields of ItemField entities.
type ItemFieldSelect struct {
*ItemFieldQuery
// EntityFieldSelect is the builder for selecting fields of EntityField entities.
type EntityFieldSelect struct {
*EntityFieldQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
func (_s *EntityFieldSelect) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *ItemFieldSelect) Scan(ctx context.Context, v any) error {
func (_s *EntityFieldSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ItemFieldQuery, *ItemFieldSelect](ctx, _s.ItemFieldQuery, _s, _s.inters, v)
return scanWithInterceptors[*EntityFieldQuery, *EntityFieldSelect](ctx, _s.EntityFieldQuery, _s, _s.inters, v)
}
func (_s *ItemFieldSelect) sqlScan(ctx context.Context, root *ItemFieldQuery, v any) error {
func (_s *EntityFieldSelect) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {

View File

@@ -12,38 +12,38 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ItemFieldUpdate is the builder for updating ItemField entities.
type ItemFieldUpdate struct {
// EntityFieldUpdate is the builder for updating EntityField entities.
type EntityFieldUpdate struct {
config
hooks []Hook
mutation *ItemFieldMutation
mutation *EntityFieldMutation
}
// Where appends a list predicates to the ItemFieldUpdate builder.
func (_u *ItemFieldUpdate) Where(ps ...predicate.ItemField) *ItemFieldUpdate {
// Where appends a list predicates to the EntityFieldUpdate builder.
func (_u *EntityFieldUpdate) Where(ps ...predicate.EntityField) *EntityFieldUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *ItemFieldUpdate) SetUpdatedAt(v time.Time) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetUpdatedAt(v time.Time) *EntityFieldUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *ItemFieldUpdate) SetName(v string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetName(v string) *EntityFieldUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableName(v *string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableName(v *string) *EntityFieldUpdate {
if v != nil {
_u.SetName(*v)
}
@@ -51,13 +51,13 @@ func (_u *ItemFieldUpdate) SetNillableName(v *string) *ItemFieldUpdate {
}
// SetDescription sets the "description" field.
func (_u *ItemFieldUpdate) SetDescription(v string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetDescription(v string) *EntityFieldUpdate {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableDescription(v *string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableDescription(v *string) *EntityFieldUpdate {
if v != nil {
_u.SetDescription(*v)
}
@@ -65,19 +65,19 @@ func (_u *ItemFieldUpdate) SetNillableDescription(v *string) *ItemFieldUpdate {
}
// ClearDescription clears the value of the "description" field.
func (_u *ItemFieldUpdate) ClearDescription() *ItemFieldUpdate {
func (_u *EntityFieldUpdate) ClearDescription() *EntityFieldUpdate {
_u.mutation.ClearDescription()
return _u
}
// SetType sets the "type" field.
func (_u *ItemFieldUpdate) SetType(v itemfield.Type) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetType(v entityfield.Type) *EntityFieldUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableType(v *itemfield.Type) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableType(v *entityfield.Type) *EntityFieldUpdate {
if v != nil {
_u.SetType(*v)
}
@@ -85,13 +85,13 @@ func (_u *ItemFieldUpdate) SetNillableType(v *itemfield.Type) *ItemFieldUpdate {
}
// SetTextValue sets the "text_value" field.
func (_u *ItemFieldUpdate) SetTextValue(v string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetTextValue(v string) *EntityFieldUpdate {
_u.mutation.SetTextValue(v)
return _u
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableTextValue(v *string) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableTextValue(v *string) *EntityFieldUpdate {
if v != nil {
_u.SetTextValue(*v)
}
@@ -99,20 +99,20 @@ func (_u *ItemFieldUpdate) SetNillableTextValue(v *string) *ItemFieldUpdate {
}
// ClearTextValue clears the value of the "text_value" field.
func (_u *ItemFieldUpdate) ClearTextValue() *ItemFieldUpdate {
func (_u *EntityFieldUpdate) ClearTextValue() *EntityFieldUpdate {
_u.mutation.ClearTextValue()
return _u
}
// SetNumberValue sets the "number_value" field.
func (_u *ItemFieldUpdate) SetNumberValue(v int) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNumberValue(v int) *EntityFieldUpdate {
_u.mutation.ResetNumberValue()
_u.mutation.SetNumberValue(v)
return _u
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableNumberValue(v *int) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableNumberValue(v *int) *EntityFieldUpdate {
if v != nil {
_u.SetNumberValue(*v)
}
@@ -120,25 +120,25 @@ func (_u *ItemFieldUpdate) SetNillableNumberValue(v *int) *ItemFieldUpdate {
}
// AddNumberValue adds value to the "number_value" field.
func (_u *ItemFieldUpdate) AddNumberValue(v int) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) AddNumberValue(v int) *EntityFieldUpdate {
_u.mutation.AddNumberValue(v)
return _u
}
// ClearNumberValue clears the value of the "number_value" field.
func (_u *ItemFieldUpdate) ClearNumberValue() *ItemFieldUpdate {
func (_u *EntityFieldUpdate) ClearNumberValue() *EntityFieldUpdate {
_u.mutation.ClearNumberValue()
return _u
}
// SetBooleanValue sets the "boolean_value" field.
func (_u *ItemFieldUpdate) SetBooleanValue(v bool) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetBooleanValue(v bool) *EntityFieldUpdate {
_u.mutation.SetBooleanValue(v)
return _u
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableBooleanValue(v *bool) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableBooleanValue(v *bool) *EntityFieldUpdate {
if v != nil {
_u.SetBooleanValue(*v)
}
@@ -146,57 +146,57 @@ func (_u *ItemFieldUpdate) SetNillableBooleanValue(v *bool) *ItemFieldUpdate {
}
// SetTimeValue sets the "time_value" field.
func (_u *ItemFieldUpdate) SetTimeValue(v time.Time) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetTimeValue(v time.Time) *EntityFieldUpdate {
_u.mutation.SetTimeValue(v)
return _u
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableTimeValue(v *time.Time) *ItemFieldUpdate {
func (_u *EntityFieldUpdate) SetNillableTimeValue(v *time.Time) *EntityFieldUpdate {
if v != nil {
_u.SetTimeValue(*v)
}
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *ItemFieldUpdate) SetItemID(id uuid.UUID) *ItemFieldUpdate {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *EntityFieldUpdate) SetEntityID(id uuid.UUID) *EntityFieldUpdate {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *ItemFieldUpdate) SetNillableItemID(id *uuid.UUID) *ItemFieldUpdate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdate {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *ItemFieldUpdate) SetItem(v *Item) *ItemFieldUpdate {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdate) SetEntity(v *Entity) *EntityFieldUpdate {
return _u.SetEntityID(v.ID)
}
// Mutation returns the ItemFieldMutation object of the builder.
func (_u *ItemFieldUpdate) Mutation() *ItemFieldMutation {
// Mutation returns the EntityFieldMutation object of the builder.
func (_u *EntityFieldUpdate) Mutation() *EntityFieldMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *ItemFieldUpdate) ClearItem() *ItemFieldUpdate {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdate) ClearEntity() *EntityFieldUpdate {
_u.mutation.ClearEntity()
return _u
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *ItemFieldUpdate) Save(ctx context.Context) (int, error) {
func (_u *EntityFieldUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *ItemFieldUpdate) SaveX(ctx context.Context) int {
func (_u *EntityFieldUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
@@ -205,56 +205,56 @@ func (_u *ItemFieldUpdate) SaveX(ctx context.Context) int {
}
// Exec executes the query.
func (_u *ItemFieldUpdate) Exec(ctx context.Context) error {
func (_u *EntityFieldUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *ItemFieldUpdate) ExecX(ctx context.Context) {
func (_u *EntityFieldUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *ItemFieldUpdate) defaults() {
func (_u *EntityFieldUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := itemfield.UpdateDefaultUpdatedAt()
v := entityfield.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *ItemFieldUpdate) check() error {
func (_u *EntityFieldUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
}
}
if v, ok := _u.mutation.TextValue(); ok {
if err := itemfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)}
if err := entityfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
}
}
return nil
}
func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
func (_u *EntityFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -263,63 +263,63 @@ func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(itemfield.FieldName, field.TypeString, value)
_spec.SetField(entityfield.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.TextValue(); ok {
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
}
if _u.mutation.TextValueCleared() {
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
}
if value, ok := _u.mutation.NumberValue(); ok {
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedNumberValue(); ok {
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
}
if _u.mutation.NumberValueCleared() {
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
}
if value, ok := _u.mutation.BooleanValue(); ok {
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
}
if value, ok := _u.mutation.TimeValue(); ok {
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -329,7 +329,7 @@ func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{itemfield.Label}
err = &NotFoundError{entityfield.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
@@ -339,28 +339,28 @@ func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
return _node, nil
}
// ItemFieldUpdateOne is the builder for updating a single ItemField entity.
type ItemFieldUpdateOne struct {
// EntityFieldUpdateOne is the builder for updating a single EntityField entity.
type EntityFieldUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ItemFieldMutation
mutation *EntityFieldMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *ItemFieldUpdateOne) SetUpdatedAt(v time.Time) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetUpdatedAt(v time.Time) *EntityFieldUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *ItemFieldUpdateOne) SetName(v string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetName(v string) *EntityFieldUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableName(v *string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableName(v *string) *EntityFieldUpdateOne {
if v != nil {
_u.SetName(*v)
}
@@ -368,13 +368,13 @@ func (_u *ItemFieldUpdateOne) SetNillableName(v *string) *ItemFieldUpdateOne {
}
// SetDescription sets the "description" field.
func (_u *ItemFieldUpdateOne) SetDescription(v string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetDescription(v string) *EntityFieldUpdateOne {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableDescription(v *string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableDescription(v *string) *EntityFieldUpdateOne {
if v != nil {
_u.SetDescription(*v)
}
@@ -382,19 +382,19 @@ func (_u *ItemFieldUpdateOne) SetNillableDescription(v *string) *ItemFieldUpdate
}
// ClearDescription clears the value of the "description" field.
func (_u *ItemFieldUpdateOne) ClearDescription() *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) ClearDescription() *EntityFieldUpdateOne {
_u.mutation.ClearDescription()
return _u
}
// SetType sets the "type" field.
func (_u *ItemFieldUpdateOne) SetType(v itemfield.Type) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetType(v entityfield.Type) *EntityFieldUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableType(v *itemfield.Type) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableType(v *entityfield.Type) *EntityFieldUpdateOne {
if v != nil {
_u.SetType(*v)
}
@@ -402,13 +402,13 @@ func (_u *ItemFieldUpdateOne) SetNillableType(v *itemfield.Type) *ItemFieldUpdat
}
// SetTextValue sets the "text_value" field.
func (_u *ItemFieldUpdateOne) SetTextValue(v string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetTextValue(v string) *EntityFieldUpdateOne {
_u.mutation.SetTextValue(v)
return _u
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableTextValue(v *string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableTextValue(v *string) *EntityFieldUpdateOne {
if v != nil {
_u.SetTextValue(*v)
}
@@ -416,20 +416,20 @@ func (_u *ItemFieldUpdateOne) SetNillableTextValue(v *string) *ItemFieldUpdateOn
}
// ClearTextValue clears the value of the "text_value" field.
func (_u *ItemFieldUpdateOne) ClearTextValue() *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) ClearTextValue() *EntityFieldUpdateOne {
_u.mutation.ClearTextValue()
return _u
}
// SetNumberValue sets the "number_value" field.
func (_u *ItemFieldUpdateOne) SetNumberValue(v int) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNumberValue(v int) *EntityFieldUpdateOne {
_u.mutation.ResetNumberValue()
_u.mutation.SetNumberValue(v)
return _u
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableNumberValue(v *int) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableNumberValue(v *int) *EntityFieldUpdateOne {
if v != nil {
_u.SetNumberValue(*v)
}
@@ -437,25 +437,25 @@ func (_u *ItemFieldUpdateOne) SetNillableNumberValue(v *int) *ItemFieldUpdateOne
}
// AddNumberValue adds value to the "number_value" field.
func (_u *ItemFieldUpdateOne) AddNumberValue(v int) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) AddNumberValue(v int) *EntityFieldUpdateOne {
_u.mutation.AddNumberValue(v)
return _u
}
// ClearNumberValue clears the value of the "number_value" field.
func (_u *ItemFieldUpdateOne) ClearNumberValue() *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) ClearNumberValue() *EntityFieldUpdateOne {
_u.mutation.ClearNumberValue()
return _u
}
// SetBooleanValue sets the "boolean_value" field.
func (_u *ItemFieldUpdateOne) SetBooleanValue(v bool) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetBooleanValue(v bool) *EntityFieldUpdateOne {
_u.mutation.SetBooleanValue(v)
return _u
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableBooleanValue(v *bool) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableBooleanValue(v *bool) *EntityFieldUpdateOne {
if v != nil {
_u.SetBooleanValue(*v)
}
@@ -463,70 +463,70 @@ func (_u *ItemFieldUpdateOne) SetNillableBooleanValue(v *bool) *ItemFieldUpdateO
}
// SetTimeValue sets the "time_value" field.
func (_u *ItemFieldUpdateOne) SetTimeValue(v time.Time) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetTimeValue(v time.Time) *EntityFieldUpdateOne {
_u.mutation.SetTimeValue(v)
return _u
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableTimeValue(v *time.Time) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) SetNillableTimeValue(v *time.Time) *EntityFieldUpdateOne {
if v != nil {
_u.SetTimeValue(*v)
}
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *ItemFieldUpdateOne) SetItemID(id uuid.UUID) *ItemFieldUpdateOne {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *EntityFieldUpdateOne) SetEntityID(id uuid.UUID) *EntityFieldUpdateOne {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *ItemFieldUpdateOne) SetNillableItemID(id *uuid.UUID) *ItemFieldUpdateOne {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableEntityID(id *uuid.UUID) *EntityFieldUpdateOne {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *ItemFieldUpdateOne) SetItem(v *Item) *ItemFieldUpdateOne {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdateOne) SetEntity(v *Entity) *EntityFieldUpdateOne {
return _u.SetEntityID(v.ID)
}
// Mutation returns the ItemFieldMutation object of the builder.
func (_u *ItemFieldUpdateOne) Mutation() *ItemFieldMutation {
// Mutation returns the EntityFieldMutation object of the builder.
func (_u *EntityFieldUpdateOne) Mutation() *EntityFieldMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *ItemFieldUpdateOne) ClearItem() *ItemFieldUpdateOne {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdateOne) ClearEntity() *EntityFieldUpdateOne {
_u.mutation.ClearEntity()
return _u
}
// Where appends a list predicates to the ItemFieldUpdate builder.
func (_u *ItemFieldUpdateOne) Where(ps ...predicate.ItemField) *ItemFieldUpdateOne {
// Where appends a list predicates to the EntityFieldUpdate builder.
func (_u *EntityFieldUpdateOne) Where(ps ...predicate.EntityField) *EntityFieldUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFieldUpdateOne {
func (_u *EntityFieldUpdateOne) Select(field string, fields ...string) *EntityFieldUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated ItemField entity.
func (_u *ItemFieldUpdateOne) Save(ctx context.Context) (*ItemField, error) {
// Save executes the query and returns the updated EntityField entity.
func (_u *EntityFieldUpdateOne) Save(ctx context.Context) (*EntityField, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *ItemFieldUpdateOne) SaveX(ctx context.Context) *ItemField {
func (_u *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
@@ -535,69 +535,69 @@ func (_u *ItemFieldUpdateOne) SaveX(ctx context.Context) *ItemField {
}
// Exec executes the query on the entity.
func (_u *ItemFieldUpdateOne) Exec(ctx context.Context) error {
func (_u *EntityFieldUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *ItemFieldUpdateOne) ExecX(ctx context.Context) {
func (_u *EntityFieldUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *ItemFieldUpdateOne) defaults() {
func (_u *EntityFieldUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := itemfield.UpdateDefaultUpdatedAt()
v := entityfield.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *ItemFieldUpdateOne) check() error {
func (_u *EntityFieldUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
}
}
if v, ok := _u.mutation.TextValue(); ok {
if err := itemfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)}
if err := entityfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "EntityField.text_value": %w`, err)}
}
}
return nil
}
func (_u *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, err error) {
func (_u *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemField.id" for update`)}
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EntityField.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.FieldID)
for _, f := range fields {
if !itemfield.ValidColumn(f) {
if !entityfield.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != itemfield.FieldID {
if f != entityfield.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
@@ -610,63 +610,63 @@ func (_u *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, er
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(itemfield.FieldName, field.TypeString, value)
_spec.SetField(entityfield.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.TextValue(); ok {
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
}
if _u.mutation.TextValueCleared() {
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
}
if value, ok := _u.mutation.NumberValue(); ok {
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedNumberValue(); ok {
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
}
if _u.mutation.NumberValueCleared() {
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
}
if value, ok := _u.mutation.BooleanValue(); ok {
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
}
if value, ok := _u.mutation.TimeValue(); ok {
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -674,12 +674,12 @@ func (_u *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, er
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &ItemField{config: _u.config}
_node = &EntityField{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{itemfield.Label}
err = &NotFoundError{entityfield.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}

View File

@@ -10,12 +10,12 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
)
// Location is the model entity for the Location schema.
type Location struct {
// EntityType is the model entity for the EntityType schema.
type EntityType struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -27,32 +27,33 @@ type Location struct {
Name string `json:"name,omitempty"`
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Icon holds the value of the "icon" field.
Icon string `json:"icon,omitempty"`
// Color holds the value of the "color" field.
Color string `json:"color,omitempty"`
// IsLocation holds the value of the "is_location" field.
IsLocation bool `json:"is_location,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the LocationQuery when eager-loading is set.
Edges LocationEdges `json:"edges"`
group_locations *uuid.UUID
location_children *uuid.UUID
selectValues sql.SelectValues
// The values are being populated by the EntityTypeQuery when eager-loading is set.
Edges EntityTypeEdges `json:"edges"`
group_entity_types *uuid.UUID
selectValues sql.SelectValues
}
// LocationEdges holds the relations/edges for other nodes in the graph.
type LocationEdges struct {
// EntityTypeEdges holds the relations/edges for other nodes in the graph.
type EntityTypeEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Parent holds the value of the parent edge.
Parent *Location `json:"parent,omitempty"`
// Children holds the value of the children edge.
Children []*Location `json:"children,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [4]bool
loadedTypes [2]bool
}
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e LocationEdges) GroupOrErr() (*Group, error) {
func (e EntityTypeEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[0] {
@@ -61,49 +62,29 @@ func (e LocationEdges) GroupOrErr() (*Group, error) {
return nil, &NotLoadedError{edge: "group"}
}
// ParentOrErr returns the Parent value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e LocationEdges) ParentOrErr() (*Location, error) {
if e.Parent != nil {
return e.Parent, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: location.Label}
}
return nil, &NotLoadedError{edge: "parent"}
}
// ChildrenOrErr returns the Children value or an error if the edge
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e LocationEdges) ChildrenOrErr() ([]*Location, error) {
if e.loadedTypes[2] {
return e.Children, nil
func (e EntityTypeEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "children"}
}
// ItemsOrErr returns the Items value or an error if the edge
// was not loaded in eager-loading.
func (e LocationEdges) ItemsOrErr() ([]*Item, error) {
if e.loadedTypes[3] {
return e.Items, nil
}
return nil, &NotLoadedError{edge: "items"}
return nil, &NotLoadedError{edge: "entities"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Location) scanValues(columns []string) ([]any, error) {
func (*EntityType) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case location.FieldName, location.FieldDescription:
case entitytype.FieldIsLocation:
values[i] = new(sql.NullBool)
case entitytype.FieldName, entitytype.FieldDescription, entitytype.FieldIcon, entitytype.FieldColor:
values[i] = new(sql.NullString)
case location.FieldCreatedAt, location.FieldUpdatedAt:
case entitytype.FieldCreatedAt, entitytype.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case location.FieldID:
case entitytype.FieldID:
values[i] = new(uuid.UUID)
case location.ForeignKeys[0]: // group_locations
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case location.ForeignKeys[1]: // location_children
case entitytype.ForeignKeys[0]: // group_entity_types
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -113,56 +94,67 @@ func (*Location) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Location fields.
func (_m *Location) assignValues(columns []string, values []any) error {
// to the EntityType fields.
func (_m *EntityType) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case location.FieldID:
case entitytype.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case location.FieldCreatedAt:
case entitytype.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case location.FieldUpdatedAt:
case entitytype.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case location.FieldName:
case entitytype.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case location.FieldDescription:
case entitytype.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case location.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field group_locations", values[i])
case entitytype.FieldIcon:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field icon", values[i])
} else if value.Valid {
_m.group_locations = new(uuid.UUID)
*_m.group_locations = *value.S.(*uuid.UUID)
_m.Icon = value.String
}
case location.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field location_children", values[i])
case entitytype.FieldColor:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field color", values[i])
} else if value.Valid {
_m.location_children = new(uuid.UUID)
*_m.location_children = *value.S.(*uuid.UUID)
_m.Color = value.String
}
case entitytype.FieldIsLocation:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field is_location", values[i])
} else if value.Valid {
_m.IsLocation = value.Bool
}
case entitytype.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field group_entity_types", values[i])
} else if value.Valid {
_m.group_entity_types = new(uuid.UUID)
*_m.group_entity_types = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -171,54 +163,44 @@ func (_m *Location) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Location.
// Value returns the ent.Value that was dynamically selected and assigned to the EntityType.
// This includes values selected through modifiers, order, etc.
func (_m *Location) Value(name string) (ent.Value, error) {
func (_m *EntityType) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroup queries the "group" edge of the Location entity.
func (_m *Location) QueryGroup() *GroupQuery {
return NewLocationClient(_m.config).QueryGroup(_m)
// QueryGroup queries the "group" edge of the EntityType entity.
func (_m *EntityType) QueryGroup() *GroupQuery {
return NewEntityTypeClient(_m.config).QueryGroup(_m)
}
// QueryParent queries the "parent" edge of the Location entity.
func (_m *Location) QueryParent() *LocationQuery {
return NewLocationClient(_m.config).QueryParent(_m)
// QueryEntities queries the "entities" edge of the EntityType entity.
func (_m *EntityType) QueryEntities() *EntityQuery {
return NewEntityTypeClient(_m.config).QueryEntities(_m)
}
// QueryChildren queries the "children" edge of the Location entity.
func (_m *Location) QueryChildren() *LocationQuery {
return NewLocationClient(_m.config).QueryChildren(_m)
}
// QueryItems queries the "items" edge of the Location entity.
func (_m *Location) QueryItems() *ItemQuery {
return NewLocationClient(_m.config).QueryItems(_m)
}
// Update returns a builder for updating this Location.
// Note that you need to call Location.Unwrap() before calling this method if this Location
// Update returns a builder for updating this EntityType.
// Note that you need to call EntityType.Unwrap() before calling this method if this EntityType
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Location) Update() *LocationUpdateOne {
return NewLocationClient(_m.config).UpdateOne(_m)
func (_m *EntityType) Update() *EntityTypeUpdateOne {
return NewEntityTypeClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Location entity that was returned from a transaction after it was closed,
// Unwrap unwraps the EntityType entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *Location) Unwrap() *Location {
func (_m *EntityType) Unwrap() *EntityType {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Location is not a transactional entity")
panic("ent: EntityType is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Location) String() string {
func (_m *EntityType) String() string {
var builder strings.Builder
builder.WriteString("Location(")
builder.WriteString("EntityType(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -231,9 +213,18 @@ func (_m *Location) String() string {
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(_m.Description)
builder.WriteString(", ")
builder.WriteString("icon=")
builder.WriteString(_m.Icon)
builder.WriteString(", ")
builder.WriteString("color=")
builder.WriteString(_m.Color)
builder.WriteString(", ")
builder.WriteString("is_location=")
builder.WriteString(fmt.Sprintf("%v", _m.IsLocation))
builder.WriteByte(')')
return builder.String()
}
// Locations is a parsable slice of Location.
type Locations []*Location
// EntityTypes is a parsable slice of EntityType.
type EntityTypes []*EntityType

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package location
package entitytype
import (
"time"
@@ -11,8 +11,8 @@ import (
)
const (
// Label holds the string label denoting the location type in the database.
Label = "location"
// Label holds the string label denoting the entitytype type in the database.
Label = "entity_type"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
@@ -23,54 +23,50 @@ const (
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldIcon holds the string denoting the icon field in the database.
FieldIcon = "icon"
// FieldColor holds the string denoting the color field in the database.
FieldColor = "color"
// FieldIsLocation holds the string denoting the is_location field in the database.
FieldIsLocation = "is_location"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// EdgeItems holds the string denoting the items edge name in mutations.
EdgeItems = "items"
// Table holds the table name of the location in the database.
Table = "locations"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// Table holds the table name of the entitytype in the database.
Table = "entity_types"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "locations"
GroupTable = "entity_types"
// GroupInverseTable is the table name for the Group entity.
// It exists in this package in order to avoid circular dependency with the "group" package.
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
GroupColumn = "group_locations"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "locations"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "location_children"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "locations"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "location_children"
// ItemsTable is the table that holds the items relation/edge.
ItemsTable = "items"
// ItemsInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemsInverseTable = "items"
// ItemsColumn is the table column denoting the items relation/edge.
ItemsColumn = "location_items"
GroupColumn = "group_entity_types"
// EntitiesTable is the table that holds the entities relation/edge.
EntitiesTable = "entities"
// EntitiesInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntitiesInverseTable = "entities"
// EntitiesColumn is the table column denoting the entities relation/edge.
EntitiesColumn = "entity_type_entities"
)
// Columns holds all SQL columns for location fields.
// Columns holds all SQL columns for entitytype fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldName,
FieldDescription,
FieldIcon,
FieldColor,
FieldIsLocation,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "locations"
// ForeignKeys holds the SQL foreign-keys that are owned by the "entity_types"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"group_locations",
"location_children",
"group_entity_types",
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -99,11 +95,17 @@ var (
NameValidator func(string) error
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
DescriptionValidator func(string) error
// IconValidator is a validator for the "icon" field. It is called by the builders before save.
IconValidator func(string) error
// ColorValidator is a validator for the "color" field. It is called by the builders before save.
ColorValidator func(string) error
// DefaultIsLocation holds the default value on creation for the "is_location" field.
DefaultIsLocation bool
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() uuid.UUID
)
// OrderOption defines the ordering options for the Location queries.
// OrderOption defines the ordering options for the EntityType queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
@@ -131,6 +133,21 @@ func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByIcon orders the results by the icon field.
func ByIcon(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIcon, opts...).ToFunc()
}
// ByColor orders the results by the color field.
func ByColor(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldColor, opts...).ToFunc()
}
// ByIsLocation orders the results by the is_location field.
func ByIsLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIsLocation, opts...).ToFunc()
}
// ByGroupField orders the results by group field.
func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -138,38 +155,17 @@ func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
}
}
// ByParentField orders the results by parent field.
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
}
}
// ByChildrenCount orders the results by children count.
func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption {
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...)
}
}
// ByChildren orders the results by children terms.
func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByItemsCount orders the results by items count.
func ByItemsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...)
}
}
// ByItems orders the results by items terms.
func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...)
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newGroupStep() *sqlgraph.Step {
@@ -179,24 +175,10 @@ func newGroupStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newParentStep() *sqlgraph.Step {
func newEntitiesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newChildrenStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
)
}
func newItemsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
}

View File

@@ -0,0 +1,533 @@
// Code generated by ent, DO NOT EDIT.
package entitytype
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldUpdatedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldName, v))
}
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldDescription, v))
}
// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ.
func Icon(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldIcon, v))
}
// Color applies equality check predicate on the "color" field. It's identical to ColorEQ.
func Color(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldColor, v))
}
// IsLocation applies equality check predicate on the "is_location" field. It's identical to IsLocationEQ.
func IsLocation(v bool) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldIsLocation, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldUpdatedAt, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContainsFold(FieldName, v))
}
// DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldDescription, v))
}
// DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldDescription, v))
}
// DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldDescription, vs...))
}
// DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldDescription, vs...))
}
// DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldDescription, v))
}
// DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldDescription, v))
}
// DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldDescription, v))
}
// DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldDescription, v))
}
// DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContains(FieldDescription, v))
}
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasPrefix(FieldDescription, v))
}
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasSuffix(FieldDescription, v))
}
// DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.EntityType {
return predicate.EntityType(sql.FieldIsNull(FieldDescription))
}
// DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.EntityType {
return predicate.EntityType(sql.FieldNotNull(FieldDescription))
}
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEqualFold(FieldDescription, v))
}
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContainsFold(FieldDescription, v))
}
// IconEQ applies the EQ predicate on the "icon" field.
func IconEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldIcon, v))
}
// IconNEQ applies the NEQ predicate on the "icon" field.
func IconNEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldIcon, v))
}
// IconIn applies the In predicate on the "icon" field.
func IconIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldIcon, vs...))
}
// IconNotIn applies the NotIn predicate on the "icon" field.
func IconNotIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldIcon, vs...))
}
// IconGT applies the GT predicate on the "icon" field.
func IconGT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldIcon, v))
}
// IconGTE applies the GTE predicate on the "icon" field.
func IconGTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldIcon, v))
}
// IconLT applies the LT predicate on the "icon" field.
func IconLT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldIcon, v))
}
// IconLTE applies the LTE predicate on the "icon" field.
func IconLTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldIcon, v))
}
// IconContains applies the Contains predicate on the "icon" field.
func IconContains(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContains(FieldIcon, v))
}
// IconHasPrefix applies the HasPrefix predicate on the "icon" field.
func IconHasPrefix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasPrefix(FieldIcon, v))
}
// IconHasSuffix applies the HasSuffix predicate on the "icon" field.
func IconHasSuffix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasSuffix(FieldIcon, v))
}
// IconIsNil applies the IsNil predicate on the "icon" field.
func IconIsNil() predicate.EntityType {
return predicate.EntityType(sql.FieldIsNull(FieldIcon))
}
// IconNotNil applies the NotNil predicate on the "icon" field.
func IconNotNil() predicate.EntityType {
return predicate.EntityType(sql.FieldNotNull(FieldIcon))
}
// IconEqualFold applies the EqualFold predicate on the "icon" field.
func IconEqualFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEqualFold(FieldIcon, v))
}
// IconContainsFold applies the ContainsFold predicate on the "icon" field.
func IconContainsFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContainsFold(FieldIcon, v))
}
// ColorEQ applies the EQ predicate on the "color" field.
func ColorEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldColor, v))
}
// ColorNEQ applies the NEQ predicate on the "color" field.
func ColorNEQ(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldColor, v))
}
// ColorIn applies the In predicate on the "color" field.
func ColorIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldIn(FieldColor, vs...))
}
// ColorNotIn applies the NotIn predicate on the "color" field.
func ColorNotIn(vs ...string) predicate.EntityType {
return predicate.EntityType(sql.FieldNotIn(FieldColor, vs...))
}
// ColorGT applies the GT predicate on the "color" field.
func ColorGT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGT(FieldColor, v))
}
// ColorGTE applies the GTE predicate on the "color" field.
func ColorGTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldGTE(FieldColor, v))
}
// ColorLT applies the LT predicate on the "color" field.
func ColorLT(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLT(FieldColor, v))
}
// ColorLTE applies the LTE predicate on the "color" field.
func ColorLTE(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldLTE(FieldColor, v))
}
// ColorContains applies the Contains predicate on the "color" field.
func ColorContains(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContains(FieldColor, v))
}
// ColorHasPrefix applies the HasPrefix predicate on the "color" field.
func ColorHasPrefix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasPrefix(FieldColor, v))
}
// ColorHasSuffix applies the HasSuffix predicate on the "color" field.
func ColorHasSuffix(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldHasSuffix(FieldColor, v))
}
// ColorIsNil applies the IsNil predicate on the "color" field.
func ColorIsNil() predicate.EntityType {
return predicate.EntityType(sql.FieldIsNull(FieldColor))
}
// ColorNotNil applies the NotNil predicate on the "color" field.
func ColorNotNil() predicate.EntityType {
return predicate.EntityType(sql.FieldNotNull(FieldColor))
}
// ColorEqualFold applies the EqualFold predicate on the "color" field.
func ColorEqualFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldEqualFold(FieldColor, v))
}
// ColorContainsFold applies the ContainsFold predicate on the "color" field.
func ColorContainsFold(v string) predicate.EntityType {
return predicate.EntityType(sql.FieldContainsFold(FieldColor, v))
}
// IsLocationEQ applies the EQ predicate on the "is_location" field.
func IsLocationEQ(v bool) predicate.EntityType {
return predicate.EntityType(sql.FieldEQ(FieldIsLocation, v))
}
// IsLocationNEQ applies the NEQ predicate on the "is_location" field.
func IsLocationNEQ(v bool) predicate.EntityType {
return predicate.EntityType(sql.FieldNEQ(FieldIsLocation, v))
}
// HasGroup applies the HasEdge predicate on the "group" edge.
func HasGroup() predicate.EntityType {
return predicate.EntityType(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
func HasGroupWith(preds ...predicate.Group) predicate.EntityType {
return predicate.EntityType(func(s *sql.Selector) {
step := newGroupStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.EntityType {
return predicate.EntityType(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates).
func HasEntitiesWith(preds ...predicate.Entity) predicate.EntityType {
return predicate.EntityType(func(s *sql.Selector) {
step := newEntitiesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.EntityType) predicate.EntityType {
return predicate.EntityType(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.EntityType) predicate.EntityType {
return predicate.EntityType(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.EntityType) predicate.EntityType {
return predicate.EntityType(sql.NotPredicates(p))
}

View File

@@ -11,26 +11,26 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
)
// LocationCreate is the builder for creating a Location entity.
type LocationCreate struct {
// EntityTypeCreate is the builder for creating a EntityType entity.
type EntityTypeCreate struct {
config
mutation *LocationMutation
mutation *EntityTypeMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (_c *LocationCreate) SetCreatedAt(v time.Time) *LocationCreate {
func (_c *EntityTypeCreate) SetCreatedAt(v time.Time) *EntityTypeCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *LocationCreate) SetNillableCreatedAt(v *time.Time) *LocationCreate {
func (_c *EntityTypeCreate) SetNillableCreatedAt(v *time.Time) *EntityTypeCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
@@ -38,13 +38,13 @@ func (_c *LocationCreate) SetNillableCreatedAt(v *time.Time) *LocationCreate {
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *LocationCreate) SetUpdatedAt(v time.Time) *LocationCreate {
func (_c *EntityTypeCreate) SetUpdatedAt(v time.Time) *EntityTypeCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *LocationCreate) SetNillableUpdatedAt(v *time.Time) *LocationCreate {
func (_c *EntityTypeCreate) SetNillableUpdatedAt(v *time.Time) *EntityTypeCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
@@ -52,33 +52,75 @@ func (_c *LocationCreate) SetNillableUpdatedAt(v *time.Time) *LocationCreate {
}
// SetName sets the "name" field.
func (_c *LocationCreate) SetName(v string) *LocationCreate {
func (_c *EntityTypeCreate) SetName(v string) *EntityTypeCreate {
_c.mutation.SetName(v)
return _c
}
// SetDescription sets the "description" field.
func (_c *LocationCreate) SetDescription(v string) *LocationCreate {
func (_c *EntityTypeCreate) SetDescription(v string) *EntityTypeCreate {
_c.mutation.SetDescription(v)
return _c
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *LocationCreate) SetNillableDescription(v *string) *LocationCreate {
func (_c *EntityTypeCreate) SetNillableDescription(v *string) *EntityTypeCreate {
if v != nil {
_c.SetDescription(*v)
}
return _c
}
// SetIcon sets the "icon" field.
func (_c *EntityTypeCreate) SetIcon(v string) *EntityTypeCreate {
_c.mutation.SetIcon(v)
return _c
}
// SetNillableIcon sets the "icon" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableIcon(v *string) *EntityTypeCreate {
if v != nil {
_c.SetIcon(*v)
}
return _c
}
// SetColor sets the "color" field.
func (_c *EntityTypeCreate) SetColor(v string) *EntityTypeCreate {
_c.mutation.SetColor(v)
return _c
}
// SetNillableColor sets the "color" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableColor(v *string) *EntityTypeCreate {
if v != nil {
_c.SetColor(*v)
}
return _c
}
// SetIsLocation sets the "is_location" field.
func (_c *EntityTypeCreate) SetIsLocation(v bool) *EntityTypeCreate {
_c.mutation.SetIsLocation(v)
return _c
}
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableIsLocation(v *bool) *EntityTypeCreate {
if v != nil {
_c.SetIsLocation(*v)
}
return _c
}
// SetID sets the "id" field.
func (_c *LocationCreate) SetID(v uuid.UUID) *LocationCreate {
func (_c *EntityTypeCreate) SetID(v uuid.UUID) *EntityTypeCreate {
_c.mutation.SetID(v)
return _c
}
// SetNillableID sets the "id" field if the given value is not nil.
func (_c *LocationCreate) SetNillableID(v *uuid.UUID) *LocationCreate {
func (_c *EntityTypeCreate) SetNillableID(v *uuid.UUID) *EntityTypeCreate {
if v != nil {
_c.SetID(*v)
}
@@ -86,78 +128,44 @@ func (_c *LocationCreate) SetNillableID(v *uuid.UUID) *LocationCreate {
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_c *LocationCreate) SetGroupID(id uuid.UUID) *LocationCreate {
func (_c *EntityTypeCreate) SetGroupID(id uuid.UUID) *EntityTypeCreate {
_c.mutation.SetGroupID(id)
return _c
}
// SetGroup sets the "group" edge to the Group entity.
func (_c *LocationCreate) SetGroup(v *Group) *LocationCreate {
func (_c *EntityTypeCreate) SetGroup(v *Group) *EntityTypeCreate {
return _c.SetGroupID(v.ID)
}
// SetParentID sets the "parent" edge to the Location entity by ID.
func (_c *LocationCreate) SetParentID(id uuid.UUID) *LocationCreate {
_c.mutation.SetParentID(id)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *EntityTypeCreate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeCreate {
_c.mutation.AddEntityIDs(ids...)
return _c
}
// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil.
func (_c *LocationCreate) SetNillableParentID(id *uuid.UUID) *LocationCreate {
if id != nil {
_c = _c.SetParentID(*id)
}
return _c
}
// SetParent sets the "parent" edge to the Location entity.
func (_c *LocationCreate) SetParent(v *Location) *LocationCreate {
return _c.SetParentID(v.ID)
}
// AddChildIDs adds the "children" edge to the Location entity by IDs.
func (_c *LocationCreate) AddChildIDs(ids ...uuid.UUID) *LocationCreate {
_c.mutation.AddChildIDs(ids...)
return _c
}
// AddChildren adds the "children" edges to the Location entity.
func (_c *LocationCreate) AddChildren(v ...*Location) *LocationCreate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *EntityTypeCreate) AddEntities(v ...*Entity) *EntityTypeCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddChildIDs(ids...)
return _c.AddEntityIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *LocationCreate) AddItemIDs(ids ...uuid.UUID) *LocationCreate {
_c.mutation.AddItemIDs(ids...)
return _c
}
// AddItems adds the "items" edges to the Item entity.
func (_c *LocationCreate) AddItems(v ...*Item) *LocationCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddItemIDs(ids...)
}
// Mutation returns the LocationMutation object of the builder.
func (_c *LocationCreate) Mutation() *LocationMutation {
// Mutation returns the EntityTypeMutation object of the builder.
func (_c *EntityTypeCreate) Mutation() *EntityTypeMutation {
return _c.mutation
}
// Save creates the Location in the database.
func (_c *LocationCreate) Save(ctx context.Context) (*Location, error) {
// Save creates the EntityType in the database.
func (_c *EntityTypeCreate) Save(ctx context.Context) (*EntityType, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *LocationCreate) SaveX(ctx context.Context) *Location {
func (_c *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -166,62 +174,79 @@ func (_c *LocationCreate) SaveX(ctx context.Context) *Location {
}
// Exec executes the query.
func (_c *LocationCreate) Exec(ctx context.Context) error {
func (_c *EntityTypeCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *LocationCreate) ExecX(ctx context.Context) {
func (_c *EntityTypeCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *LocationCreate) defaults() {
func (_c *EntityTypeCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := location.DefaultCreatedAt()
v := entitytype.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := location.DefaultUpdatedAt()
v := entitytype.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.IsLocation(); !ok {
v := entitytype.DefaultIsLocation
_c.mutation.SetIsLocation(v)
}
if _, ok := _c.mutation.ID(); !ok {
v := location.DefaultID()
v := entitytype.DefaultID()
_c.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *LocationCreate) check() error {
func (_c *EntityTypeCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Location.created_at"`)}
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityType.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Location.updated_at"`)}
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityType.updated_at"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Location.name"`)}
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityType.name"`)}
}
if v, ok := _c.mutation.Name(); ok {
if err := location.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)}
if err := entitytype.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
}
}
if v, ok := _c.mutation.Description(); ok {
if err := location.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
if err := entitytype.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
}
}
if v, ok := _c.mutation.Icon(); ok {
if err := entitytype.IconValidator(v); err != nil {
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
}
}
if v, ok := _c.mutation.Color(); ok {
if err := entitytype.ColorValidator(v); err != nil {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
}
}
if _, ok := _c.mutation.IsLocation(); !ok {
return &ValidationError{Name: "is_location", err: errors.New(`ent: missing required field "EntityType.is_location"`)}
}
if len(_c.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Location.group"`)}
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "EntityType.group"`)}
}
return nil
}
func (_c *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
func (_c *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
if err := _c.check(); err != nil {
return nil, err
}
@@ -244,37 +269,49 @@ func (_c *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
return _node, nil
}
func (_c *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
func (_c *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
var (
_node = &Location{config: _c.config}
_spec = sqlgraph.NewCreateSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
_node = &EntityType{config: _c.config}
_spec = sqlgraph.NewCreateSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
)
if id, ok := _c.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = &id
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(location.FieldCreatedAt, field.TypeTime, value)
_spec.SetField(entitytype.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(location.FieldName, field.TypeString, value)
_spec.SetField(entitytype.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Description(); ok {
_spec.SetField(location.FieldDescription, field.TypeString, value)
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
_node.Description = value
}
if value, ok := _c.mutation.Icon(); ok {
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
_node.Icon = value
}
if value, ok := _c.mutation.Color(); ok {
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
_node.Color = value
}
if value, ok := _c.mutation.IsLocation(); ok {
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
_node.IsLocation = value
}
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Table: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
@@ -283,51 +320,18 @@ func (_c *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.group_locations = &nodes[0]
_node.group_entity_types = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.ParentTable,
Columns: []string{location.ParentColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.location_children = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -338,27 +342,27 @@ func (_c *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
return _node, _spec
}
// LocationCreateBulk is the builder for creating many Location entities in bulk.
type LocationCreateBulk struct {
// EntityTypeCreateBulk is the builder for creating many EntityType entities in bulk.
type EntityTypeCreateBulk struct {
config
err error
builders []*LocationCreate
builders []*EntityTypeCreate
}
// Save creates the Location entities in the database.
func (_c *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error) {
// Save creates the EntityType entities in the database.
func (_c *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Location, len(_c.builders))
nodes := make([]*EntityType, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*LocationMutation)
mutation, ok := m.(*EntityTypeMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
@@ -401,7 +405,7 @@ func (_c *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error) {
}
// SaveX is like Save, but panics if an error occurs.
func (_c *LocationCreateBulk) SaveX(ctx context.Context) []*Location {
func (_c *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -410,13 +414,13 @@ func (_c *LocationCreateBulk) SaveX(ctx context.Context) []*Location {
}
// Exec executes the query.
func (_c *LocationCreateBulk) Exec(ctx context.Context) error {
func (_c *EntityTypeCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *LocationCreateBulk) ExecX(ctx context.Context) {
func (_c *EntityTypeCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -8,30 +8,30 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// LocationDelete is the builder for deleting a Location entity.
type LocationDelete struct {
// EntityTypeDelete is the builder for deleting a EntityType entity.
type EntityTypeDelete struct {
config
hooks []Hook
mutation *LocationMutation
mutation *EntityTypeMutation
}
// Where appends a list predicates to the LocationDelete builder.
func (_d *LocationDelete) Where(ps ...predicate.Location) *LocationDelete {
// Where appends a list predicates to the EntityTypeDelete builder.
func (_d *EntityTypeDelete) Where(ps ...predicate.EntityType) *EntityTypeDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *LocationDelete) Exec(ctx context.Context) (int, error) {
func (_d *EntityTypeDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *LocationDelete) ExecX(ctx context.Context) int {
func (_d *EntityTypeDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
@@ -39,8 +39,8 @@ func (_d *LocationDelete) ExecX(ctx context.Context) int {
return n
}
func (_d *LocationDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
func (_d *EntityTypeDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -56,32 +56,32 @@ func (_d *LocationDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err
}
// LocationDeleteOne is the builder for deleting a single Location entity.
type LocationDeleteOne struct {
_d *LocationDelete
// EntityTypeDeleteOne is the builder for deleting a single EntityType entity.
type EntityTypeDeleteOne struct {
_d *EntityTypeDelete
}
// Where appends a list predicates to the LocationDelete builder.
func (_d *LocationDeleteOne) Where(ps ...predicate.Location) *LocationDeleteOne {
// Where appends a list predicates to the EntityTypeDelete builder.
func (_d *EntityTypeDeleteOne) Where(ps ...predicate.EntityType) *EntityTypeDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *LocationDeleteOne) Exec(ctx context.Context) error {
func (_d *EntityTypeDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{location.Label}
return &NotFoundError{entitytype.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *LocationDeleteOne) ExecX(ctx context.Context) {
func (_d *EntityTypeDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -0,0 +1,691 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// EntityTypeQuery is the builder for querying EntityType entities.
type EntityTypeQuery struct {
config
ctx *QueryContext
order []entitytype.OrderOption
inters []Interceptor
predicates []predicate.EntityType
withGroup *GroupQuery
withEntities *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the EntityTypeQuery builder.
func (_q *EntityTypeQuery) Where(ps ...predicate.EntityType) *EntityTypeQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *EntityTypeQuery) Limit(limit int) *EntityTypeQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *EntityTypeQuery) Offset(offset int) *EntityTypeQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *EntityTypeQuery) Unique(unique bool) *EntityTypeQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *EntityTypeQuery) Order(o ...entitytype.OrderOption) *EntityTypeQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryGroup chains the current query on the "group" edge.
func (_q *EntityTypeQuery) QueryGroup() *GroupQuery {
query := (&GroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(entitytype.Table, entitytype.FieldID, selector),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, entitytype.GroupTable, entitytype.GroupColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryEntities chains the current query on the "entities" edge.
func (_q *EntityTypeQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(entitytype.Table, entitytype.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, entitytype.EntitiesTable, entitytype.EntitiesColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first EntityType entity from the query.
// Returns a *NotFoundError when no EntityType was found.
func (_q *EntityTypeQuery) First(ctx context.Context) (*EntityType, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{entitytype.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *EntityTypeQuery) FirstX(ctx context.Context) *EntityType {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first EntityType ID from the query.
// Returns a *NotFoundError when no EntityType ID was found.
func (_q *EntityTypeQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{entitytype.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *EntityTypeQuery) FirstIDX(ctx context.Context) uuid.UUID {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single EntityType entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one EntityType entity is found.
// Returns a *NotFoundError when no EntityType entities are found.
func (_q *EntityTypeQuery) Only(ctx context.Context) (*EntityType, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{entitytype.Label}
default:
return nil, &NotSingularError{entitytype.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *EntityTypeQuery) OnlyX(ctx context.Context) *EntityType {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only EntityType ID in the query.
// Returns a *NotSingularError when more than one EntityType ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *EntityTypeQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{entitytype.Label}
default:
err = &NotSingularError{entitytype.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *EntityTypeQuery) OnlyIDX(ctx context.Context) uuid.UUID {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of EntityTypes.
func (_q *EntityTypeQuery) All(ctx context.Context) ([]*EntityType, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*EntityType, *EntityTypeQuery]()
return withInterceptors[[]*EntityType](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *EntityTypeQuery) AllX(ctx context.Context) []*EntityType {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of EntityType IDs.
func (_q *EntityTypeQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(entitytype.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *EntityTypeQuery) IDsX(ctx context.Context) []uuid.UUID {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *EntityTypeQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*EntityTypeQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *EntityTypeQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *EntityTypeQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *EntityTypeQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the EntityTypeQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *EntityTypeQuery) Clone() *EntityTypeQuery {
if _q == nil {
return nil
}
return &EntityTypeQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]entitytype.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.EntityType{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withEntities: _q.withEntities.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *EntityTypeQuery) WithGroup(opts ...func(*GroupQuery)) *EntityTypeQuery {
query := (&GroupClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withGroup = query
return _q
}
// WithEntities tells the query-builder to eager-load the nodes that are connected to
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *EntityTypeQuery) WithEntities(opts ...func(*EntityQuery)) *EntityTypeQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withEntities = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.EntityType.Query().
// GroupBy(entitytype.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *EntityTypeQuery) GroupBy(field string, fields ...string) *EntityTypeGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &EntityTypeGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = entitytype.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.EntityType.Query().
// Select(entitytype.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *EntityTypeQuery) Select(fields ...string) *EntityTypeSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &EntityTypeSelect{EntityTypeQuery: _q}
sbuild.label = entitytype.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a EntityTypeSelect configured with the given aggregations.
func (_q *EntityTypeQuery) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *EntityTypeQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !entitytype.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *EntityTypeQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityType, error) {
var (
nodes = []*EntityType{}
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withGroup != nil,
_q.withEntities != nil,
}
)
if _q.withGroup != nil {
withFKs = true
}
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, entitytype.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*EntityType).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &EntityType{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withGroup; query != nil {
if err := _q.loadGroup(ctx, query, nodes, nil,
func(n *EntityType, e *Group) { n.Edges.Group = e }); err != nil {
return nil, err
}
}
if query := _q.withEntities; query != nil {
if err := _q.loadEntities(ctx, query, nodes,
func(n *EntityType) { n.Edges.Entities = []*Entity{} },
func(n *EntityType, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *EntityTypeQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Group)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*EntityType)
for i := range nodes {
if nodes[i].group_entity_types == nil {
continue
}
fk := *nodes[i].group_entity_types
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(group.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "group_entity_types" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *EntityTypeQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*EntityType, init func(*EntityType), assign func(*EntityType, *Entity)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*EntityType)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Entity(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(entitytype.EntitiesColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.entity_type_entities
if fk == nil {
return fmt.Errorf(`foreign-key "entity_type_entities" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "entity_type_entities" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *EntityTypeQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *EntityTypeQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, entitytype.FieldID)
for i := range fields {
if fields[i] != entitytype.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *EntityTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(entitytype.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = entitytype.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// EntityTypeGroupBy is the group-by builder for EntityType entities.
type EntityTypeGroupBy struct {
selector
build *EntityTypeQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *EntityTypeGroupBy) Aggregate(fns ...AggregateFunc) *EntityTypeGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *EntityTypeGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *EntityTypeGroupBy) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// EntityTypeSelect is the builder for selecting fields of EntityType entities.
type EntityTypeSelect struct {
*EntityTypeQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *EntityTypeSelect) Aggregate(fns ...AggregateFunc) *EntityTypeSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *EntityTypeSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*EntityTypeQuery, *EntityTypeSelect](ctx, _s.EntityTypeQuery, _s, _s.inters, v)
}
func (_s *EntityTypeSelect) sqlScan(ctx context.Context, root *EntityTypeQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -0,0 +1,755 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// EntityTypeUpdate is the builder for updating EntityType entities.
type EntityTypeUpdate struct {
config
hooks []Hook
mutation *EntityTypeMutation
}
// Where appends a list predicates to the EntityTypeUpdate builder.
func (_u *EntityTypeUpdate) Where(ps ...predicate.EntityType) *EntityTypeUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *EntityTypeUpdate) SetUpdatedAt(v time.Time) *EntityTypeUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *EntityTypeUpdate) SetName(v string) *EntityTypeUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *EntityTypeUpdate) SetNillableName(v *string) *EntityTypeUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDescription sets the "description" field.
func (_u *EntityTypeUpdate) SetDescription(v string) *EntityTypeUpdate {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *EntityTypeUpdate) SetNillableDescription(v *string) *EntityTypeUpdate {
if v != nil {
_u.SetDescription(*v)
}
return _u
}
// ClearDescription clears the value of the "description" field.
func (_u *EntityTypeUpdate) ClearDescription() *EntityTypeUpdate {
_u.mutation.ClearDescription()
return _u
}
// SetIcon sets the "icon" field.
func (_u *EntityTypeUpdate) SetIcon(v string) *EntityTypeUpdate {
_u.mutation.SetIcon(v)
return _u
}
// SetNillableIcon sets the "icon" field if the given value is not nil.
func (_u *EntityTypeUpdate) SetNillableIcon(v *string) *EntityTypeUpdate {
if v != nil {
_u.SetIcon(*v)
}
return _u
}
// ClearIcon clears the value of the "icon" field.
func (_u *EntityTypeUpdate) ClearIcon() *EntityTypeUpdate {
_u.mutation.ClearIcon()
return _u
}
// SetColor sets the "color" field.
func (_u *EntityTypeUpdate) SetColor(v string) *EntityTypeUpdate {
_u.mutation.SetColor(v)
return _u
}
// SetNillableColor sets the "color" field if the given value is not nil.
func (_u *EntityTypeUpdate) SetNillableColor(v *string) *EntityTypeUpdate {
if v != nil {
_u.SetColor(*v)
}
return _u
}
// ClearColor clears the value of the "color" field.
func (_u *EntityTypeUpdate) ClearColor() *EntityTypeUpdate {
_u.mutation.ClearColor()
return _u
}
// SetIsLocation sets the "is_location" field.
func (_u *EntityTypeUpdate) SetIsLocation(v bool) *EntityTypeUpdate {
_u.mutation.SetIsLocation(v)
return _u
}
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
func (_u *EntityTypeUpdate) SetNillableIsLocation(v *bool) *EntityTypeUpdate {
if v != nil {
_u.SetIsLocation(*v)
}
return _u
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_u *EntityTypeUpdate) SetGroupID(id uuid.UUID) *EntityTypeUpdate {
_u.mutation.SetGroupID(id)
return _u
}
// SetGroup sets the "group" edge to the Group entity.
func (_u *EntityTypeUpdate) SetGroup(v *Group) *EntityTypeUpdate {
return _u.SetGroupID(v.ID)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *EntityTypeUpdate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *EntityTypeUpdate) AddEntities(v ...*Entity) *EntityTypeUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
}
// Mutation returns the EntityTypeMutation object of the builder.
func (_u *EntityTypeUpdate) Mutation() *EntityTypeMutation {
return _u.mutation
}
// ClearGroup clears the "group" edge to the Group entity.
func (_u *EntityTypeUpdate) ClearGroup() *EntityTypeUpdate {
_u.mutation.ClearGroup()
return _u
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *EntityTypeUpdate) ClearEntities() *EntityTypeUpdate {
_u.mutation.ClearEntities()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *EntityTypeUpdate) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdate {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *EntityTypeUpdate) RemoveEntities(v ...*Entity) *EntityTypeUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *EntityTypeUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *EntityTypeUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *EntityTypeUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *EntityTypeUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *EntityTypeUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := entitytype.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *EntityTypeUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := entitytype.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := entitytype.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
}
}
if v, ok := _u.mutation.Icon(); ok {
if err := entitytype.IconValidator(v); err != nil {
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
}
}
if v, ok := _u.mutation.Color(); ok {
if err := entitytype.ColorValidator(v); err != nil {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
}
}
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "EntityType.group"`)
}
return nil
}
func (_u *EntityTypeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(entitytype.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(entitytype.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.Icon(); ok {
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
}
if _u.mutation.IconCleared() {
_spec.ClearField(entitytype.FieldIcon, field.TypeString)
}
if value, ok := _u.mutation.Color(); ok {
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
}
if _u.mutation.ColorCleared() {
_spec.ClearField(entitytype.FieldColor, field.TypeString)
}
if value, ok := _u.mutation.IsLocation(); ok {
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
}
if _u.mutation.GroupCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitytype.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// EntityTypeUpdateOne is the builder for updating a single EntityType entity.
type EntityTypeUpdateOne struct {
config
fields []string
hooks []Hook
mutation *EntityTypeMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *EntityTypeUpdateOne) SetUpdatedAt(v time.Time) *EntityTypeUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *EntityTypeUpdateOne) SetName(v string) *EntityTypeUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *EntityTypeUpdateOne) SetNillableName(v *string) *EntityTypeUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDescription sets the "description" field.
func (_u *EntityTypeUpdateOne) SetDescription(v string) *EntityTypeUpdateOne {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *EntityTypeUpdateOne) SetNillableDescription(v *string) *EntityTypeUpdateOne {
if v != nil {
_u.SetDescription(*v)
}
return _u
}
// ClearDescription clears the value of the "description" field.
func (_u *EntityTypeUpdateOne) ClearDescription() *EntityTypeUpdateOne {
_u.mutation.ClearDescription()
return _u
}
// SetIcon sets the "icon" field.
func (_u *EntityTypeUpdateOne) SetIcon(v string) *EntityTypeUpdateOne {
_u.mutation.SetIcon(v)
return _u
}
// SetNillableIcon sets the "icon" field if the given value is not nil.
func (_u *EntityTypeUpdateOne) SetNillableIcon(v *string) *EntityTypeUpdateOne {
if v != nil {
_u.SetIcon(*v)
}
return _u
}
// ClearIcon clears the value of the "icon" field.
func (_u *EntityTypeUpdateOne) ClearIcon() *EntityTypeUpdateOne {
_u.mutation.ClearIcon()
return _u
}
// SetColor sets the "color" field.
func (_u *EntityTypeUpdateOne) SetColor(v string) *EntityTypeUpdateOne {
_u.mutation.SetColor(v)
return _u
}
// SetNillableColor sets the "color" field if the given value is not nil.
func (_u *EntityTypeUpdateOne) SetNillableColor(v *string) *EntityTypeUpdateOne {
if v != nil {
_u.SetColor(*v)
}
return _u
}
// ClearColor clears the value of the "color" field.
func (_u *EntityTypeUpdateOne) ClearColor() *EntityTypeUpdateOne {
_u.mutation.ClearColor()
return _u
}
// SetIsLocation sets the "is_location" field.
func (_u *EntityTypeUpdateOne) SetIsLocation(v bool) *EntityTypeUpdateOne {
_u.mutation.SetIsLocation(v)
return _u
}
// SetNillableIsLocation sets the "is_location" field if the given value is not nil.
func (_u *EntityTypeUpdateOne) SetNillableIsLocation(v *bool) *EntityTypeUpdateOne {
if v != nil {
_u.SetIsLocation(*v)
}
return _u
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_u *EntityTypeUpdateOne) SetGroupID(id uuid.UUID) *EntityTypeUpdateOne {
_u.mutation.SetGroupID(id)
return _u
}
// SetGroup sets the "group" edge to the Group entity.
func (_u *EntityTypeUpdateOne) SetGroup(v *Group) *EntityTypeUpdateOne {
return _u.SetGroupID(v.ID)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *EntityTypeUpdateOne) AddEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *EntityTypeUpdateOne) AddEntities(v ...*Entity) *EntityTypeUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
}
// Mutation returns the EntityTypeMutation object of the builder.
func (_u *EntityTypeUpdateOne) Mutation() *EntityTypeMutation {
return _u.mutation
}
// ClearGroup clears the "group" edge to the Group entity.
func (_u *EntityTypeUpdateOne) ClearGroup() *EntityTypeUpdateOne {
_u.mutation.ClearGroup()
return _u
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *EntityTypeUpdateOne) ClearEntities() *EntityTypeUpdateOne {
_u.mutation.ClearEntities()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *EntityTypeUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *EntityTypeUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *EntityTypeUpdateOne) RemoveEntities(v ...*Entity) *EntityTypeUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
}
// Where appends a list predicates to the EntityTypeUpdate builder.
func (_u *EntityTypeUpdateOne) Where(ps ...predicate.EntityType) *EntityTypeUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *EntityTypeUpdateOne) Select(field string, fields ...string) *EntityTypeUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated EntityType entity.
func (_u *EntityTypeUpdateOne) Save(ctx context.Context) (*EntityType, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *EntityTypeUpdateOne) SaveX(ctx context.Context) *EntityType {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *EntityTypeUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *EntityTypeUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *EntityTypeUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := entitytype.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *EntityTypeUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := entitytype.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityType.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := entitytype.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityType.description": %w`, err)}
}
}
if v, ok := _u.mutation.Icon(); ok {
if err := entitytype.IconValidator(v); err != nil {
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "EntityType.icon": %w`, err)}
}
}
if v, ok := _u.mutation.Color(); ok {
if err := entitytype.ColorValidator(v); err != nil {
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "EntityType.color": %w`, err)}
}
}
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "EntityType.group"`)
}
return nil
}
func (_u *EntityTypeUpdateOne) sqlSave(ctx context.Context) (_node *EntityType, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(entitytype.Table, entitytype.Columns, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EntityType.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, entitytype.FieldID)
for _, f := range fields {
if !entitytype.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != entitytype.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(entitytype.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(entitytype.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.Icon(); ok {
_spec.SetField(entitytype.FieldIcon, field.TypeString, value)
}
if _u.mutation.IconCleared() {
_spec.ClearField(entitytype.FieldIcon, field.TypeString)
}
if value, ok := _u.mutation.Color(); ok {
_spec.SetField(entitytype.FieldColor, field.TypeString, value)
}
if _u.mutation.ColorCleared() {
_spec.ClearField(entitytype.FieldColor, field.TypeString)
}
if value, ok := _u.mutation.IsLocation(); ok {
_spec.SetField(entitytype.FieldIsLocation, field.TypeBool, value)
}
if _u.mutation.GroupCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &EntityType{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{entitytype.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}

View File

@@ -36,16 +36,16 @@ type Group struct {
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User `json:"users,omitempty"`
// Locations holds the value of the locations edge.
Locations []*Location `json:"locations,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// Labels holds the value of the labels edge.
Labels []*Label `json:"labels,omitempty"`
// InvitationTokens holds the value of the invitation_tokens edge.
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
// Notifiers holds the value of the notifiers edge.
Notifiers []*Notifier `json:"notifiers,omitempty"`
// EntityTypes holds the value of the entity_types edge.
EntityTypes []*EntityType `json:"entity_types,omitempty"`
// ItemTemplates holds the value of the item_templates edge.
ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"`
// loadedTypes holds the information for reporting if a
@@ -62,28 +62,19 @@ func (e GroupEdges) UsersOrErr() ([]*User, error) {
return nil, &NotLoadedError{edge: "users"}
}
// LocationsOrErr returns the Locations value or an error if the edge
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) LocationsOrErr() ([]*Location, error) {
func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Locations, nil
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "locations"}
}
// ItemsOrErr returns the Items value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) ItemsOrErr() ([]*Item, error) {
if e.loadedTypes[2] {
return e.Items, nil
}
return nil, &NotLoadedError{edge: "items"}
return nil, &NotLoadedError{edge: "entities"}
}
// LabelsOrErr returns the Labels value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
if e.loadedTypes[3] {
if e.loadedTypes[2] {
return e.Labels, nil
}
return nil, &NotLoadedError{edge: "labels"}
@@ -92,7 +83,7 @@ func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
// InvitationTokensOrErr returns the InvitationTokens value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) {
if e.loadedTypes[4] {
if e.loadedTypes[3] {
return e.InvitationTokens, nil
}
return nil, &NotLoadedError{edge: "invitation_tokens"}
@@ -101,12 +92,21 @@ func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) {
// NotifiersOrErr returns the Notifiers value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) {
if e.loadedTypes[5] {
if e.loadedTypes[4] {
return e.Notifiers, nil
}
return nil, &NotLoadedError{edge: "notifiers"}
}
// EntityTypesOrErr returns the EntityTypes value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntityTypesOrErr() ([]*EntityType, error) {
if e.loadedTypes[5] {
return e.EntityTypes, nil
}
return nil, &NotLoadedError{edge: "entity_types"}
}
// ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) {
@@ -190,14 +190,9 @@ func (_m *Group) QueryUsers() *UserQuery {
return NewGroupClient(_m.config).QueryUsers(_m)
}
// QueryLocations queries the "locations" edge of the Group entity.
func (_m *Group) QueryLocations() *LocationQuery {
return NewGroupClient(_m.config).QueryLocations(_m)
}
// QueryItems queries the "items" edge of the Group entity.
func (_m *Group) QueryItems() *ItemQuery {
return NewGroupClient(_m.config).QueryItems(_m)
// QueryEntities queries the "entities" edge of the Group entity.
func (_m *Group) QueryEntities() *EntityQuery {
return NewGroupClient(_m.config).QueryEntities(_m)
}
// QueryLabels queries the "labels" edge of the Group entity.
@@ -215,6 +210,11 @@ func (_m *Group) QueryNotifiers() *NotifierQuery {
return NewGroupClient(_m.config).QueryNotifiers(_m)
}
// QueryEntityTypes queries the "entity_types" edge of the Group entity.
func (_m *Group) QueryEntityTypes() *EntityTypeQuery {
return NewGroupClient(_m.config).QueryEntityTypes(_m)
}
// QueryItemTemplates queries the "item_templates" edge of the Group entity.
func (_m *Group) QueryItemTemplates() *ItemTemplateQuery {
return NewGroupClient(_m.config).QueryItemTemplates(_m)

View File

@@ -25,16 +25,16 @@ const (
FieldCurrency = "currency"
// EdgeUsers holds the string denoting the users edge name in mutations.
EdgeUsers = "users"
// EdgeLocations holds the string denoting the locations edge name in mutations.
EdgeLocations = "locations"
// EdgeItems holds the string denoting the items edge name in mutations.
EdgeItems = "items"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// EdgeLabels holds the string denoting the labels edge name in mutations.
EdgeLabels = "labels"
// EdgeInvitationTokens holds the string denoting the invitation_tokens edge name in mutations.
EdgeInvitationTokens = "invitation_tokens"
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
EdgeNotifiers = "notifiers"
// EdgeEntityTypes holds the string denoting the entity_types edge name in mutations.
EdgeEntityTypes = "entity_types"
// EdgeItemTemplates holds the string denoting the item_templates edge name in mutations.
EdgeItemTemplates = "item_templates"
// Table holds the table name of the group in the database.
@@ -46,20 +46,13 @@ const (
UsersInverseTable = "users"
// UsersColumn is the table column denoting the users relation/edge.
UsersColumn = "group_users"
// LocationsTable is the table that holds the locations relation/edge.
LocationsTable = "locations"
// LocationsInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationsInverseTable = "locations"
// LocationsColumn is the table column denoting the locations relation/edge.
LocationsColumn = "group_locations"
// ItemsTable is the table that holds the items relation/edge.
ItemsTable = "items"
// ItemsInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemsInverseTable = "items"
// ItemsColumn is the table column denoting the items relation/edge.
ItemsColumn = "group_items"
// EntitiesTable is the table that holds the entities relation/edge.
EntitiesTable = "entities"
// EntitiesInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntitiesInverseTable = "entities"
// EntitiesColumn is the table column denoting the entities relation/edge.
EntitiesColumn = "group_entities"
// LabelsTable is the table that holds the labels relation/edge.
LabelsTable = "labels"
// LabelsInverseTable is the table name for the Label entity.
@@ -81,6 +74,13 @@ const (
NotifiersInverseTable = "notifiers"
// NotifiersColumn is the table column denoting the notifiers relation/edge.
NotifiersColumn = "group_id"
// EntityTypesTable is the table that holds the entity_types relation/edge.
EntityTypesTable = "entity_types"
// EntityTypesInverseTable is the table name for the EntityType entity.
// It exists in this package in order to avoid circular dependency with the "entitytype" package.
EntityTypesInverseTable = "entity_types"
// EntityTypesColumn is the table column denoting the entity_types relation/edge.
EntityTypesColumn = "group_entity_types"
// ItemTemplatesTable is the table that holds the item_templates relation/edge.
ItemTemplatesTable = "item_templates"
// ItemTemplatesInverseTable is the table name for the ItemTemplate entity.
@@ -166,31 +166,17 @@ func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByLocationsCount orders the results by locations count.
func ByLocationsCount(opts ...sql.OrderTermOption) OrderOption {
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newLocationsStep(), opts...)
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
}
}
// ByLocations orders the results by locations terms.
func ByLocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLocationsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByItemsCount orders the results by items count.
func ByItemsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...)
}
}
// ByItems orders the results by items terms.
func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...)
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
@@ -236,6 +222,20 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByEntityTypesCount orders the results by entity_types count.
func ByEntityTypesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEntityTypesStep(), opts...)
}
}
// ByEntityTypes orders the results by entity_types terms.
func ByEntityTypes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityTypesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByItemTemplatesCount orders the results by item_templates count.
func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -256,18 +256,11 @@ func newUsersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
)
}
func newLocationsStep() *sqlgraph.Step {
func newEntitiesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LocationsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
)
}
func newItemsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
}
func newLabelsStep() *sqlgraph.Step {
@@ -291,6 +284,13 @@ func newNotifiersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
)
}
func newEntityTypesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntityTypesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn),
)
}
func newItemTemplatesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),

View File

@@ -309,44 +309,21 @@ func HasUsersWith(preds ...predicate.User) predicate.Group {
})
}
// HasLocations applies the HasEdge predicate on the "locations" edge.
func HasLocations() predicate.Group {
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasLocationsWith applies the HasEdge predicate on the "locations" edge with a given conditions (other predicates).
func HasLocationsWith(preds ...predicate.Location) predicate.Group {
// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates).
func HasEntitiesWith(preds ...predicate.Entity) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newLocationsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasItems applies the HasEdge predicate on the "items" edge.
func HasItems() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
func HasItemsWith(preds ...predicate.Item) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newItemsStep()
step := newEntitiesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
@@ -424,6 +401,29 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group {
})
}
// HasEntityTypes applies the HasEdge predicate on the "entity_types" edge.
func HasEntityTypes() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasEntityTypesWith applies the HasEdge predicate on the "entity_types" edge with a given conditions (other predicates).
func HasEntityTypesWith(preds ...predicate.EntityType) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newEntityTypesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasItemTemplates applies the HasEdge predicate on the "item_templates" edge.
func HasItemTemplates() predicate.Group {
return predicate.Group(func(s *sql.Selector) {

View File

@@ -11,12 +11,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -105,34 +105,19 @@ func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate {
return _c.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_c *GroupCreate) AddLocationIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddEntityIDs(ids...)
return _c
}
// AddLocations adds the "locations" edges to the Location entity.
func (_c *GroupCreate) AddLocations(v ...*Location) *GroupCreate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *GroupCreate) AddItemIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddItemIDs(ids...)
return _c
}
// AddItems adds the "items" edges to the Item entity.
func (_c *GroupCreate) AddItems(v ...*Item) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddItemIDs(ids...)
return _c.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -180,6 +165,21 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate {
return _c.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_c *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddEntityTypeIDs(ids...)
return _c
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_c *GroupCreate) AddEntityTypes(v ...*EntityType) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_c *GroupCreate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddItemTemplateIDs(ids...)
@@ -334,31 +334,15 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -414,6 +398,22 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -13,12 +13,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
@@ -32,11 +32,11 @@ type GroupQuery struct {
inters []Interceptor
predicates []predicate.Group
withUsers *UserQuery
withLocations *LocationQuery
withItems *ItemQuery
withEntities *EntityQuery
withLabels *LabelQuery
withInvitationTokens *GroupInvitationTokenQuery
withNotifiers *NotifierQuery
withEntityTypes *EntityTypeQuery
withItemTemplates *ItemTemplateQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -96,9 +96,9 @@ func (_q *GroupQuery) QueryUsers() *UserQuery {
return query
}
// QueryLocations chains the current query on the "locations" edge.
func (_q *GroupQuery) QueryLocations() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
// QueryEntities chains the current query on the "entities" edge.
func (_q *GroupQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -109,30 +109,8 @@ func (_q *GroupQuery) QueryLocations() *LocationQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryItems chains the current query on the "items" edge.
func (_q *GroupQuery) QueryItems() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -206,6 +184,28 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery {
return query
}
// QueryEntityTypes chains the current query on the "entity_types" edge.
func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
query := (&EntityTypeClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(entitytype.Table, entitytype.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryItemTemplates chains the current query on the "item_templates" edge.
func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery {
query := (&ItemTemplateClient{config: _q.config}).Query()
@@ -421,11 +421,11 @@ func (_q *GroupQuery) Clone() *GroupQuery {
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Group{}, _q.predicates...),
withUsers: _q.withUsers.Clone(),
withLocations: _q.withLocations.Clone(),
withItems: _q.withItems.Clone(),
withEntities: _q.withEntities.Clone(),
withLabels: _q.withLabels.Clone(),
withInvitationTokens: _q.withInvitationTokens.Clone(),
withNotifiers: _q.withNotifiers.Clone(),
withEntityTypes: _q.withEntityTypes.Clone(),
withItemTemplates: _q.withItemTemplates.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
@@ -444,25 +444,14 @@ func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
return _q
}
// WithLocations tells the query-builder to eager-load the nodes that are connected to
// the "locations" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery {
query := (&LocationClient{config: _q.config}).Query()
// WithEntities tells the query-builder to eager-load the nodes that are connected to
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withLocations = query
return _q
}
// WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery {
query := (&ItemClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItems = query
_q.withEntities = query
return _q
}
@@ -499,6 +488,17 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
return _q
}
// WithEntityTypes tells the query-builder to eager-load the nodes that are connected to
// the "entity_types" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery {
query := (&EntityTypeClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withEntityTypes = query
return _q
}
// WithItemTemplates tells the query-builder to eager-load the nodes that are connected to
// the "item_templates" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithItemTemplates(opts ...func(*ItemTemplateQuery)) *GroupQuery {
@@ -590,11 +590,11 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
_spec = _q.querySpec()
loadedTypes = [7]bool{
_q.withUsers != nil,
_q.withLocations != nil,
_q.withItems != nil,
_q.withEntities != nil,
_q.withLabels != nil,
_q.withInvitationTokens != nil,
_q.withNotifiers != nil,
_q.withEntityTypes != nil,
_q.withItemTemplates != nil,
}
)
@@ -623,17 +623,10 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
if query := _q.withLocations; query != nil {
if err := _q.loadLocations(ctx, query, nodes,
func(n *Group) { n.Edges.Locations = []*Location{} },
func(n *Group, e *Location) { n.Edges.Locations = append(n.Edges.Locations, e) }); err != nil {
return nil, err
}
}
if query := _q.withItems; query != nil {
if err := _q.loadItems(ctx, query, nodes,
func(n *Group) { n.Edges.Items = []*Item{} },
func(n *Group, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
if query := _q.withEntities; query != nil {
if err := _q.loadEntities(ctx, query, nodes,
func(n *Group) { n.Edges.Entities = []*Entity{} },
func(n *Group, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
return nil, err
}
}
@@ -660,6 +653,13 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
if query := _q.withEntityTypes; query != nil {
if err := _q.loadEntityTypes(ctx, query, nodes,
func(n *Group) { n.Edges.EntityTypes = []*EntityType{} },
func(n *Group, e *EntityType) { n.Edges.EntityTypes = append(n.Edges.EntityTypes, e) }); err != nil {
return nil, err
}
}
if query := _q.withItemTemplates; query != nil {
if err := _q.loadItemTemplates(ctx, query, nodes,
func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} },
@@ -701,7 +701,7 @@ func (_q *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
}
return nil
}
func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, nodes []*Group, init func(*Group), assign func(*Group, *Location)) error {
func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
@@ -712,52 +712,21 @@ func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, n
}
}
query.withFKs = true
query.Where(predicate.Location(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.LocationsColumn), fks...))
query.Where(predicate.Entity(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.EntitiesColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_locations
fk := n.group_entities
if fk == nil {
return fmt.Errorf(`foreign-key "group_locations" is nil for node %v`, n.ID)
return fmt.Errorf(`foreign-key "group_entities" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_locations" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *GroupQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Group, init func(*Group), assign func(*Group, *Item)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Item(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.ItemsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_items
if fk == nil {
return fmt.Errorf(`foreign-key "group_items" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_items" returned %v for node %v`, *fk, n.ID)
return fmt.Errorf(`unexpected referenced foreign-key "group_entities" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
@@ -855,6 +824,37 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n
}
return nil
}
func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.EntityType(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.EntityTypesColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_entity_types
if fk == nil {
return fmt.Errorf(`foreign-key "group_entity_types" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_entity_types" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *GroupQuery) loadItemTemplates(ctx context.Context, query *ItemTemplateQuery, nodes []*Group, init func(*Group), assign func(*Group, *ItemTemplate)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)

View File

@@ -12,12 +12,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
@@ -85,34 +85,19 @@ func (_u *GroupUpdate) AddUsers(v ...*User) *GroupUpdate {
return _u.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdate) AddLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdate) AddEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdate) AddLocations(v ...*Location) *GroupUpdate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdate) AddEntities(v ...*Entity) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *GroupUpdate) AddItemIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *GroupUpdate) AddItems(v ...*Item) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -160,6 +145,21 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate {
return _u.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_u *GroupUpdate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddEntityTypeIDs(ids...)
return _u
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_u *GroupUpdate) AddEntityTypes(v ...*EntityType) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_u *GroupUpdate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddItemTemplateIDs(ids...)
@@ -201,46 +201,25 @@ func (_u *GroupUpdate) RemoveUsers(v ...*User) *GroupUpdate {
return _u.RemoveUserIDs(ids...)
}
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdate) ClearLocations() *GroupUpdate {
_u.mutation.ClearLocations()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdate) ClearEntities() *GroupUpdate {
_u.mutation.ClearEntities()
return _u
}
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdate) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveLocationIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdate) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdate) RemoveLocations(v ...*Location) *GroupUpdate {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdate) RemoveEntities(v ...*Entity) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveLocationIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *GroupUpdate) ClearItems() *GroupUpdate {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *GroupUpdate) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *GroupUpdate) RemoveItems(v ...*Item) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -306,6 +285,27 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate {
return _u.RemoveNotifierIDs(ids...)
}
// ClearEntityTypes clears all "entity_types" edges to the EntityType entity.
func (_u *GroupUpdate) ClearEntityTypes() *GroupUpdate {
_u.mutation.ClearEntityTypes()
return _u
}
// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs.
func (_u *GroupUpdate) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveEntityTypeIDs(ids...)
return _u
}
// RemoveEntityTypes removes "entity_types" edges to EntityType entities.
func (_u *GroupUpdate) RemoveEntityTypes(v ...*EntityType) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityTypeIDs(ids...)
}
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate {
_u.mutation.ClearItemTemplates()
@@ -439,28 +439,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.LocationsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -468,60 +468,15 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -664,6 +619,51 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemTemplatesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
@@ -778,34 +778,19 @@ func (_u *GroupUpdateOne) AddUsers(v ...*User) *GroupUpdateOne {
return _u.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdateOne) AddLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdateOne) AddEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdateOne) AddLocations(v ...*Location) *GroupUpdateOne {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) AddEntities(v ...*Entity) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *GroupUpdateOne) AddItemIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *GroupUpdateOne) AddItems(v ...*Item) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -853,6 +838,21 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_u *GroupUpdateOne) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddEntityTypeIDs(ids...)
return _u
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_u *GroupUpdateOne) AddEntityTypes(v ...*EntityType) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_u *GroupUpdateOne) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddItemTemplateIDs(ids...)
@@ -894,46 +894,25 @@ func (_u *GroupUpdateOne) RemoveUsers(v ...*User) *GroupUpdateOne {
return _u.RemoveUserIDs(ids...)
}
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdateOne) ClearLocations() *GroupUpdateOne {
_u.mutation.ClearLocations()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) ClearEntities() *GroupUpdateOne {
_u.mutation.ClearEntities()
return _u
}
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdateOne) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveLocationIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdateOne) RemoveLocations(v ...*Location) *GroupUpdateOne {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdateOne) RemoveEntities(v ...*Entity) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveLocationIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *GroupUpdateOne) ClearItems() *GroupUpdateOne {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *GroupUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *GroupUpdateOne) RemoveItems(v ...*Item) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -999,6 +978,27 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.RemoveNotifierIDs(ids...)
}
// ClearEntityTypes clears all "entity_types" edges to the EntityType entity.
func (_u *GroupUpdateOne) ClearEntityTypes() *GroupUpdateOne {
_u.mutation.ClearEntityTypes()
return _u
}
// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs.
func (_u *GroupUpdateOne) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveEntityTypeIDs(ids...)
return _u
}
// RemoveEntityTypes removes "entity_types" edges to EntityType entities.
func (_u *GroupUpdateOne) RemoveEntityTypes(v ...*EntityType) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityTypeIDs(ids...)
}
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne {
_u.mutation.ClearItemTemplates()
@@ -1162,28 +1162,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.LocationsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -1191,60 +1191,15 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -1387,6 +1342,51 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemTemplatesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -16,6 +16,18 @@ func (_m *AuthTokens) GetID() uuid.UUID {
return _m.ID
}
func (_m *Entity) GetID() uuid.UUID {
return _m.ID
}
func (_m *EntityField) GetID() uuid.UUID {
return _m.ID
}
func (_m *EntityType) GetID() uuid.UUID {
return _m.ID
}
func (_m *Group) GetID() uuid.UUID {
return _m.ID
}
@@ -24,14 +36,6 @@ func (_m *GroupInvitationToken) GetID() uuid.UUID {
return _m.ID
}
func (_m *Item) GetID() uuid.UUID {
return _m.ID
}
func (_m *ItemField) GetID() uuid.UUID {
return _m.ID
}
func (_m *ItemTemplate) GetID() uuid.UUID {
return _m.ID
}
@@ -40,10 +44,6 @@ func (_m *Label) GetID() uuid.UUID {
return _m.ID
}
func (_m *Location) GetID() uuid.UUID {
return _m.ID
}
func (_m *MaintenanceEntry) GetID() uuid.UUID {
return _m.ID
}

View File

@@ -45,6 +45,42 @@ func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m)
}
// The EntityFunc type is an adapter to allow the use of ordinary
// function as Entity mutator.
type EntityFunc func(context.Context, *ent.EntityMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityMutation", m)
}
// The EntityFieldFunc type is an adapter to allow the use of ordinary
// function as EntityField mutator.
type EntityFieldFunc func(context.Context, *ent.EntityFieldMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityFieldMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityFieldMutation", m)
}
// The EntityTypeFunc type is an adapter to allow the use of ordinary
// function as EntityType mutator.
type EntityTypeFunc func(context.Context, *ent.EntityTypeMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityTypeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityTypeMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityTypeMutation", m)
}
// The GroupFunc type is an adapter to allow the use of ordinary
// function as Group mutator.
type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)
@@ -69,30 +105,6 @@ func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (e
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m)
}
// The ItemFunc type is an adapter to allow the use of ordinary
// function as Item mutator.
type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ItemMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m)
}
// The ItemFieldFunc type is an adapter to allow the use of ordinary
// function as ItemField mutator.
type ItemFieldFunc func(context.Context, *ent.ItemFieldMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ItemFieldMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
}
// The ItemTemplateFunc type is an adapter to allow the use of ordinary
// function as ItemTemplate mutator.
type ItemTemplateFunc func(context.Context, *ent.ItemTemplateMutation) (ent.Value, error)
@@ -117,18 +129,6 @@ func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m)
}
// The LocationFunc type is an adapter to allow the use of ordinary
// function as Location mutator.
type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.LocationMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m)
}
// The MaintenanceEntryFunc type is an adapter to allow the use of ordinary
// function as MaintenanceEntry mutator.
type MaintenanceEntryFunc func(context.Context, *ent.MaintenanceEntryMutation) (ent.Value, error)

File diff suppressed because it is too large Load Diff

View File

@@ -1,550 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package itemfield
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldUpdatedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldName, v))
}
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldDescription, v))
}
// TextValue applies equality check predicate on the "text_value" field. It's identical to TextValueEQ.
func TextValue(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldTextValue, v))
}
// NumberValue applies equality check predicate on the "number_value" field. It's identical to NumberValueEQ.
func NumberValue(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldNumberValue, v))
}
// BooleanValue applies equality check predicate on the "boolean_value" field. It's identical to BooleanValueEQ.
func BooleanValue(v bool) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldBooleanValue, v))
}
// TimeValue applies equality check predicate on the "time_value" field. It's identical to TimeValueEQ.
func TimeValue(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldTimeValue, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldUpdatedAt, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContainsFold(FieldName, v))
}
// DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldDescription, v))
}
// DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldDescription, v))
}
// DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldDescription, vs...))
}
// DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldDescription, vs...))
}
// DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldDescription, v))
}
// DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldDescription, v))
}
// DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldDescription, v))
}
// DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldDescription, v))
}
// DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContains(FieldDescription, v))
}
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasPrefix(FieldDescription, v))
}
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasSuffix(FieldDescription, v))
}
// DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.ItemField {
return predicate.ItemField(sql.FieldIsNull(FieldDescription))
}
// DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.ItemField {
return predicate.ItemField(sql.FieldNotNull(FieldDescription))
}
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEqualFold(FieldDescription, v))
}
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContainsFold(FieldDescription, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v Type) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v Type) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...Type) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...Type) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldType, vs...))
}
// TextValueEQ applies the EQ predicate on the "text_value" field.
func TextValueEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldTextValue, v))
}
// TextValueNEQ applies the NEQ predicate on the "text_value" field.
func TextValueNEQ(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldTextValue, v))
}
// TextValueIn applies the In predicate on the "text_value" field.
func TextValueIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldTextValue, vs...))
}
// TextValueNotIn applies the NotIn predicate on the "text_value" field.
func TextValueNotIn(vs ...string) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldTextValue, vs...))
}
// TextValueGT applies the GT predicate on the "text_value" field.
func TextValueGT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldTextValue, v))
}
// TextValueGTE applies the GTE predicate on the "text_value" field.
func TextValueGTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldTextValue, v))
}
// TextValueLT applies the LT predicate on the "text_value" field.
func TextValueLT(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldTextValue, v))
}
// TextValueLTE applies the LTE predicate on the "text_value" field.
func TextValueLTE(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldTextValue, v))
}
// TextValueContains applies the Contains predicate on the "text_value" field.
func TextValueContains(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContains(FieldTextValue, v))
}
// TextValueHasPrefix applies the HasPrefix predicate on the "text_value" field.
func TextValueHasPrefix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasPrefix(FieldTextValue, v))
}
// TextValueHasSuffix applies the HasSuffix predicate on the "text_value" field.
func TextValueHasSuffix(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldHasSuffix(FieldTextValue, v))
}
// TextValueIsNil applies the IsNil predicate on the "text_value" field.
func TextValueIsNil() predicate.ItemField {
return predicate.ItemField(sql.FieldIsNull(FieldTextValue))
}
// TextValueNotNil applies the NotNil predicate on the "text_value" field.
func TextValueNotNil() predicate.ItemField {
return predicate.ItemField(sql.FieldNotNull(FieldTextValue))
}
// TextValueEqualFold applies the EqualFold predicate on the "text_value" field.
func TextValueEqualFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldEqualFold(FieldTextValue, v))
}
// TextValueContainsFold applies the ContainsFold predicate on the "text_value" field.
func TextValueContainsFold(v string) predicate.ItemField {
return predicate.ItemField(sql.FieldContainsFold(FieldTextValue, v))
}
// NumberValueEQ applies the EQ predicate on the "number_value" field.
func NumberValueEQ(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldNumberValue, v))
}
// NumberValueNEQ applies the NEQ predicate on the "number_value" field.
func NumberValueNEQ(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldNumberValue, v))
}
// NumberValueIn applies the In predicate on the "number_value" field.
func NumberValueIn(vs ...int) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldNumberValue, vs...))
}
// NumberValueNotIn applies the NotIn predicate on the "number_value" field.
func NumberValueNotIn(vs ...int) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldNumberValue, vs...))
}
// NumberValueGT applies the GT predicate on the "number_value" field.
func NumberValueGT(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldNumberValue, v))
}
// NumberValueGTE applies the GTE predicate on the "number_value" field.
func NumberValueGTE(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldNumberValue, v))
}
// NumberValueLT applies the LT predicate on the "number_value" field.
func NumberValueLT(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldNumberValue, v))
}
// NumberValueLTE applies the LTE predicate on the "number_value" field.
func NumberValueLTE(v int) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldNumberValue, v))
}
// NumberValueIsNil applies the IsNil predicate on the "number_value" field.
func NumberValueIsNil() predicate.ItemField {
return predicate.ItemField(sql.FieldIsNull(FieldNumberValue))
}
// NumberValueNotNil applies the NotNil predicate on the "number_value" field.
func NumberValueNotNil() predicate.ItemField {
return predicate.ItemField(sql.FieldNotNull(FieldNumberValue))
}
// BooleanValueEQ applies the EQ predicate on the "boolean_value" field.
func BooleanValueEQ(v bool) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldBooleanValue, v))
}
// BooleanValueNEQ applies the NEQ predicate on the "boolean_value" field.
func BooleanValueNEQ(v bool) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldBooleanValue, v))
}
// TimeValueEQ applies the EQ predicate on the "time_value" field.
func TimeValueEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldEQ(FieldTimeValue, v))
}
// TimeValueNEQ applies the NEQ predicate on the "time_value" field.
func TimeValueNEQ(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNEQ(FieldTimeValue, v))
}
// TimeValueIn applies the In predicate on the "time_value" field.
func TimeValueIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldIn(FieldTimeValue, vs...))
}
// TimeValueNotIn applies the NotIn predicate on the "time_value" field.
func TimeValueNotIn(vs ...time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldNotIn(FieldTimeValue, vs...))
}
// TimeValueGT applies the GT predicate on the "time_value" field.
func TimeValueGT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGT(FieldTimeValue, v))
}
// TimeValueGTE applies the GTE predicate on the "time_value" field.
func TimeValueGTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldGTE(FieldTimeValue, v))
}
// TimeValueLT applies the LT predicate on the "time_value" field.
func TimeValueLT(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLT(FieldTimeValue, v))
}
// TimeValueLTE applies the LTE predicate on the "time_value" field.
func TimeValueLTE(v time.Time) predicate.ItemField {
return predicate.ItemField(sql.FieldLTE(FieldTimeValue, v))
}
// HasItem applies the HasEdge predicate on the "item" edge.
func HasItem() predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemWith applies the HasEdge predicate on the "item" edge with a given conditions (other predicates).
func HasItemWith(preds ...predicate.Item) predicate.ItemField {
return predicate.ItemField(func(s *sql.Selector) {
step := newItemStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.ItemField) predicate.ItemField {
return predicate.ItemField(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ItemField) predicate.ItemField {
return predicate.ItemField(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ItemField) predicate.ItemField {
return predicate.ItemField(sql.NotPredicates(p))
}

View File

@@ -11,9 +11,9 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
)
// ItemTemplate is the model entity for the ItemTemplate schema.
@@ -70,7 +70,7 @@ type ItemTemplateEdges struct {
// Fields holds the value of the fields edge.
Fields []*TemplateField `json:"fields,omitempty"`
// Location holds the value of the location edge.
Location *Location `json:"location,omitempty"`
Location *Entity `json:"location,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [3]bool
@@ -98,11 +98,11 @@ func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) {
// LocationOrErr returns the Location value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemTemplateEdges) LocationOrErr() (*Location, error) {
func (e ItemTemplateEdges) LocationOrErr() (*Entity, error) {
if e.Location != nil {
return e.Location, nil
} else if e.loadedTypes[2] {
return nil, &NotFoundError{label: location.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "location"}
}
@@ -291,7 +291,7 @@ func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery {
}
// QueryLocation queries the "location" edge of the ItemTemplate entity.
func (_m *ItemTemplate) QueryLocation() *LocationQuery {
func (_m *ItemTemplate) QueryLocation() *EntityQuery {
return NewItemTemplateClient(_m.config).QueryLocation(_m)
}

View File

@@ -73,9 +73,9 @@ const (
FieldsColumn = "item_template_fields"
// LocationTable is the table that holds the location relation/edge.
LocationTable = "item_templates"
// LocationInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationInverseTable = "locations"
// LocationInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
LocationInverseTable = "entities"
// LocationColumn is the table column denoting the location relation/edge.
LocationColumn = "item_template_location"
)

View File

@@ -964,7 +964,7 @@ func HasLocation() predicate.ItemTemplate {
}
// HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates).
func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate {
func HasLocationWith(preds ...predicate.Entity) predicate.ItemTemplate {
return predicate.ItemTemplate(func(s *sql.Selector) {
step := newLocationStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {

View File

@@ -11,9 +11,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -286,13 +286,13 @@ func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate
return _c.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate {
_c.mutation.SetLocationID(id)
return _c
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateCreate {
if id != nil {
_c = _c.SetLocationID(*id)
@@ -300,8 +300,8 @@ func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate
return _c
}
// SetLocation sets the "location" edge to the Location entity.
func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate {
// SetLocation sets the "location" edge to the Entity entity.
func (_c *ItemTemplateCreate) SetLocation(v *Entity) *ItemTemplateCreate {
return _c.SetLocationID(v.ID)
}
@@ -594,7 +594,7 @@ func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec)
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -13,9 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -29,7 +29,7 @@ type ItemTemplateQuery struct {
predicates []predicate.ItemTemplate
withGroup *GroupQuery
withFields *TemplateFieldQuery
withLocation *LocationQuery
withLocation *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -112,8 +112,8 @@ func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery {
}
// QueryLocation chains the current query on the "location" edge.
func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) QueryLocation() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -124,7 +124,7 @@ func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
@@ -358,8 +358,8 @@ func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *Item
// WithLocation tells the query-builder to eager-load the nodes that are connected to
// the "location" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery {
query := (&LocationClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*EntityQuery)) *ItemTemplateQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -491,7 +491,7 @@ func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
}
if query := _q.withLocation; query != nil {
if err := _q.loadLocation(ctx, query, nodes, nil,
func(n *ItemTemplate, e *Location) { n.Edges.Location = e }); err != nil {
func(n *ItemTemplate, e *Entity) { n.Edges.Location = e }); err != nil {
return nil, err
}
}
@@ -561,7 +561,7 @@ func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFiel
}
return nil
}
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error {
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *EntityQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*ItemTemplate)
for i := range nodes {
@@ -577,7 +577,7 @@ func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQu
if len(ids) == 0 {
return nil
}
query.Where(location.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err

View File

@@ -13,9 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -328,13 +328,13 @@ func (_u *ItemTemplateUpdate) AddFields(v ...*TemplateField) *ItemTemplateUpdate
return _u.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_u *ItemTemplateUpdate) SetLocationID(id uuid.UUID) *ItemTemplateUpdate {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdate {
if id != nil {
_u = _u.SetLocationID(*id)
@@ -342,8 +342,8 @@ func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate
return _u
}
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Location) *ItemTemplateUpdate {
// SetLocation sets the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Entity) *ItemTemplateUpdate {
return _u.SetLocationID(v.ID)
}
@@ -379,7 +379,7 @@ func (_u *ItemTemplateUpdate) RemoveFields(v ...*TemplateField) *ItemTemplateUpd
return _u.RemoveFieldIDs(ids...)
}
// ClearLocation clears the "location" edge to the Location entity.
// ClearLocation clears the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdate) ClearLocation() *ItemTemplateUpdate {
_u.mutation.ClearLocation()
return _u
@@ -643,7 +643,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -656,7 +656,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -979,13 +979,13 @@ func (_u *ItemTemplateUpdateOne) AddFields(v ...*TemplateField) *ItemTemplateUpd
return _u.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_u *ItemTemplateUpdateOne) SetLocationID(id uuid.UUID) *ItemTemplateUpdateOne {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdateOne {
if id != nil {
_u = _u.SetLocationID(*id)
@@ -993,8 +993,8 @@ func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTempl
return _u
}
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *ItemTemplateUpdateOne {
// SetLocation sets the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Entity) *ItemTemplateUpdateOne {
return _u.SetLocationID(v.ID)
}
@@ -1030,7 +1030,7 @@ func (_u *ItemTemplateUpdateOne) RemoveFields(v ...*TemplateField) *ItemTemplate
return _u.RemoveFieldIDs(ids...)
}
// ClearLocation clears the "location" edge to the Location entity.
// ClearLocation clears the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdateOne) ClearLocation() *ItemTemplateUpdateOne {
_u.mutation.ClearLocation()
return _u
@@ -1324,7 +1324,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1337,7 +1337,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -40,8 +40,8 @@ type Label struct {
type LabelEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
@@ -58,13 +58,13 @@ func (e LabelEdges) GroupOrErr() (*Group, error) {
return nil, &NotLoadedError{edge: "group"}
}
// ItemsOrErr returns the Items value or an error if the edge
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e LabelEdges) ItemsOrErr() ([]*Item, error) {
func (e LabelEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Items, nil
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "items"}
return nil, &NotLoadedError{edge: "entities"}
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -156,9 +156,9 @@ func (_m *Label) QueryGroup() *GroupQuery {
return NewLabelClient(_m.config).QueryGroup(_m)
}
// QueryItems queries the "items" edge of the Label entity.
func (_m *Label) QueryItems() *ItemQuery {
return NewLabelClient(_m.config).QueryItems(_m)
// QueryEntities queries the "entities" edge of the Label entity.
func (_m *Label) QueryEntities() *EntityQuery {
return NewLabelClient(_m.config).QueryEntities(_m)
}
// Update returns a builder for updating this Label.

View File

@@ -27,8 +27,8 @@ const (
FieldColor = "color"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// EdgeItems holds the string denoting the items edge name in mutations.
EdgeItems = "items"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// Table holds the table name of the label in the database.
Table = "labels"
// GroupTable is the table that holds the group relation/edge.
@@ -38,11 +38,11 @@ const (
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
GroupColumn = "group_labels"
// ItemsTable is the table that holds the items relation/edge. The primary key declared below.
ItemsTable = "label_items"
// ItemsInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemsInverseTable = "items"
// EntitiesTable is the table that holds the entities relation/edge. The primary key declared below.
EntitiesTable = "label_entities"
// EntitiesInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntitiesInverseTable = "entities"
)
// Columns holds all SQL columns for label fields.
@@ -62,9 +62,9 @@ var ForeignKeys = []string{
}
var (
// ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the
// primary key for the items relation (M2M).
ItemsPrimaryKey = []string{"label_id", "item_id"}
// EntitiesPrimaryKey and EntitiesColumn2 are the table columns denoting the
// primary key for the entities relation (M2M).
EntitiesPrimaryKey = []string{"label_id", "entity_id"}
)
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -139,17 +139,17 @@ func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
}
}
// ByItemsCount orders the results by items count.
func ByItemsCount(opts ...sql.OrderTermOption) OrderOption {
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...)
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
}
}
// ByItems orders the results by items terms.
func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...)
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newGroupStep() *sqlgraph.Step {
@@ -159,10 +159,10 @@ func newGroupStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newItemsStep() *sqlgraph.Step {
func newEntitiesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, EntitiesTable, EntitiesPrimaryKey...),
)
}

View File

@@ -399,21 +399,21 @@ func HasGroupWith(preds ...predicate.Group) predicate.Label {
})
}
// HasItems applies the HasEdge predicate on the "items" edge.
func HasItems() predicate.Label {
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.Label {
return predicate.Label(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
sqlgraph.Edge(sqlgraph.M2M, false, EntitiesTable, EntitiesPrimaryKey...),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
func HasItemsWith(preds ...predicate.Item) predicate.Label {
// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates).
func HasEntitiesWith(preds ...predicate.Entity) predicate.Label {
return predicate.Label(func(s *sql.Selector) {
step := newItemsStep()
step := newEntitiesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -11,8 +11,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
)
@@ -110,19 +110,19 @@ func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate {
return _c.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddEntityIDs(ids...)
return _c
}
// AddItems adds the "items" edges to the Item entity.
func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddItemIDs(ids...)
return _c.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -275,15 +275,15 @@ func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
_node.group_labels = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -13,8 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -22,13 +22,13 @@ import (
// LabelQuery is the builder for querying Label entities.
type LabelQuery struct {
config
ctx *QueryContext
order []label.OrderOption
inters []Interceptor
predicates []predicate.Label
withGroup *GroupQuery
withItems *ItemQuery
withFKs bool
ctx *QueryContext
order []label.OrderOption
inters []Interceptor
predicates []predicate.Label
withGroup *GroupQuery
withEntities *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -87,9 +87,9 @@ func (_q *LabelQuery) QueryGroup() *GroupQuery {
return query
}
// QueryItems chains the current query on the "items" edge.
func (_q *LabelQuery) QueryItems() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntities chains the current query on the "entities" edge.
func (_q *LabelQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -100,8 +100,8 @@ func (_q *LabelQuery) QueryItems() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(label.Table, label.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -296,13 +296,13 @@ func (_q *LabelQuery) Clone() *LabelQuery {
return nil
}
return &LabelQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]label.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Label{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withItems: _q.withItems.Clone(),
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]label.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Label{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withEntities: _q.withEntities.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
@@ -320,14 +320,14 @@ func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
return _q
}
// WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntities tells the query-builder to eager-load the nodes that are connected to
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItems = query
_q.withEntities = query
return _q
}
@@ -412,7 +412,7 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withGroup != nil,
_q.withItems != nil,
_q.withEntities != nil,
}
)
if _q.withGroup != nil {
@@ -445,10 +445,10 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
return nil, err
}
}
if query := _q.withItems; query != nil {
if err := _q.loadItems(ctx, query, nodes,
func(n *Label) { n.Edges.Items = []*Item{} },
func(n *Label, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
if query := _q.withEntities; query != nil {
if err := _q.loadEntities(ctx, query, nodes,
func(n *Label) { n.Edges.Entities = []*Entity{} },
func(n *Label, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
return nil, err
}
}
@@ -487,7 +487,7 @@ func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []
}
return nil
}
func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) error {
func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error {
edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uuid.UUID]*Label)
nids := make(map[uuid.UUID]map[*Label]struct{})
@@ -499,11 +499,11 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
}
}
query.Where(func(s *sql.Selector) {
joinT := sql.Table(label.ItemsTable)
s.Join(joinT).On(s.C(item.FieldID), joinT.C(label.ItemsPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(label.ItemsPrimaryKey[0]), edgeIDs...))
joinT := sql.Table(label.EntitiesTable)
s.Join(joinT).On(s.C(entity.FieldID), joinT.C(label.EntitiesPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(label.EntitiesPrimaryKey[0]), edgeIDs...))
columns := s.SelectedColumns()
s.Select(joinT.C(label.ItemsPrimaryKey[0]))
s.Select(joinT.C(label.EntitiesPrimaryKey[0]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
@@ -533,14 +533,14 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
}
})
})
neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters)
neighbors, err := withInterceptors[[]*Entity](ctx, query, qr, query.inters)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nids[n.ID]
if !ok {
return fmt.Errorf(`unexpected "items" node returned %v`, n.ID)
return fmt.Errorf(`unexpected "entities" node returned %v`, n.ID)
}
for kn := range nodes {
assign(kn, n)

View File

@@ -12,8 +12,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -102,19 +102,19 @@ func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate {
return _u.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -128,25 +128,25 @@ func (_u *LabelUpdate) ClearGroup() *LabelUpdate {
return _u
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdate) ClearItems() *LabelUpdate {
_u.mutation.ClearItems()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdate) ClearEntities() *LabelUpdate {
_u.mutation.ClearEntities()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveItemIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
@@ -267,28 +267,28 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -296,15 +296,15 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -403,19 +403,19 @@ func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne {
return _u.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -429,25 +429,25 @@ func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
return _u
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne {
_u.mutation.ClearItems()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne {
_u.mutation.ClearEntities()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// Where appends a list predicates to the LabelUpdate builder.
@@ -598,28 +598,28 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -627,15 +627,15 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -1,404 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package location
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id uuid.UUID) predicate.Location {
return predicate.Location(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldUpdatedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldName, v))
}
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func Description(v string) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldDescription, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Location {
return predicate.Location(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Location {
return predicate.Location(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Location {
return predicate.Location(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Location {
return predicate.Location(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Location {
return predicate.Location(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Location {
return predicate.Location(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Location {
return predicate.Location(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Location {
return predicate.Location(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Location {
return predicate.Location(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Location {
return predicate.Location(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Location {
return predicate.Location(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Location {
return predicate.Location(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Location {
return predicate.Location(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Location {
return predicate.Location(sql.FieldLTE(FieldUpdatedAt, v))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Location {
return predicate.Location(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Location {
return predicate.Location(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Location {
return predicate.Location(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Location {
return predicate.Location(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Location {
return predicate.Location(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Location {
return predicate.Location(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Location {
return predicate.Location(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Location {
return predicate.Location(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Location {
return predicate.Location(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Location {
return predicate.Location(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Location {
return predicate.Location(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Location {
return predicate.Location(sql.FieldContainsFold(FieldName, v))
}
// DescriptionEQ applies the EQ predicate on the "description" field.
func DescriptionEQ(v string) predicate.Location {
return predicate.Location(sql.FieldEQ(FieldDescription, v))
}
// DescriptionNEQ applies the NEQ predicate on the "description" field.
func DescriptionNEQ(v string) predicate.Location {
return predicate.Location(sql.FieldNEQ(FieldDescription, v))
}
// DescriptionIn applies the In predicate on the "description" field.
func DescriptionIn(vs ...string) predicate.Location {
return predicate.Location(sql.FieldIn(FieldDescription, vs...))
}
// DescriptionNotIn applies the NotIn predicate on the "description" field.
func DescriptionNotIn(vs ...string) predicate.Location {
return predicate.Location(sql.FieldNotIn(FieldDescription, vs...))
}
// DescriptionGT applies the GT predicate on the "description" field.
func DescriptionGT(v string) predicate.Location {
return predicate.Location(sql.FieldGT(FieldDescription, v))
}
// DescriptionGTE applies the GTE predicate on the "description" field.
func DescriptionGTE(v string) predicate.Location {
return predicate.Location(sql.FieldGTE(FieldDescription, v))
}
// DescriptionLT applies the LT predicate on the "description" field.
func DescriptionLT(v string) predicate.Location {
return predicate.Location(sql.FieldLT(FieldDescription, v))
}
// DescriptionLTE applies the LTE predicate on the "description" field.
func DescriptionLTE(v string) predicate.Location {
return predicate.Location(sql.FieldLTE(FieldDescription, v))
}
// DescriptionContains applies the Contains predicate on the "description" field.
func DescriptionContains(v string) predicate.Location {
return predicate.Location(sql.FieldContains(FieldDescription, v))
}
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func DescriptionHasPrefix(v string) predicate.Location {
return predicate.Location(sql.FieldHasPrefix(FieldDescription, v))
}
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func DescriptionHasSuffix(v string) predicate.Location {
return predicate.Location(sql.FieldHasSuffix(FieldDescription, v))
}
// DescriptionIsNil applies the IsNil predicate on the "description" field.
func DescriptionIsNil() predicate.Location {
return predicate.Location(sql.FieldIsNull(FieldDescription))
}
// DescriptionNotNil applies the NotNil predicate on the "description" field.
func DescriptionNotNil() predicate.Location {
return predicate.Location(sql.FieldNotNull(FieldDescription))
}
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func DescriptionEqualFold(v string) predicate.Location {
return predicate.Location(sql.FieldEqualFold(FieldDescription, v))
}
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func DescriptionContainsFold(v string) predicate.Location {
return predicate.Location(sql.FieldContainsFold(FieldDescription, v))
}
// HasGroup applies the HasEdge predicate on the "group" edge.
func HasGroup() predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
func HasGroupWith(preds ...predicate.Group) predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := newGroupStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasParent applies the HasEdge predicate on the "parent" edge.
func HasParent() predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates).
func HasParentWith(preds ...predicate.Location) predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := newParentStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasChildren applies the HasEdge predicate on the "children" edge.
func HasChildren() predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates).
func HasChildrenWith(preds ...predicate.Location) predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := newChildrenStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasItems applies the HasEdge predicate on the "items" edge.
func HasItems() predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
func HasItemsWith(preds ...predicate.Item) predicate.Location {
return predicate.Location(func(s *sql.Selector) {
step := newItemsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Location) predicate.Location {
return predicate.Location(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Location) predicate.Location {
return predicate.Location(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Location) predicate.Location {
return predicate.Location(sql.NotPredicates(p))
}

View File

@@ -1,839 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// LocationQuery is the builder for querying Location entities.
type LocationQuery struct {
config
ctx *QueryContext
order []location.OrderOption
inters []Interceptor
predicates []predicate.Location
withGroup *GroupQuery
withParent *LocationQuery
withChildren *LocationQuery
withItems *ItemQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the LocationQuery builder.
func (_q *LocationQuery) Where(ps ...predicate.Location) *LocationQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *LocationQuery) Limit(limit int) *LocationQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *LocationQuery) Offset(offset int) *LocationQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *LocationQuery) Unique(unique bool) *LocationQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *LocationQuery) Order(o ...location.OrderOption) *LocationQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryGroup chains the current query on the "group" edge.
func (_q *LocationQuery) QueryGroup() *GroupQuery {
query := (&GroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(location.Table, location.FieldID, selector),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, location.GroupTable, location.GroupColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryParent chains the current query on the "parent" edge.
func (_q *LocationQuery) QueryParent() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(location.Table, location.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, location.ParentTable, location.ParentColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryChildren chains the current query on the "children" edge.
func (_q *LocationQuery) QueryChildren() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(location.Table, location.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, location.ChildrenTable, location.ChildrenColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryItems chains the current query on the "items" edge.
func (_q *LocationQuery) QueryItems() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(location.Table, location.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, location.ItemsTable, location.ItemsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first Location entity from the query.
// Returns a *NotFoundError when no Location was found.
func (_q *LocationQuery) First(ctx context.Context) (*Location, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{location.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *LocationQuery) FirstX(ctx context.Context) *Location {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first Location ID from the query.
// Returns a *NotFoundError when no Location ID was found.
func (_q *LocationQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{location.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *LocationQuery) FirstIDX(ctx context.Context) uuid.UUID {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single Location entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one Location entity is found.
// Returns a *NotFoundError when no Location entities are found.
func (_q *LocationQuery) Only(ctx context.Context) (*Location, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{location.Label}
default:
return nil, &NotSingularError{location.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *LocationQuery) OnlyX(ctx context.Context) *Location {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only Location ID in the query.
// Returns a *NotSingularError when more than one Location ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *LocationQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
var ids []uuid.UUID
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{location.Label}
default:
err = &NotSingularError{location.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *LocationQuery) OnlyIDX(ctx context.Context) uuid.UUID {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of Locations.
func (_q *LocationQuery) All(ctx context.Context) ([]*Location, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*Location, *LocationQuery]()
return withInterceptors[[]*Location](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *LocationQuery) AllX(ctx context.Context) []*Location {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of Location IDs.
func (_q *LocationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(location.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *LocationQuery) IDsX(ctx context.Context) []uuid.UUID {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *LocationQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*LocationQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *LocationQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *LocationQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *LocationQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the LocationQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *LocationQuery) Clone() *LocationQuery {
if _q == nil {
return nil
}
return &LocationQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]location.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Location{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withParent: _q.withParent.Clone(),
withChildren: _q.withChildren.Clone(),
withItems: _q.withItems.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LocationQuery) WithGroup(opts ...func(*GroupQuery)) *LocationQuery {
query := (&GroupClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withGroup = query
return _q
}
// WithParent tells the query-builder to eager-load the nodes that are connected to
// the "parent" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LocationQuery) WithParent(opts ...func(*LocationQuery)) *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withParent = query
return _q
}
// WithChildren tells the query-builder to eager-load the nodes that are connected to
// the "children" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LocationQuery) WithChildren(opts ...func(*LocationQuery)) *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withChildren = query
return _q
}
// WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LocationQuery) WithItems(opts ...func(*ItemQuery)) *LocationQuery {
query := (&ItemClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItems = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.Location.Query().
// GroupBy(location.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &LocationGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = location.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.Location.Query().
// Select(location.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *LocationQuery) Select(fields ...string) *LocationSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &LocationSelect{LocationQuery: _q}
sbuild.label = location.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a LocationSelect configured with the given aggregations.
func (_q *LocationQuery) Aggregate(fns ...AggregateFunc) *LocationSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *LocationQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !location.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *LocationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Location, error) {
var (
nodes = []*Location{}
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [4]bool{
_q.withGroup != nil,
_q.withParent != nil,
_q.withChildren != nil,
_q.withItems != nil,
}
)
if _q.withGroup != nil || _q.withParent != nil {
withFKs = true
}
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, location.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Location).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Location{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withGroup; query != nil {
if err := _q.loadGroup(ctx, query, nodes, nil,
func(n *Location, e *Group) { n.Edges.Group = e }); err != nil {
return nil, err
}
}
if query := _q.withParent; query != nil {
if err := _q.loadParent(ctx, query, nodes, nil,
func(n *Location, e *Location) { n.Edges.Parent = e }); err != nil {
return nil, err
}
}
if query := _q.withChildren; query != nil {
if err := _q.loadChildren(ctx, query, nodes,
func(n *Location) { n.Edges.Children = []*Location{} },
func(n *Location, e *Location) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil {
return nil, err
}
}
if query := _q.withItems; query != nil {
if err := _q.loadItems(ctx, query, nodes,
func(n *Location) { n.Edges.Items = []*Item{} },
func(n *Location, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *LocationQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Location, init func(*Location), assign func(*Location, *Group)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*Location)
for i := range nodes {
if nodes[i].group_locations == nil {
continue
}
fk := *nodes[i].group_locations
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(group.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "group_locations" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *LocationQuery) loadParent(ctx context.Context, query *LocationQuery, nodes []*Location, init func(*Location), assign func(*Location, *Location)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*Location)
for i := range nodes {
if nodes[i].location_children == nil {
continue
}
fk := *nodes[i].location_children
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(location.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "location_children" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *LocationQuery) loadChildren(ctx context.Context, query *LocationQuery, nodes []*Location, init func(*Location), assign func(*Location, *Location)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Location)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Location(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(location.ChildrenColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.location_children
if fk == nil {
return fmt.Errorf(`foreign-key "location_children" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "location_children" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *LocationQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Location, init func(*Location), assign func(*Location, *Item)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Location)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Item(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(location.ItemsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.location_items
if fk == nil {
return fmt.Errorf(`foreign-key "location_items" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "location_items" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *LocationQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *LocationQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, location.FieldID)
for i := range fields {
if fields[i] != location.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *LocationQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(location.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = location.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// LocationGroupBy is the group-by builder for Location entities.
type LocationGroupBy struct {
selector
build *LocationQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *LocationGroupBy) Aggregate(fns ...AggregateFunc) *LocationGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *LocationGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*LocationQuery, *LocationGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *LocationGroupBy) sqlScan(ctx context.Context, root *LocationQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// LocationSelect is the builder for selecting fields of Location entities.
type LocationSelect struct {
*LocationQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *LocationSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*LocationQuery, *LocationSelect](ctx, _s.LocationQuery, _s, _s.inters, v)
}
func (_s *LocationSelect) sqlScan(ctx context.Context, root *LocationQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,867 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// LocationUpdate is the builder for updating Location entities.
type LocationUpdate struct {
config
hooks []Hook
mutation *LocationMutation
}
// Where appends a list predicates to the LocationUpdate builder.
func (_u *LocationUpdate) Where(ps ...predicate.Location) *LocationUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *LocationUpdate) SetUpdatedAt(v time.Time) *LocationUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *LocationUpdate) SetName(v string) *LocationUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *LocationUpdate) SetNillableName(v *string) *LocationUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDescription sets the "description" field.
func (_u *LocationUpdate) SetDescription(v string) *LocationUpdate {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *LocationUpdate) SetNillableDescription(v *string) *LocationUpdate {
if v != nil {
_u.SetDescription(*v)
}
return _u
}
// ClearDescription clears the value of the "description" field.
func (_u *LocationUpdate) ClearDescription() *LocationUpdate {
_u.mutation.ClearDescription()
return _u
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_u *LocationUpdate) SetGroupID(id uuid.UUID) *LocationUpdate {
_u.mutation.SetGroupID(id)
return _u
}
// SetGroup sets the "group" edge to the Group entity.
func (_u *LocationUpdate) SetGroup(v *Group) *LocationUpdate {
return _u.SetGroupID(v.ID)
}
// SetParentID sets the "parent" edge to the Location entity by ID.
func (_u *LocationUpdate) SetParentID(id uuid.UUID) *LocationUpdate {
_u.mutation.SetParentID(id)
return _u
}
// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil.
func (_u *LocationUpdate) SetNillableParentID(id *uuid.UUID) *LocationUpdate {
if id != nil {
_u = _u.SetParentID(*id)
}
return _u
}
// SetParent sets the "parent" edge to the Location entity.
func (_u *LocationUpdate) SetParent(v *Location) *LocationUpdate {
return _u.SetParentID(v.ID)
}
// AddChildIDs adds the "children" edge to the Location entity by IDs.
func (_u *LocationUpdate) AddChildIDs(ids ...uuid.UUID) *LocationUpdate {
_u.mutation.AddChildIDs(ids...)
return _u
}
// AddChildren adds the "children" edges to the Location entity.
func (_u *LocationUpdate) AddChildren(v ...*Location) *LocationUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddChildIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LocationUpdate) AddItemIDs(ids ...uuid.UUID) *LocationUpdate {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LocationUpdate) AddItems(v ...*Item) *LocationUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
}
// Mutation returns the LocationMutation object of the builder.
func (_u *LocationUpdate) Mutation() *LocationMutation {
return _u.mutation
}
// ClearGroup clears the "group" edge to the Group entity.
func (_u *LocationUpdate) ClearGroup() *LocationUpdate {
_u.mutation.ClearGroup()
return _u
}
// ClearParent clears the "parent" edge to the Location entity.
func (_u *LocationUpdate) ClearParent() *LocationUpdate {
_u.mutation.ClearParent()
return _u
}
// ClearChildren clears all "children" edges to the Location entity.
func (_u *LocationUpdate) ClearChildren() *LocationUpdate {
_u.mutation.ClearChildren()
return _u
}
// RemoveChildIDs removes the "children" edge to Location entities by IDs.
func (_u *LocationUpdate) RemoveChildIDs(ids ...uuid.UUID) *LocationUpdate {
_u.mutation.RemoveChildIDs(ids...)
return _u
}
// RemoveChildren removes "children" edges to Location entities.
func (_u *LocationUpdate) RemoveChildren(v ...*Location) *LocationUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveChildIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LocationUpdate) ClearItems() *LocationUpdate {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LocationUpdate) RemoveItemIDs(ids ...uuid.UUID) *LocationUpdate {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LocationUpdate) RemoveItems(v ...*Item) *LocationUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *LocationUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *LocationUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *LocationUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *LocationUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *LocationUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := location.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *LocationUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := location.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := location.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
}
}
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Location.group"`)
}
return nil
}
func (_u *LocationUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(location.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(location.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(location.FieldDescription, field.TypeString)
}
if _u.mutation.GroupCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ParentCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.ParentTable,
Columns: []string{location.ParentColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.ParentTable,
Columns: []string{location.ParentColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ChildrenCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{location.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// LocationUpdateOne is the builder for updating a single Location entity.
type LocationUpdateOne struct {
config
fields []string
hooks []Hook
mutation *LocationMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *LocationUpdateOne) SetUpdatedAt(v time.Time) *LocationUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *LocationUpdateOne) SetName(v string) *LocationUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *LocationUpdateOne) SetNillableName(v *string) *LocationUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetDescription sets the "description" field.
func (_u *LocationUpdateOne) SetDescription(v string) *LocationUpdateOne {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *LocationUpdateOne) SetNillableDescription(v *string) *LocationUpdateOne {
if v != nil {
_u.SetDescription(*v)
}
return _u
}
// ClearDescription clears the value of the "description" field.
func (_u *LocationUpdateOne) ClearDescription() *LocationUpdateOne {
_u.mutation.ClearDescription()
return _u
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_u *LocationUpdateOne) SetGroupID(id uuid.UUID) *LocationUpdateOne {
_u.mutation.SetGroupID(id)
return _u
}
// SetGroup sets the "group" edge to the Group entity.
func (_u *LocationUpdateOne) SetGroup(v *Group) *LocationUpdateOne {
return _u.SetGroupID(v.ID)
}
// SetParentID sets the "parent" edge to the Location entity by ID.
func (_u *LocationUpdateOne) SetParentID(id uuid.UUID) *LocationUpdateOne {
_u.mutation.SetParentID(id)
return _u
}
// SetNillableParentID sets the "parent" edge to the Location entity by ID if the given value is not nil.
func (_u *LocationUpdateOne) SetNillableParentID(id *uuid.UUID) *LocationUpdateOne {
if id != nil {
_u = _u.SetParentID(*id)
}
return _u
}
// SetParent sets the "parent" edge to the Location entity.
func (_u *LocationUpdateOne) SetParent(v *Location) *LocationUpdateOne {
return _u.SetParentID(v.ID)
}
// AddChildIDs adds the "children" edge to the Location entity by IDs.
func (_u *LocationUpdateOne) AddChildIDs(ids ...uuid.UUID) *LocationUpdateOne {
_u.mutation.AddChildIDs(ids...)
return _u
}
// AddChildren adds the "children" edges to the Location entity.
func (_u *LocationUpdateOne) AddChildren(v ...*Location) *LocationUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddChildIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LocationUpdateOne) AddItemIDs(ids ...uuid.UUID) *LocationUpdateOne {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LocationUpdateOne) AddItems(v ...*Item) *LocationUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
}
// Mutation returns the LocationMutation object of the builder.
func (_u *LocationUpdateOne) Mutation() *LocationMutation {
return _u.mutation
}
// ClearGroup clears the "group" edge to the Group entity.
func (_u *LocationUpdateOne) ClearGroup() *LocationUpdateOne {
_u.mutation.ClearGroup()
return _u
}
// ClearParent clears the "parent" edge to the Location entity.
func (_u *LocationUpdateOne) ClearParent() *LocationUpdateOne {
_u.mutation.ClearParent()
return _u
}
// ClearChildren clears all "children" edges to the Location entity.
func (_u *LocationUpdateOne) ClearChildren() *LocationUpdateOne {
_u.mutation.ClearChildren()
return _u
}
// RemoveChildIDs removes the "children" edge to Location entities by IDs.
func (_u *LocationUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *LocationUpdateOne {
_u.mutation.RemoveChildIDs(ids...)
return _u
}
// RemoveChildren removes "children" edges to Location entities.
func (_u *LocationUpdateOne) RemoveChildren(v ...*Location) *LocationUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveChildIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LocationUpdateOne) ClearItems() *LocationUpdateOne {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LocationUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LocationUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LocationUpdateOne) RemoveItems(v ...*Item) *LocationUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
}
// Where appends a list predicates to the LocationUpdate builder.
func (_u *LocationUpdateOne) Where(ps ...predicate.Location) *LocationUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *LocationUpdateOne) Select(field string, fields ...string) *LocationUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated Location entity.
func (_u *LocationUpdateOne) Save(ctx context.Context) (*Location, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *LocationUpdateOne) SaveX(ctx context.Context) *Location {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *LocationUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *LocationUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *LocationUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := location.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *LocationUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := location.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Location.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := location.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.description": %w`, err)}
}
}
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "Location.group"`)
}
return nil
}
func (_u *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Location.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, location.FieldID)
for _, f := range fields {
if !location.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != location.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(location.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(location.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(location.FieldDescription, field.TypeString)
}
if _u.mutation.GroupCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ParentCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.ParentTable,
Columns: []string{location.ParentColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: location.ParentTable,
Columns: []string{location.ParentColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ChildrenCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: location.ItemsTable,
Columns: []string{location.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Location{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{location.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}

View File

@@ -10,7 +10,7 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
)
@@ -23,8 +23,8 @@ type MaintenanceEntry struct {
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// ItemID holds the value of the "item_id" field.
ItemID uuid.UUID `json:"item_id,omitempty"`
// EntityID holds the value of the "entity_id" field.
EntityID uuid.UUID `json:"entity_id,omitempty"`
// Date holds the value of the "date" field.
Date time.Time `json:"date,omitempty"`
// ScheduledDate holds the value of the "scheduled_date" field.
@@ -43,22 +43,22 @@ type MaintenanceEntry struct {
// MaintenanceEntryEdges holds the relations/edges for other nodes in the graph.
type MaintenanceEntryEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e MaintenanceEntryEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -72,7 +72,7 @@ func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullString)
case maintenanceentry.FieldCreatedAt, maintenanceentry.FieldUpdatedAt, maintenanceentry.FieldDate, maintenanceentry.FieldScheduledDate:
values[i] = new(sql.NullTime)
case maintenanceentry.FieldID, maintenanceentry.FieldItemID:
case maintenanceentry.FieldID, maintenanceentry.FieldEntityID:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
@@ -107,11 +107,11 @@ func (_m *MaintenanceEntry) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case maintenanceentry.FieldItemID:
case maintenanceentry.FieldEntityID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field item_id", values[i])
return fmt.Errorf("unexpected type %T for field entity_id", values[i])
} else if value != nil {
_m.ItemID = *value
_m.EntityID = *value
}
case maintenanceentry.FieldDate:
if value, ok := values[i].(*sql.NullTime); !ok {
@@ -156,9 +156,9 @@ func (_m *MaintenanceEntry) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryItem() *ItemQuery {
return NewMaintenanceEntryClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryEntity() *EntityQuery {
return NewMaintenanceEntryClient(_m.config).QueryEntity(_m)
}
// Update returns a builder for updating this MaintenanceEntry.
@@ -190,8 +190,8 @@ func (_m *MaintenanceEntry) String() string {
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("item_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ItemID))
builder.WriteString("entity_id=")
builder.WriteString(fmt.Sprintf("%v", _m.EntityID))
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(_m.Date.Format(time.ANSIC))

View File

@@ -19,8 +19,8 @@ const (
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldItemID holds the string denoting the item_id field in the database.
FieldItemID = "item_id"
// FieldEntityID holds the string denoting the entity_id field in the database.
FieldEntityID = "entity_id"
// FieldDate holds the string denoting the date field in the database.
FieldDate = "date"
// FieldScheduledDate holds the string denoting the scheduled_date field in the database.
@@ -31,17 +31,17 @@ const (
FieldDescription = "description"
// FieldCost holds the string denoting the cost field in the database.
FieldCost = "cost"
// EdgeItem holds the string denoting the item edge name in mutations.
EdgeItem = "item"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// Table holds the table name of the maintenanceentry in the database.
Table = "maintenance_entries"
// ItemTable is the table that holds the item relation/edge.
ItemTable = "maintenance_entries"
// ItemInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemInverseTable = "items"
// ItemColumn is the table column denoting the item relation/edge.
ItemColumn = "item_id"
// EntityTable is the table that holds the entity relation/edge.
EntityTable = "maintenance_entries"
// EntityInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntityInverseTable = "entities"
// EntityColumn is the table column denoting the entity relation/edge.
EntityColumn = "entity_id"
)
// Columns holds all SQL columns for maintenanceentry fields.
@@ -49,7 +49,7 @@ var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldItemID,
FieldEntityID,
FieldDate,
FieldScheduledDate,
FieldName,
@@ -102,9 +102,9 @@ func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByItemID orders the results by the item_id field.
func ByItemID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldItemID, opts...).ToFunc()
// ByEntityID orders the results by the entity_id field.
func ByEntityID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEntityID, opts...).ToFunc()
}
// ByDate orders the results by the date field.
@@ -132,16 +132,16 @@ func ByCost(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCost, opts...).ToFunc()
}
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
}
}
func newItemStep() *sqlgraph.Step {
func newEntityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
}

View File

@@ -66,9 +66,9 @@ func UpdatedAt(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldUpdatedAt, v))
}
// ItemID applies equality check predicate on the "item_id" field. It's identical to ItemIDEQ.
func ItemID(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldItemID, v))
// EntityID applies equality check predicate on the "entity_id" field. It's identical to EntityIDEQ.
func EntityID(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldEntityID, v))
}
// Date applies equality check predicate on the "date" field. It's identical to DateEQ.
@@ -176,24 +176,24 @@ func UpdatedAtLTE(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldLTE(FieldUpdatedAt, v))
}
// ItemIDEQ applies the EQ predicate on the "item_id" field.
func ItemIDEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldItemID, v))
// EntityIDEQ applies the EQ predicate on the "entity_id" field.
func EntityIDEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldEntityID, v))
}
// ItemIDNEQ applies the NEQ predicate on the "item_id" field.
func ItemIDNEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNEQ(FieldItemID, v))
// EntityIDNEQ applies the NEQ predicate on the "entity_id" field.
func EntityIDNEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNEQ(FieldEntityID, v))
}
// ItemIDIn applies the In predicate on the "item_id" field.
func ItemIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldIn(FieldItemID, vs...))
// EntityIDIn applies the In predicate on the "entity_id" field.
func EntityIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldIn(FieldEntityID, vs...))
}
// ItemIDNotIn applies the NotIn predicate on the "item_id" field.
func ItemIDNotIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNotIn(FieldItemID, vs...))
// EntityIDNotIn applies the NotIn predicate on the "entity_id" field.
func EntityIDNotIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNotIn(FieldEntityID, vs...))
}
// DateEQ applies the EQ predicate on the "date" field.
@@ -476,21 +476,21 @@ func CostLTE(v float64) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldLTE(FieldCost, v))
}
// HasItem applies the HasEdge predicate on the "item" edge.
func HasItem() predicate.MaintenanceEntry {
// HasEntity applies the HasEdge predicate on the "entity" edge.
func HasEntity() predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemWith applies the HasEdge predicate on the "item" edge with a given conditions (other predicates).
func HasItemWith(preds ...predicate.Item) predicate.MaintenanceEntry {
// HasEntityWith applies the HasEdge predicate on the "entity" edge with a given conditions (other predicates).
func HasEntityWith(preds ...predicate.Entity) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) {
step := newItemStep()
step := newEntityStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)

View File

@@ -11,7 +11,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
)
@@ -50,9 +50,9 @@ func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *Maintenanc
return _c
}
// SetItemID sets the "item_id" field.
func (_c *MaintenanceEntryCreate) SetItemID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetEntityID(v)
return _c
}
@@ -132,9 +132,9 @@ func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryC
return _c
}
// SetItem sets the "item" edge to the Item entity.
func (_c *MaintenanceEntryCreate) SetItem(v *Item) *MaintenanceEntryCreate {
return _c.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate {
return _c.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -198,8 +198,8 @@ func (_c *MaintenanceEntryCreate) check() error {
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MaintenanceEntry.updated_at"`)}
}
if _, ok := _c.mutation.ItemID(); !ok {
return &ValidationError{Name: "item_id", err: errors.New(`ent: missing required field "MaintenanceEntry.item_id"`)}
if _, ok := _c.mutation.EntityID(); !ok {
return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "MaintenanceEntry.name"`)}
@@ -217,8 +217,8 @@ func (_c *MaintenanceEntryCreate) check() error {
if _, ok := _c.mutation.Cost(); !ok {
return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)}
}
if len(_c.mutation.ItemIDs()) == 0 {
return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)}
if len(_c.mutation.EntityIDs()) == 0 {
return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)}
}
return nil
}
@@ -283,21 +283,21 @@ func (_c *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.Cre
_spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value)
_node.Cost = value
}
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.ItemID = nodes[0]
_node.EntityID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -24,7 +24,7 @@ type MaintenanceEntryQuery struct {
order []maintenanceentry.OrderOption
inters []Interceptor
predicates []predicate.MaintenanceEntry
withItem *ItemQuery
withEntity *EntityQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,9 +61,9 @@ func (_q *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *Maint
return _q
}
// QueryItem chains the current query on the "item" edge.
func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntity chains the current query on the "entity" edge.
func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -74,8 +74,8 @@ func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -275,21 +275,21 @@ func (_q *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
order: append([]maintenanceentry.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.MaintenanceEntry{}, _q.predicates...),
withItem: _q.withItem.Clone(),
withEntity: _q.withEntity.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntity tells the query-builder to eager-load the nodes that are connected to
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItem = query
_q.withEntity = query
return _q
}
@@ -372,7 +372,7 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook)
nodes = []*MaintenanceEntry{}
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withItem != nil,
_q.withEntity != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
@@ -393,20 +393,20 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook)
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withItem; query != nil {
if err := _q.loadItem(ctx, query, nodes, nil,
func(n *MaintenanceEntry, e *Item) { n.Edges.Item = e }); err != nil {
if query := _q.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Item)) error {
func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*MaintenanceEntry)
for i := range nodes {
fk := nodes[i].ItemID
fk := nodes[i].EntityID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -415,7 +415,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery,
if len(ids) == 0 {
return nil
}
query.Where(item.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -423,7 +423,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery,
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "item_id" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "entity_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
@@ -457,8 +457,8 @@ func (_q *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if _q.withItem != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldItemID)
if _q.withEntity != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID)
}
}
if ps := _q.predicates; len(ps) > 0 {

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -36,16 +36,16 @@ func (_u *MaintenanceEntryUpdate) SetUpdatedAt(v time.Time) *MaintenanceEntryUpd
return _u
}
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdate) SetItemID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetEntityID(v)
return _u
}
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdate {
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate {
if v != nil {
_u.SetItemID(*v)
_u.SetEntityID(*v)
}
return _u
}
@@ -145,9 +145,9 @@ func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate {
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) SetItem(v *Item) *MaintenanceEntryUpdate {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate {
return _u.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -155,9 +155,9 @@ func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate {
_u.mutation.ClearEntity()
return _u
}
@@ -209,8 +209,8 @@ func (_u *MaintenanceEntryUpdate) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
}
return nil
}
@@ -257,28 +257,28 @@ func (_u *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (_node int, err e
if value, ok := _u.mutation.AddedCost(); ok {
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -312,16 +312,16 @@ func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntry
return _u
}
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdateOne) SetItemID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetEntityID(v)
return _u
}
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
if v != nil {
_u.SetItemID(*v)
_u.SetEntityID(*v)
}
return _u
}
@@ -421,9 +421,9 @@ func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateO
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) SetItem(v *Item) *MaintenanceEntryUpdateOne {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne {
return _u.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -431,9 +431,9 @@ func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne {
_u.mutation.ClearEntity()
return _u
}
@@ -498,8 +498,8 @@ func (_u *MaintenanceEntryUpdateOne) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
}
return nil
}
@@ -563,28 +563,28 @@ func (_u *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Mainte
if value, ok := _u.mutation.AddedCost(); ok {
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -19,7 +19,7 @@ var (
{Name: "path", Type: field.TypeString, Default: ""},
{Name: "mime_type", Type: field.TypeString, Default: "application/octet-stream"},
{Name: "attachment_thumbnail", Type: field.TypeUUID, Unique: true, Nullable: true},
{Name: "item_attachments", Type: field.TypeUUID, Nullable: true},
{Name: "entity_attachments", Type: field.TypeUUID, Nullable: true},
}
// AttachmentsTable holds the schema information for the "attachments" table.
AttachmentsTable = &schema.Table{
@@ -34,9 +34,9 @@ var (
OnDelete: schema.SetNull,
},
{
Symbol: "attachments_items_attachments",
Symbol: "attachments_entities_attachments",
Columns: []*schema.Column{AttachmentsColumns[9]},
RefColumns: []*schema.Column{ItemsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -91,6 +91,168 @@ var (
},
},
}
// EntitiesColumns holds the columns for the "entities" table.
EntitiesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "quantity", Type: field.TypeInt, Default: 1},
{Name: "insured", Type: field.TypeBool, Default: false},
{Name: "archived", Type: field.TypeBool, Default: false},
{Name: "asset_id", Type: field.TypeInt, Default: 0},
{Name: "sync_child_entities_locations", Type: field.TypeBool, Default: false},
{Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "lifetime_warranty", Type: field.TypeBool, Default: false},
{Name: "warranty_expires", Type: field.TypeTime, Nullable: true},
{Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "purchase_time", Type: field.TypeTime, Nullable: true},
{Name: "purchase_from", Type: field.TypeString, Nullable: true},
{Name: "purchase_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_time", Type: field.TypeTime, Nullable: true},
{Name: "sold_to", Type: field.TypeString, Nullable: true},
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "entity_parent", Type: field.TypeUUID, Nullable: true},
{Name: "entity_location", Type: field.TypeUUID, Nullable: true},
{Name: "entity_type_entities", Type: field.TypeUUID, Nullable: true},
{Name: "group_entities", Type: field.TypeUUID},
}
// EntitiesTable holds the schema information for the "entities" table.
EntitiesTable = &schema.Table{
Name: "entities",
Columns: EntitiesColumns,
PrimaryKey: []*schema.Column{EntitiesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entities_entities_parent",
Columns: []*schema.Column{EntitiesColumns[25]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_entities_location",
Columns: []*schema.Column{EntitiesColumns[26]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_entity_types_entities",
Columns: []*schema.Column{EntitiesColumns[27]},
RefColumns: []*schema.Column{EntityTypesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_groups_entities",
Columns: []*schema.Column{EntitiesColumns[28]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "entity_name",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[3]},
},
{
Name: "entity_manufacturer",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[14]},
},
{
Name: "entity_model_number",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[13]},
},
{
Name: "entity_serial_number",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[12]},
},
{
Name: "entity_archived",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[9]},
},
{
Name: "entity_asset_id",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[10]},
},
},
}
// EntityFieldsColumns holds the columns for the "entity_fields" table.
EntityFieldsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}},
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
{Name: "number_value", Type: field.TypeInt, Nullable: true},
{Name: "boolean_value", Type: field.TypeBool, Default: false},
{Name: "time_value", Type: field.TypeTime},
{Name: "entity_fields", Type: field.TypeUUID, Nullable: true},
}
// EntityFieldsTable holds the schema information for the "entity_fields" table.
EntityFieldsTable = &schema.Table{
Name: "entity_fields",
Columns: EntityFieldsColumns,
PrimaryKey: []*schema.Column{EntityFieldsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entity_fields_entities_fields",
Columns: []*schema.Column{EntityFieldsColumns[10]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// EntityTypesColumns holds the columns for the "entity_types" table.
EntityTypesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "icon", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "color", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "is_location", Type: field.TypeBool, Default: false},
{Name: "group_entity_types", Type: field.TypeUUID},
}
// EntityTypesTable holds the schema information for the "entity_types" table.
EntityTypesTable = &schema.Table{
Name: "entity_types",
Columns: EntityTypesColumns,
PrimaryKey: []*schema.Column{EntityTypesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entity_types_groups_entity_types",
Columns: []*schema.Column{EntityTypesColumns[8]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "entitytype_name",
Unique: false,
Columns: []*schema.Column{EntityTypesColumns[3]},
},
{
Name: "entitytype_is_location",
Unique: false,
Columns: []*schema.Column{EntityTypesColumns[7]},
},
},
}
// GroupsColumns holds the columns for the "groups" table.
GroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -129,123 +291,6 @@ var (
},
},
}
// ItemsColumns holds the columns for the "items" table.
ItemsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "quantity", Type: field.TypeInt, Default: 1},
{Name: "insured", Type: field.TypeBool, Default: false},
{Name: "archived", Type: field.TypeBool, Default: false},
{Name: "asset_id", Type: field.TypeInt, Default: 0},
{Name: "sync_child_items_locations", Type: field.TypeBool, Default: false},
{Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "lifetime_warranty", Type: field.TypeBool, Default: false},
{Name: "warranty_expires", Type: field.TypeTime, Nullable: true},
{Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "purchase_time", Type: field.TypeTime, Nullable: true},
{Name: "purchase_from", Type: field.TypeString, Nullable: true},
{Name: "purchase_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_time", Type: field.TypeTime, Nullable: true},
{Name: "sold_to", Type: field.TypeString, Nullable: true},
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "group_items", Type: field.TypeUUID},
{Name: "item_children", Type: field.TypeUUID, Nullable: true},
{Name: "location_items", Type: field.TypeUUID, Nullable: true},
}
// ItemsTable holds the schema information for the "items" table.
ItemsTable = &schema.Table{
Name: "items",
Columns: ItemsColumns,
PrimaryKey: []*schema.Column{ItemsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "items_groups_items",
Columns: []*schema.Column{ItemsColumns[25]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "items_items_children",
Columns: []*schema.Column{ItemsColumns[26]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "items_locations_items",
Columns: []*schema.Column{ItemsColumns[27]},
RefColumns: []*schema.Column{LocationsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "item_name",
Unique: false,
Columns: []*schema.Column{ItemsColumns[3]},
},
{
Name: "item_manufacturer",
Unique: false,
Columns: []*schema.Column{ItemsColumns[14]},
},
{
Name: "item_model_number",
Unique: false,
Columns: []*schema.Column{ItemsColumns[13]},
},
{
Name: "item_serial_number",
Unique: false,
Columns: []*schema.Column{ItemsColumns[12]},
},
{
Name: "item_archived",
Unique: false,
Columns: []*schema.Column{ItemsColumns[9]},
},
{
Name: "item_asset_id",
Unique: false,
Columns: []*schema.Column{ItemsColumns[10]},
},
},
}
// ItemFieldsColumns holds the columns for the "item_fields" table.
ItemFieldsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}},
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
{Name: "number_value", Type: field.TypeInt, Nullable: true},
{Name: "boolean_value", Type: field.TypeBool, Default: false},
{Name: "time_value", Type: field.TypeTime},
{Name: "item_fields", Type: field.TypeUUID, Nullable: true},
}
// ItemFieldsTable holds the schema information for the "item_fields" table.
ItemFieldsTable = &schema.Table{
Name: "item_fields",
Columns: ItemFieldsColumns,
PrimaryKey: []*schema.Column{ItemFieldsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "item_fields_items_fields",
Columns: []*schema.Column{ItemFieldsColumns[10]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// ItemTemplatesColumns holds the columns for the "item_templates" table.
ItemTemplatesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -282,9 +327,9 @@ var (
OnDelete: schema.Cascade,
},
{
Symbol: "item_templates_locations_location",
Symbol: "item_templates_entities_location",
Columns: []*schema.Column{ItemTemplatesColumns[19]},
RefColumns: []*schema.Column{LocationsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
},
@@ -320,36 +365,6 @@ var (
},
},
}
// LocationsColumns holds the columns for the "locations" table.
LocationsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "group_locations", Type: field.TypeUUID},
{Name: "location_children", Type: field.TypeUUID, Nullable: true},
}
// LocationsTable holds the schema information for the "locations" table.
LocationsTable = &schema.Table{
Name: "locations",
Columns: LocationsColumns,
PrimaryKey: []*schema.Column{LocationsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "locations_groups_locations",
Columns: []*schema.Column{LocationsColumns[5]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "locations_locations_children",
Columns: []*schema.Column{LocationsColumns[6]},
RefColumns: []*schema.Column{LocationsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// MaintenanceEntriesColumns holds the columns for the "maintenance_entries" table.
MaintenanceEntriesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -360,7 +375,7 @@ var (
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 2500},
{Name: "cost", Type: field.TypeFloat64, Default: 0},
{Name: "item_id", Type: field.TypeUUID},
{Name: "entity_id", Type: field.TypeUUID},
}
// MaintenanceEntriesTable holds the schema information for the "maintenance_entries" table.
MaintenanceEntriesTable = &schema.Table{
@@ -369,9 +384,9 @@ var (
PrimaryKey: []*schema.Column{MaintenanceEntriesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "maintenance_entries_items_maintenance_entries",
Symbol: "maintenance_entries_entities_maintenance_entries",
Columns: []*schema.Column{MaintenanceEntriesColumns[8]},
RefColumns: []*schema.Column{ItemsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -491,27 +506,27 @@ var (
},
},
}
// LabelItemsColumns holds the columns for the "label_items" table.
LabelItemsColumns = []*schema.Column{
// LabelEntitiesColumns holds the columns for the "label_entities" table.
LabelEntitiesColumns = []*schema.Column{
{Name: "label_id", Type: field.TypeUUID},
{Name: "item_id", Type: field.TypeUUID},
{Name: "entity_id", Type: field.TypeUUID},
}
// LabelItemsTable holds the schema information for the "label_items" table.
LabelItemsTable = &schema.Table{
Name: "label_items",
Columns: LabelItemsColumns,
PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]},
// LabelEntitiesTable holds the schema information for the "label_entities" table.
LabelEntitiesTable = &schema.Table{
Name: "label_entities",
Columns: LabelEntitiesColumns,
PrimaryKey: []*schema.Column{LabelEntitiesColumns[0], LabelEntitiesColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "label_items_label_id",
Columns: []*schema.Column{LabelItemsColumns[0]},
Symbol: "label_entities_label_id",
Columns: []*schema.Column{LabelEntitiesColumns[0]},
RefColumns: []*schema.Column{LabelsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "label_items_item_id",
Columns: []*schema.Column{LabelItemsColumns[1]},
RefColumns: []*schema.Column{ItemsColumns[0]},
Symbol: "label_entities_entity_id",
Columns: []*schema.Column{LabelEntitiesColumns[1]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -521,41 +536,41 @@ var (
AttachmentsTable,
AuthRolesTable,
AuthTokensTable,
EntitiesTable,
EntityFieldsTable,
EntityTypesTable,
GroupsTable,
GroupInvitationTokensTable,
ItemsTable,
ItemFieldsTable,
ItemTemplatesTable,
LabelsTable,
LocationsTable,
MaintenanceEntriesTable,
NotifiersTable,
TemplateFieldsTable,
UsersTable,
LabelItemsTable,
LabelEntitiesTable,
}
)
func init() {
AttachmentsTable.ForeignKeys[0].RefTable = AttachmentsTable
AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable
AttachmentsTable.ForeignKeys[1].RefTable = EntitiesTable
AuthRolesTable.ForeignKeys[0].RefTable = AuthTokensTable
AuthTokensTable.ForeignKeys[0].RefTable = UsersTable
EntitiesTable.ForeignKeys[0].RefTable = EntitiesTable
EntitiesTable.ForeignKeys[1].RefTable = EntitiesTable
EntitiesTable.ForeignKeys[2].RefTable = EntityTypesTable
EntitiesTable.ForeignKeys[3].RefTable = GroupsTable
EntityFieldsTable.ForeignKeys[0].RefTable = EntitiesTable
EntityTypesTable.ForeignKeys[0].RefTable = GroupsTable
GroupInvitationTokensTable.ForeignKeys[0].RefTable = GroupsTable
ItemsTable.ForeignKeys[0].RefTable = GroupsTable
ItemsTable.ForeignKeys[1].RefTable = ItemsTable
ItemsTable.ForeignKeys[2].RefTable = LocationsTable
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable
ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
ItemTemplatesTable.ForeignKeys[1].RefTable = EntitiesTable
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = EntitiesTable
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
UsersTable.ForeignKeys[0].RefTable = GroupsTable
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
LabelEntitiesTable.ForeignKeys[0].RefTable = LabelsTable
LabelEntitiesTable.ForeignKeys[1].RefTable = EntitiesTable
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,27 +15,27 @@ type AuthRoles func(*sql.Selector)
// AuthTokens is the predicate function for authtokens builders.
type AuthTokens func(*sql.Selector)
// Entity is the predicate function for entity builders.
type Entity func(*sql.Selector)
// EntityField is the predicate function for entityfield builders.
type EntityField func(*sql.Selector)
// EntityType is the predicate function for entitytype builders.
type EntityType func(*sql.Selector)
// Group is the predicate function for group builders.
type Group func(*sql.Selector)
// GroupInvitationToken is the predicate function for groupinvitationtoken builders.
type GroupInvitationToken func(*sql.Selector)
// Item is the predicate function for item builders.
type Item func(*sql.Selector)
// ItemField is the predicate function for itemfield builders.
type ItemField func(*sql.Selector)
// ItemTemplate is the predicate function for itemtemplate builders.
type ItemTemplate func(*sql.Selector)
// Label is the predicate function for label builders.
type Label func(*sql.Selector)
// Location is the predicate function for location builders.
type Location func(*sql.Selector)
// MaintenanceEntry is the predicate function for maintenanceentry builders.
type MaintenanceEntry func(*sql.Selector)

View File

@@ -8,13 +8,13 @@ import (
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
@@ -86,6 +86,219 @@ func init() {
authtokensDescID := authtokensMixinFields0[0].Descriptor()
// authtokens.DefaultID holds the default value on creation for the id field.
authtokens.DefaultID = authtokensDescID.Default.(func() uuid.UUID)
entityMixin := schema.Entity{}.Mixin()
entityMixinFields0 := entityMixin[0].Fields()
_ = entityMixinFields0
entityMixinFields1 := entityMixin[1].Fields()
_ = entityMixinFields1
entityFields := schema.Entity{}.Fields()
_ = entityFields
// entityDescCreatedAt is the schema descriptor for created_at field.
entityDescCreatedAt := entityMixinFields0[1].Descriptor()
// entity.DefaultCreatedAt holds the default value on creation for the created_at field.
entity.DefaultCreatedAt = entityDescCreatedAt.Default.(func() time.Time)
// entityDescUpdatedAt is the schema descriptor for updated_at field.
entityDescUpdatedAt := entityMixinFields0[2].Descriptor()
// entity.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entity.DefaultUpdatedAt = entityDescUpdatedAt.Default.(func() time.Time)
// entity.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entity.UpdateDefaultUpdatedAt = entityDescUpdatedAt.UpdateDefault.(func() time.Time)
// entityDescName is the schema descriptor for name field.
entityDescName := entityMixinFields1[0].Descriptor()
// entity.NameValidator is a validator for the "name" field. It is called by the builders before save.
entity.NameValidator = func() func(string) error {
validators := entityDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entityDescDescription is the schema descriptor for description field.
entityDescDescription := entityMixinFields1[1].Descriptor()
// entity.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entity.DescriptionValidator = entityDescDescription.Validators[0].(func(string) error)
// entityDescImportRef is the schema descriptor for import_ref field.
entityDescImportRef := entityFields[0].Descriptor()
// entity.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
entity.ImportRefValidator = entityDescImportRef.Validators[0].(func(string) error)
// entityDescNotes is the schema descriptor for notes field.
entityDescNotes := entityFields[1].Descriptor()
// entity.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
entity.NotesValidator = entityDescNotes.Validators[0].(func(string) error)
// entityDescQuantity is the schema descriptor for quantity field.
entityDescQuantity := entityFields[2].Descriptor()
// entity.DefaultQuantity holds the default value on creation for the quantity field.
entity.DefaultQuantity = entityDescQuantity.Default.(int)
// entityDescInsured is the schema descriptor for insured field.
entityDescInsured := entityFields[3].Descriptor()
// entity.DefaultInsured holds the default value on creation for the insured field.
entity.DefaultInsured = entityDescInsured.Default.(bool)
// entityDescArchived is the schema descriptor for archived field.
entityDescArchived := entityFields[4].Descriptor()
// entity.DefaultArchived holds the default value on creation for the archived field.
entity.DefaultArchived = entityDescArchived.Default.(bool)
// entityDescAssetID is the schema descriptor for asset_id field.
entityDescAssetID := entityFields[5].Descriptor()
// entity.DefaultAssetID holds the default value on creation for the asset_id field.
entity.DefaultAssetID = entityDescAssetID.Default.(int)
// entityDescSyncChildEntitiesLocations is the schema descriptor for sync_child_entities_locations field.
entityDescSyncChildEntitiesLocations := entityFields[6].Descriptor()
// entity.DefaultSyncChildEntitiesLocations holds the default value on creation for the sync_child_entities_locations field.
entity.DefaultSyncChildEntitiesLocations = entityDescSyncChildEntitiesLocations.Default.(bool)
// entityDescSerialNumber is the schema descriptor for serial_number field.
entityDescSerialNumber := entityFields[7].Descriptor()
// entity.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
entity.SerialNumberValidator = entityDescSerialNumber.Validators[0].(func(string) error)
// entityDescModelNumber is the schema descriptor for model_number field.
entityDescModelNumber := entityFields[8].Descriptor()
// entity.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
entity.ModelNumberValidator = entityDescModelNumber.Validators[0].(func(string) error)
// entityDescManufacturer is the schema descriptor for manufacturer field.
entityDescManufacturer := entityFields[9].Descriptor()
// entity.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
entity.ManufacturerValidator = entityDescManufacturer.Validators[0].(func(string) error)
// entityDescLifetimeWarranty is the schema descriptor for lifetime_warranty field.
entityDescLifetimeWarranty := entityFields[10].Descriptor()
// entity.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field.
entity.DefaultLifetimeWarranty = entityDescLifetimeWarranty.Default.(bool)
// entityDescWarrantyDetails is the schema descriptor for warranty_details field.
entityDescWarrantyDetails := entityFields[12].Descriptor()
// entity.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
entity.WarrantyDetailsValidator = entityDescWarrantyDetails.Validators[0].(func(string) error)
// entityDescPurchasePrice is the schema descriptor for purchase_price field.
entityDescPurchasePrice := entityFields[15].Descriptor()
// entity.DefaultPurchasePrice holds the default value on creation for the purchase_price field.
entity.DefaultPurchasePrice = entityDescPurchasePrice.Default.(float64)
// entityDescSoldPrice is the schema descriptor for sold_price field.
entityDescSoldPrice := entityFields[18].Descriptor()
// entity.DefaultSoldPrice holds the default value on creation for the sold_price field.
entity.DefaultSoldPrice = entityDescSoldPrice.Default.(float64)
// entityDescSoldNotes is the schema descriptor for sold_notes field.
entityDescSoldNotes := entityFields[19].Descriptor()
// entity.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
entity.SoldNotesValidator = entityDescSoldNotes.Validators[0].(func(string) error)
// entityDescID is the schema descriptor for id field.
entityDescID := entityMixinFields0[0].Descriptor()
// entity.DefaultID holds the default value on creation for the id field.
entity.DefaultID = entityDescID.Default.(func() uuid.UUID)
entityfieldMixin := schema.EntityField{}.Mixin()
entityfieldMixinFields0 := entityfieldMixin[0].Fields()
_ = entityfieldMixinFields0
entityfieldMixinFields1 := entityfieldMixin[1].Fields()
_ = entityfieldMixinFields1
entityfieldFields := schema.EntityField{}.Fields()
_ = entityfieldFields
// entityfieldDescCreatedAt is the schema descriptor for created_at field.
entityfieldDescCreatedAt := entityfieldMixinFields0[1].Descriptor()
// entityfield.DefaultCreatedAt holds the default value on creation for the created_at field.
entityfield.DefaultCreatedAt = entityfieldDescCreatedAt.Default.(func() time.Time)
// entityfieldDescUpdatedAt is the schema descriptor for updated_at field.
entityfieldDescUpdatedAt := entityfieldMixinFields0[2].Descriptor()
// entityfield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entityfield.DefaultUpdatedAt = entityfieldDescUpdatedAt.Default.(func() time.Time)
// entityfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entityfield.UpdateDefaultUpdatedAt = entityfieldDescUpdatedAt.UpdateDefault.(func() time.Time)
// entityfieldDescName is the schema descriptor for name field.
entityfieldDescName := entityfieldMixinFields1[0].Descriptor()
// entityfield.NameValidator is a validator for the "name" field. It is called by the builders before save.
entityfield.NameValidator = func() func(string) error {
validators := entityfieldDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entityfieldDescDescription is the schema descriptor for description field.
entityfieldDescDescription := entityfieldMixinFields1[1].Descriptor()
// entityfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entityfield.DescriptionValidator = entityfieldDescDescription.Validators[0].(func(string) error)
// entityfieldDescTextValue is the schema descriptor for text_value field.
entityfieldDescTextValue := entityfieldFields[1].Descriptor()
// entityfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
entityfield.TextValueValidator = entityfieldDescTextValue.Validators[0].(func(string) error)
// entityfieldDescBooleanValue is the schema descriptor for boolean_value field.
entityfieldDescBooleanValue := entityfieldFields[3].Descriptor()
// entityfield.DefaultBooleanValue holds the default value on creation for the boolean_value field.
entityfield.DefaultBooleanValue = entityfieldDescBooleanValue.Default.(bool)
// entityfieldDescTimeValue is the schema descriptor for time_value field.
entityfieldDescTimeValue := entityfieldFields[4].Descriptor()
// entityfield.DefaultTimeValue holds the default value on creation for the time_value field.
entityfield.DefaultTimeValue = entityfieldDescTimeValue.Default.(func() time.Time)
// entityfieldDescID is the schema descriptor for id field.
entityfieldDescID := entityfieldMixinFields0[0].Descriptor()
// entityfield.DefaultID holds the default value on creation for the id field.
entityfield.DefaultID = entityfieldDescID.Default.(func() uuid.UUID)
entitytypeMixin := schema.EntityType{}.Mixin()
entitytypeMixinFields0 := entitytypeMixin[0].Fields()
_ = entitytypeMixinFields0
entitytypeMixinFields1 := entitytypeMixin[1].Fields()
_ = entitytypeMixinFields1
entitytypeFields := schema.EntityType{}.Fields()
_ = entitytypeFields
// entitytypeDescCreatedAt is the schema descriptor for created_at field.
entitytypeDescCreatedAt := entitytypeMixinFields0[1].Descriptor()
// entitytype.DefaultCreatedAt holds the default value on creation for the created_at field.
entitytype.DefaultCreatedAt = entitytypeDescCreatedAt.Default.(func() time.Time)
// entitytypeDescUpdatedAt is the schema descriptor for updated_at field.
entitytypeDescUpdatedAt := entitytypeMixinFields0[2].Descriptor()
// entitytype.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entitytype.DefaultUpdatedAt = entitytypeDescUpdatedAt.Default.(func() time.Time)
// entitytype.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entitytype.UpdateDefaultUpdatedAt = entitytypeDescUpdatedAt.UpdateDefault.(func() time.Time)
// entitytypeDescName is the schema descriptor for name field.
entitytypeDescName := entitytypeMixinFields1[0].Descriptor()
// entitytype.NameValidator is a validator for the "name" field. It is called by the builders before save.
entitytype.NameValidator = func() func(string) error {
validators := entitytypeDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entitytypeDescDescription is the schema descriptor for description field.
entitytypeDescDescription := entitytypeMixinFields1[1].Descriptor()
// entitytype.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entitytype.DescriptionValidator = entitytypeDescDescription.Validators[0].(func(string) error)
// entitytypeDescIcon is the schema descriptor for icon field.
entitytypeDescIcon := entitytypeFields[0].Descriptor()
// entitytype.IconValidator is a validator for the "icon" field. It is called by the builders before save.
entitytype.IconValidator = entitytypeDescIcon.Validators[0].(func(string) error)
// entitytypeDescColor is the schema descriptor for color field.
entitytypeDescColor := entitytypeFields[1].Descriptor()
// entitytype.ColorValidator is a validator for the "color" field. It is called by the builders before save.
entitytype.ColorValidator = entitytypeDescColor.Validators[0].(func(string) error)
// entitytypeDescIsLocation is the schema descriptor for is_location field.
entitytypeDescIsLocation := entitytypeFields[2].Descriptor()
// entitytype.DefaultIsLocation holds the default value on creation for the is_location field.
entitytype.DefaultIsLocation = entitytypeDescIsLocation.Default.(bool)
// entitytypeDescID is the schema descriptor for id field.
entitytypeDescID := entitytypeMixinFields0[0].Descriptor()
// entitytype.DefaultID holds the default value on creation for the id field.
entitytype.DefaultID = entitytypeDescID.Default.(func() uuid.UUID)
groupMixin := schema.Group{}.Mixin()
groupMixinFields0 := groupMixin[0].Fields()
_ = groupMixinFields0
@@ -154,164 +367,6 @@ func init() {
groupinvitationtokenDescID := groupinvitationtokenMixinFields0[0].Descriptor()
// groupinvitationtoken.DefaultID holds the default value on creation for the id field.
groupinvitationtoken.DefaultID = groupinvitationtokenDescID.Default.(func() uuid.UUID)
itemMixin := schema.Item{}.Mixin()
itemMixinFields0 := itemMixin[0].Fields()
_ = itemMixinFields0
itemMixinFields1 := itemMixin[1].Fields()
_ = itemMixinFields1
itemFields := schema.Item{}.Fields()
_ = itemFields
// itemDescCreatedAt is the schema descriptor for created_at field.
itemDescCreatedAt := itemMixinFields0[1].Descriptor()
// item.DefaultCreatedAt holds the default value on creation for the created_at field.
item.DefaultCreatedAt = itemDescCreatedAt.Default.(func() time.Time)
// itemDescUpdatedAt is the schema descriptor for updated_at field.
itemDescUpdatedAt := itemMixinFields0[2].Descriptor()
// item.DefaultUpdatedAt holds the default value on creation for the updated_at field.
item.DefaultUpdatedAt = itemDescUpdatedAt.Default.(func() time.Time)
// item.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
item.UpdateDefaultUpdatedAt = itemDescUpdatedAt.UpdateDefault.(func() time.Time)
// itemDescName is the schema descriptor for name field.
itemDescName := itemMixinFields1[0].Descriptor()
// item.NameValidator is a validator for the "name" field. It is called by the builders before save.
item.NameValidator = func() func(string) error {
validators := itemDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// itemDescDescription is the schema descriptor for description field.
itemDescDescription := itemMixinFields1[1].Descriptor()
// item.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
item.DescriptionValidator = itemDescDescription.Validators[0].(func(string) error)
// itemDescImportRef is the schema descriptor for import_ref field.
itemDescImportRef := itemFields[0].Descriptor()
// item.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
item.ImportRefValidator = itemDescImportRef.Validators[0].(func(string) error)
// itemDescNotes is the schema descriptor for notes field.
itemDescNotes := itemFields[1].Descriptor()
// item.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
item.NotesValidator = itemDescNotes.Validators[0].(func(string) error)
// itemDescQuantity is the schema descriptor for quantity field.
itemDescQuantity := itemFields[2].Descriptor()
// item.DefaultQuantity holds the default value on creation for the quantity field.
item.DefaultQuantity = itemDescQuantity.Default.(int)
// itemDescInsured is the schema descriptor for insured field.
itemDescInsured := itemFields[3].Descriptor()
// item.DefaultInsured holds the default value on creation for the insured field.
item.DefaultInsured = itemDescInsured.Default.(bool)
// itemDescArchived is the schema descriptor for archived field.
itemDescArchived := itemFields[4].Descriptor()
// item.DefaultArchived holds the default value on creation for the archived field.
item.DefaultArchived = itemDescArchived.Default.(bool)
// itemDescAssetID is the schema descriptor for asset_id field.
itemDescAssetID := itemFields[5].Descriptor()
// item.DefaultAssetID holds the default value on creation for the asset_id field.
item.DefaultAssetID = itemDescAssetID.Default.(int)
// itemDescSyncChildItemsLocations is the schema descriptor for sync_child_items_locations field.
itemDescSyncChildItemsLocations := itemFields[6].Descriptor()
// item.DefaultSyncChildItemsLocations holds the default value on creation for the sync_child_items_locations field.
item.DefaultSyncChildItemsLocations = itemDescSyncChildItemsLocations.Default.(bool)
// itemDescSerialNumber is the schema descriptor for serial_number field.
itemDescSerialNumber := itemFields[7].Descriptor()
// item.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
item.SerialNumberValidator = itemDescSerialNumber.Validators[0].(func(string) error)
// itemDescModelNumber is the schema descriptor for model_number field.
itemDescModelNumber := itemFields[8].Descriptor()
// item.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
item.ModelNumberValidator = itemDescModelNumber.Validators[0].(func(string) error)
// itemDescManufacturer is the schema descriptor for manufacturer field.
itemDescManufacturer := itemFields[9].Descriptor()
// item.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
item.ManufacturerValidator = itemDescManufacturer.Validators[0].(func(string) error)
// itemDescLifetimeWarranty is the schema descriptor for lifetime_warranty field.
itemDescLifetimeWarranty := itemFields[10].Descriptor()
// item.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field.
item.DefaultLifetimeWarranty = itemDescLifetimeWarranty.Default.(bool)
// itemDescWarrantyDetails is the schema descriptor for warranty_details field.
itemDescWarrantyDetails := itemFields[12].Descriptor()
// item.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
item.WarrantyDetailsValidator = itemDescWarrantyDetails.Validators[0].(func(string) error)
// itemDescPurchasePrice is the schema descriptor for purchase_price field.
itemDescPurchasePrice := itemFields[15].Descriptor()
// item.DefaultPurchasePrice holds the default value on creation for the purchase_price field.
item.DefaultPurchasePrice = itemDescPurchasePrice.Default.(float64)
// itemDescSoldPrice is the schema descriptor for sold_price field.
itemDescSoldPrice := itemFields[18].Descriptor()
// item.DefaultSoldPrice holds the default value on creation for the sold_price field.
item.DefaultSoldPrice = itemDescSoldPrice.Default.(float64)
// itemDescSoldNotes is the schema descriptor for sold_notes field.
itemDescSoldNotes := itemFields[19].Descriptor()
// item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error)
// itemDescID is the schema descriptor for id field.
itemDescID := itemMixinFields0[0].Descriptor()
// item.DefaultID holds the default value on creation for the id field.
item.DefaultID = itemDescID.Default.(func() uuid.UUID)
itemfieldMixin := schema.ItemField{}.Mixin()
itemfieldMixinFields0 := itemfieldMixin[0].Fields()
_ = itemfieldMixinFields0
itemfieldMixinFields1 := itemfieldMixin[1].Fields()
_ = itemfieldMixinFields1
itemfieldFields := schema.ItemField{}.Fields()
_ = itemfieldFields
// itemfieldDescCreatedAt is the schema descriptor for created_at field.
itemfieldDescCreatedAt := itemfieldMixinFields0[1].Descriptor()
// itemfield.DefaultCreatedAt holds the default value on creation for the created_at field.
itemfield.DefaultCreatedAt = itemfieldDescCreatedAt.Default.(func() time.Time)
// itemfieldDescUpdatedAt is the schema descriptor for updated_at field.
itemfieldDescUpdatedAt := itemfieldMixinFields0[2].Descriptor()
// itemfield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
itemfield.DefaultUpdatedAt = itemfieldDescUpdatedAt.Default.(func() time.Time)
// itemfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
itemfield.UpdateDefaultUpdatedAt = itemfieldDescUpdatedAt.UpdateDefault.(func() time.Time)
// itemfieldDescName is the schema descriptor for name field.
itemfieldDescName := itemfieldMixinFields1[0].Descriptor()
// itemfield.NameValidator is a validator for the "name" field. It is called by the builders before save.
itemfield.NameValidator = func() func(string) error {
validators := itemfieldDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// itemfieldDescDescription is the schema descriptor for description field.
itemfieldDescDescription := itemfieldMixinFields1[1].Descriptor()
// itemfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
itemfield.DescriptionValidator = itemfieldDescDescription.Validators[0].(func(string) error)
// itemfieldDescTextValue is the schema descriptor for text_value field.
itemfieldDescTextValue := itemfieldFields[1].Descriptor()
// itemfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
itemfield.TextValueValidator = itemfieldDescTextValue.Validators[0].(func(string) error)
// itemfieldDescBooleanValue is the schema descriptor for boolean_value field.
itemfieldDescBooleanValue := itemfieldFields[3].Descriptor()
// itemfield.DefaultBooleanValue holds the default value on creation for the boolean_value field.
itemfield.DefaultBooleanValue = itemfieldDescBooleanValue.Default.(bool)
// itemfieldDescTimeValue is the schema descriptor for time_value field.
itemfieldDescTimeValue := itemfieldFields[4].Descriptor()
// itemfield.DefaultTimeValue holds the default value on creation for the time_value field.
itemfield.DefaultTimeValue = itemfieldDescTimeValue.Default.(func() time.Time)
// itemfieldDescID is the schema descriptor for id field.
itemfieldDescID := itemfieldMixinFields0[0].Descriptor()
// itemfield.DefaultID holds the default value on creation for the id field.
itemfield.DefaultID = itemfieldDescID.Default.(func() uuid.UUID)
itemtemplateMixin := schema.ItemTemplate{}.Mixin()
itemtemplateMixinFields0 := itemtemplateMixin[0].Fields()
_ = itemtemplateMixinFields0
@@ -450,49 +505,6 @@ func init() {
labelDescID := labelMixinFields0[0].Descriptor()
// label.DefaultID holds the default value on creation for the id field.
label.DefaultID = labelDescID.Default.(func() uuid.UUID)
locationMixin := schema.Location{}.Mixin()
locationMixinFields0 := locationMixin[0].Fields()
_ = locationMixinFields0
locationMixinFields1 := locationMixin[1].Fields()
_ = locationMixinFields1
locationFields := schema.Location{}.Fields()
_ = locationFields
// locationDescCreatedAt is the schema descriptor for created_at field.
locationDescCreatedAt := locationMixinFields0[1].Descriptor()
// location.DefaultCreatedAt holds the default value on creation for the created_at field.
location.DefaultCreatedAt = locationDescCreatedAt.Default.(func() time.Time)
// locationDescUpdatedAt is the schema descriptor for updated_at field.
locationDescUpdatedAt := locationMixinFields0[2].Descriptor()
// location.DefaultUpdatedAt holds the default value on creation for the updated_at field.
location.DefaultUpdatedAt = locationDescUpdatedAt.Default.(func() time.Time)
// location.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
location.UpdateDefaultUpdatedAt = locationDescUpdatedAt.UpdateDefault.(func() time.Time)
// locationDescName is the schema descriptor for name field.
locationDescName := locationMixinFields1[0].Descriptor()
// location.NameValidator is a validator for the "name" field. It is called by the builders before save.
location.NameValidator = func() func(string) error {
validators := locationDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// locationDescDescription is the schema descriptor for description field.
locationDescDescription := locationMixinFields1[1].Descriptor()
// location.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
location.DescriptionValidator = locationDescDescription.Validators[0].(func(string) error)
// locationDescID is the schema descriptor for id field.
locationDescID := locationMixinFields0[0].Descriptor()
// location.DefaultID holds the default value on creation for the id field.
location.DefaultID = locationDescID.Default.(func() uuid.UUID)
maintenanceentryMixin := schema.MaintenanceEntry{}.Mixin()
maintenanceentryMixinFields0 := maintenanceentryMixin[0].Fields()
_ = maintenanceentryMixinFields0

View File

@@ -32,7 +32,7 @@ func (Attachment) Fields() []ent.Field {
// Edges of the Attachment.
func (Attachment) Edges() []ent.Edge {
return []ent.Edge{
edge.From("item", Item.Type).
edge.From("entity", Entity.Type).
Ref("attachments").
Unique(),
edge.To("thumbnail", Attachment.Type).

View File

@@ -9,20 +9,21 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
)
// Item holds the schema definition for the Item entity.
type Item struct {
type Entity struct {
ent.Schema
}
func (Item) Mixin() []ent.Mixin {
// Mixin for the Entity.
func (Entity) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.BaseMixin{},
mixins.DetailsMixin{},
GroupMixin{ref: "items"},
GroupMixin{ref: "entities"},
}
}
func (Item) Indexes() []ent.Index {
// Indexes of the Entity.
func (Entity) Indexes() []ent.Index {
return []ent.Index{
// Unique index on the "title" field.
index.Fields("name"),
@@ -34,9 +35,10 @@ func (Item) Indexes() []ent.Index {
}
}
// Fields of the Item.
func (Item) Fields() []ent.Field {
// Fields of the Entity.
func (Entity) Fields() []ent.Field {
return []ent.Field{
// General details
field.String("import_ref").
Optional().
MaxLen(100),
@@ -51,11 +53,11 @@ func (Item) Fields() []ent.Field {
Default(false),
field.Int("asset_id").
Default(0),
field.Bool("sync_child_items_locations").
field.Bool("sync_child_entities_locations").
Default(false),
// ------------------------------------
// item identification
// entity identification
field.String("serial_number").
MaxLen(255).
Optional(),
@@ -67,7 +69,7 @@ func (Item) Fields() []ent.Field {
Optional(),
// ------------------------------------
// Item Warranty
// entity Warranty
field.Bool("lifetime_warranty").
Default(false),
field.Time("warranty_expires").
@@ -77,7 +79,7 @@ func (Item) Fields() []ent.Field {
Optional(),
// ------------------------------------
// item purchase
// entity purchase
field.Time("purchase_time").
Optional(),
field.String("purchase_from").
@@ -99,8 +101,8 @@ func (Item) Fields() []ent.Field {
}
}
// Edges of the Item.
func (Item) Edges() []ent.Edge {
// Edges of the Entity.
func (Entity) Edges() []ent.Edge {
owned := func(s string, t any) ent.Edge {
return edge.To(s, t).
Annotations(entsql.Annotation{
@@ -109,15 +111,18 @@ func (Item) Edges() []ent.Edge {
}
return []ent.Edge{
edge.To("children", Item.Type).
From("parent").
Unique(),
edge.To("parent", Entity.Type).
Unique().
From("children"),
edge.To("location", Entity.Type).
Unique().
From("entity"),
edge.From("label", Label.Type).
Ref("items"),
edge.From("location", Location.Type).
Ref("items").
Ref("entities"),
edge.From("type", EntityType.Type).
Ref("entities").
Unique(),
owned("fields", ItemField.Type),
owned("fields", EntityField.Type),
owned("maintenance_entries", MaintenanceEntry.Type),
owned("attachments", Attachment.Type),
}

View File

@@ -9,20 +9,20 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
)
// ItemField holds the schema definition for the ItemField entity.
type ItemField struct {
// EntityField holds the schema definition for the EntityField entity.
type EntityField struct {
ent.Schema
}
func (ItemField) Mixin() []ent.Mixin {
func (EntityField) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.BaseMixin{},
mixins.DetailsMixin{},
}
}
// Fields of the ItemField.
func (ItemField) Fields() []ent.Field {
// Fields of the EntityField.
func (EntityField) Fields() []ent.Field {
return []ent.Field{
field.Enum("type").
Values("text", "number", "boolean", "time"),
@@ -38,10 +38,10 @@ func (ItemField) Fields() []ent.Field {
}
}
// Edges of the ItemField.
func (ItemField) Edges() []ent.Edge {
// Edges of the EntityField.
func (EntityField) Edges() []ent.Edge {
return []ent.Edge{
edge.From("item", Item.Type).
edge.From("entity", Entity.Type).
Ref("fields").
Unique(),
}

View File

@@ -0,0 +1,48 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
)
type EntityType struct {
ent.Schema
}
func (EntityType) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.BaseMixin{},
mixins.DetailsMixin{},
GroupMixin{ref: "entity_types"},
}
}
func (EntityType) Fields() []ent.Field {
return []ent.Field{
field.String("icon").
MaxLen(255).
Optional(),
field.String("color").
MaxLen(255).
Optional(),
field.Bool("is_location").
Default(false),
}
}
func (EntityType) Indexes() []ent.Index {
return []ent.Index{
// Unique index on the "title" field.
index.Fields("name"),
index.Fields("is_location"),
}
}
func (EntityType) Edges() []ent.Edge {
return []ent.Edge{
edge.To("entities", Entity.Type),
}
}

View File

@@ -43,11 +43,11 @@ func (Group) Edges() []ent.Edge {
return []ent.Edge{
owned("users", User.Type),
owned("locations", Location.Type),
owned("items", Item.Type),
owned("entities", Entity.Type),
owned("labels", Label.Type),
owned("invitation_tokens", GroupInvitationToken.Type),
owned("notifiers", Notifier.Type),
owned("entity_types", EntityType.Type),
owned("item_templates", ItemTemplate.Type),
// $scaffold_edge
}

View File

@@ -105,7 +105,7 @@ func (ItemTemplate) Edges() []ent.Edge {
return []ent.Edge{
owned("fields", TemplateField.Type),
// Default location for items created from this template
edge.To("location", Location.Type).
edge.To("location", Entity.Type).
Unique(),
}
}

View File

@@ -32,6 +32,6 @@ func (Label) Fields() []ent.Field {
// Edges of the Label.
func (Label) Edges() []ent.Edge {
return []ent.Edge{
edge.To("items", Item.Type),
edge.To("entities", Entity.Type),
}
}

View File

@@ -1,39 +0,0 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
)
// Location holds the schema definition for the Location entity.
type Location struct {
ent.Schema
}
func (Location) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.BaseMixin{},
mixins.DetailsMixin{},
GroupMixin{ref: "locations"},
}
}
// Fields of the Location.
func (Location) Fields() []ent.Field {
return nil
}
// Edges of the Location.
func (Location) Edges() []ent.Edge {
return []ent.Edge{
edge.To("children", Location.Type).
From("parent").
Unique(),
edge.To("items", Item.Type).
Annotations(entsql.Annotation{
OnDelete: entsql.Cascade,
}),
}
}

View File

@@ -12,15 +12,17 @@ type MaintenanceEntry struct {
ent.Schema
}
// Mixin for the MaintenanceEntry.
func (MaintenanceEntry) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.BaseMixin{},
}
}
// Fields of the EntityField.
func (MaintenanceEntry) Fields() []ent.Field {
return []ent.Field{
field.UUID("item_id", uuid.UUID{}),
field.UUID("entity_id", uuid.UUID{}),
field.Time("date").
Optional(),
field.Time("scheduled_date").
@@ -36,11 +38,11 @@ func (MaintenanceEntry) Fields() []ent.Field {
}
}
// Edges of the ItemField.
// Edges of the EntityField.
func (MaintenanceEntry) Edges() []ent.Edge {
return []ent.Edge{
edge.From("item", Item.Type).
Field("item_id").
edge.From("entity", Entity.Type).
Field("entity_id").
Ref("maintenance_entries").
Required().
Unique(),

View File

@@ -18,20 +18,20 @@ type Tx struct {
AuthRoles *AuthRolesClient
// AuthTokens is the client for interacting with the AuthTokens builders.
AuthTokens *AuthTokensClient
// Entity is the client for interacting with the Entity builders.
Entity *EntityClient
// EntityField is the client for interacting with the EntityField builders.
EntityField *EntityFieldClient
// EntityType is the client for interacting with the EntityType builders.
EntityType *EntityTypeClient
// Group is the client for interacting with the Group builders.
Group *GroupClient
// GroupInvitationToken is the client for interacting with the GroupInvitationToken builders.
GroupInvitationToken *GroupInvitationTokenClient
// Item is the client for interacting with the Item builders.
Item *ItemClient
// ItemField is the client for interacting with the ItemField builders.
ItemField *ItemFieldClient
// ItemTemplate is the client for interacting with the ItemTemplate builders.
ItemTemplate *ItemTemplateClient
// Label is the client for interacting with the Label builders.
Label *LabelClient
// Location is the client for interacting with the Location builders.
Location *LocationClient
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
MaintenanceEntry *MaintenanceEntryClient
// Notifier is the client for interacting with the Notifier builders.
@@ -174,13 +174,13 @@ func (tx *Tx) init() {
tx.Attachment = NewAttachmentClient(tx.config)
tx.AuthRoles = NewAuthRolesClient(tx.config)
tx.AuthTokens = NewAuthTokensClient(tx.config)
tx.Entity = NewEntityClient(tx.config)
tx.EntityField = NewEntityFieldClient(tx.config)
tx.EntityType = NewEntityTypeClient(tx.config)
tx.Group = NewGroupClient(tx.config)
tx.GroupInvitationToken = NewGroupInvitationTokenClient(tx.config)
tx.Item = NewItemClient(tx.config)
tx.ItemField = NewItemFieldClient(tx.config)
tx.ItemTemplate = NewItemTemplateClient(tx.config)
tx.Label = NewLabelClient(tx.config)
tx.Location = NewLocationClient(tx.config)
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
tx.Notifier = NewNotifierClient(tx.config)
tx.TemplateField = NewTemplateFieldClient(tx.config)

View File

@@ -0,0 +1,31 @@
package main
import (
"context"
"log"
"os"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
_ "github.com/sysadminsmedia/homebox/backend/internal/data/ent/migrate"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
)
func main() {
client, err := ent.Open("postgres", "host=localhost port=5432 user=homebox dbname=homebox password=homebox sslmode=disable")
if err != nil {
log.Fatalf("failed connecting to mysql: %v", err)
}
defer client.Close()
ctx := context.Background()
// Dump migration changes to an SQL script.
f, err := os.Create("migrate.sql")
if err != nil {
log.Fatalf("create migrate file: %v", err)
}
defer f.Close()
if err := client.Schema.WriteTo(ctx, f); err != nil {
log.Fatalf("failed printing schema changes: %v", err)
}
}

View File

@@ -30,5 +30,4 @@ func Migrations(dialect string) (embed.FS, error) {
return embed.FS{}, fmt.Errorf("unknown sql dialect: %s", dialect)
}
// This should never get hit, but just in case
return sqliteFiles, nil
}

View File

@@ -0,0 +1,249 @@
package postgres
import (
"context"
"database/sql"
"fmt"
"time"
"github.com/google/uuid"
"github.com/pressly/goose/v3"
)
//nolint:gochecknoinits
func init() {
goose.AddMigrationNoTxContext(Up20250831120000, Down20250831120000)
}
func Up20250831120000(ctx context.Context, tx *sql.DB) error {
// Create entity_types table
_, err := tx.ExecContext(ctx, `
CREATE TABLE "entity_types" (
"id" uuid NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"name" character varying NOT NULL,
"description" character varying NULL,
"icon" character varying NULL,
"color" character varying NULL,
"is_location" boolean NOT NULL DEFAULT false,
"group_entity_types" uuid NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT "entity_types_groups_entity_types" FOREIGN KEY ("group_entity_types") REFERENCES "groups" ("id") ON DELETE CASCADE
);
CREATE INDEX "entitytype_name" ON "entity_types" ("name");
CREATE INDEX "entitytype_is_location" ON "entity_types" ("is_location");
`)
if err != nil {
return fmt.Errorf("failed to create entity_types table: %w", err)
}
// Create entities table
_, err = tx.ExecContext(ctx, `
CREATE TABLE "entities" (
"id" uuid NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"name" character varying NOT NULL,
"description" character varying NULL,
"import_ref" character varying NULL,
"notes" character varying NULL,
"quantity" bigint NOT NULL DEFAULT 1,
"insured" boolean NOT NULL DEFAULT false,
"archived" boolean NOT NULL DEFAULT false,
"asset_id" bigint NOT NULL DEFAULT 0,
"sync_child_entities_locations" boolean NOT NULL DEFAULT false,
"serial_number" character varying NULL,
"model_number" character varying NULL,
"manufacturer" character varying NULL,
"lifetime_warranty" boolean NOT NULL DEFAULT false,
"warranty_expires" timestamptz NULL,
"warranty_details" character varying NULL,
"purchase_time" timestamptz NULL,
"purchase_from" character varying NULL,
"purchase_price" double precision NOT NULL DEFAULT 0,
"sold_time" timestamptz NULL, "sold_to" character varying NULL,
"sold_price" double precision NOT NULL DEFAULT 0,
"sold_notes" character varying NULL,
"entity_parent" uuid NULL,
"entity_location" uuid NULL,
"entity_type_entities" uuid NULL,
"group_entities" uuid NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT "entities_entities_parent" FOREIGN KEY ("entity_parent") REFERENCES "entities" ("id") ON DELETE SET NULL,
CONSTRAINT "entities_entities_location" FOREIGN KEY ("entity_location") REFERENCES "entities" ("id") ON DELETE SET NULL,
CONSTRAINT "entities_entity_types_entities" FOREIGN KEY ("entity_type_entities") REFERENCES "entity_types" ("id") ON DELETE SET NULL,
CONSTRAINT "entities_groups_entities" FOREIGN KEY ("group_entities") REFERENCES "groups" ("id") ON DELETE CASCADE);
CREATE INDEX "entity_name" ON "entities" ("name");
CREATE INDEX "entity_manufacturer" ON "entities" ("manufacturer");
CREATE INDEX "entity_model_number" ON "entities" ("model_number");
CREATE INDEX "entity_serial_number" ON "entities" ("serial_number");
CREATE INDEX "entity_archived" ON "entities" ("archived");
CREATE INDEX "entity_asset_id" ON "entities" ("asset_id");
`)
if err != nil {
return fmt.Errorf("failed to create entities table: %w", err)
}
// Fetch all groups to create default entity types for each group
groups, err := tx.QueryContext(ctx, `SELECT id FROM "groups"`)
if err != nil {
return fmt.Errorf("failed to query groups: %w", err)
}
defer func(rows *sql.Rows) {
err := rows.Close()
if err != nil {
fmt.Printf("failed to close rows: %v\n", err)
}
}(groups)
// Process each group and create default entity types
for groups.Next() {
var groupID uuid.UUID
if err := groups.Scan(&groupID); err != nil {
return fmt.Errorf("failed to scan group ID: %w", err)
}
// Create default 'Item' entity type for this group
itemTypeID := uuid.New()
now := time.Now().UTC()
_, err = tx.ExecContext(ctx, `
INSERT INTO "entity_types" ("id", "created_at", "updated_at", "name", "description", "is_location", "group_entity_types")
VALUES ($1, $2, $3, $4, $5, $6, $7)
`, itemTypeID, now, now, "Item", "Default item type", false, groupID)
if err != nil {
return fmt.Errorf("failed to create Item entity type for group %s: %w", groupID, err)
}
// Create default 'Location' entity type for this group
locTypeID := uuid.New()
_, err = tx.ExecContext(ctx, `
INSERT INTO "entity_types" ("id", "created_at", "updated_at", "name", "description", "is_location", "group_entity_types")
VALUES ($1, $2, $3, $4, $5, $6, $7)
`, locTypeID, now, now, "Location", "Default location type", true, groupID)
if err != nil {
return fmt.Errorf("failed to create Location entity type for group %s: %w", groupID, err)
}
// Migrate existing locations to entities
_, err = tx.ExecContext(ctx, `
INSERT INTO "entities" (
"id", "created_at", "updated_at", "name", "description",
"group_entities", "entity_parent", "entity_type_entities"
)
SELECT
l."id", l."created_at", l."updated_at", l."name", l."description",
l."group_locations", l."location_children", $1
FROM "locations" l
WHERE l."group_locations" = $2
`, locTypeID, groupID)
if err != nil {
return fmt.Errorf("failed to migrate locations to entities for group %s: %w", groupID, err)
}
// Migrate existing items to entities
_, err = tx.ExecContext(ctx, `
INSERT INTO "entities" (
"id", "created_at", "updated_at", "name", "description",
"import_ref", "notes", "quantity", "insured", "archived",
"asset_id", "serial_number", "model_number", "manufacturer",
"lifetime_warranty", "warranty_expires", "warranty_details", "purchase_time",
"purchase_from", "purchase_price", "sold_time", "sold_to",
"sold_price", "sold_notes", "group_entities", "entity_parent", "sync_child_entities_locations",
"entity_type_entities")
SELECT
i."id", i."created_at", i."updated_at", i."name", i."description",
i."import_ref", i."notes", i."quantity", i."insured", i."archived",
i."asset_id", i."serial_number", i."model_number", i."manufacturer",
i."lifetime_warranty", i."warranty_expires", i."warranty_details", i."purchase_time",
i."purchase_from", i."purchase_price", i."sold_time", i."sold_to",
i."sold_price", i."sold_notes", i."group_items", i."item_children", i."sync_child_items_locations",
$1
FROM "items" i WHERE i."group_items" = $2
`, itemTypeID, groupID)
if err != nil {
return fmt.Errorf("failed to migrate items to entities for group %s: %w", groupID, err)
}
}
_, err = tx.ExecContext(ctx, `
ALTER TABLE "maintenance_entries" DROP CONSTRAINT "maintenance_entries_items_maintenance_entries",
ADD COLUMN "entity_id" uuid NOT NULL;
UPDATE "maintenance_entries" SET "entity_id" = "item_id";
ALTER TABLE "maintenance_entries" ADD CONSTRAINT "maintenance_entries_entities_maintenance_entries" FOREIGN KEY ("entity_id") REFERENCES "entities" ("id") ON DELETE CASCADE;
ALTER TABLE "maintenance_entries" DROP COLUMN "item_id";
`)
if err != nil {
return fmt.Errorf("failed to migrate maintence_entries to use entities: %w", err)
}
_, err = tx.ExecContext(ctx, `
ALTER TABLE "attachments" DROP CONSTRAINT "attachments_no_self_reference",
DROP CONSTRAINT "attachments_items_attachments",
ALTER COLUMN "mime_type" SET NOT NULL,
ADD COLUMN "entity_attachments" uuid NULL,
ADD CONSTRAINT "attachments_entities_attachments" FOREIGN KEY ("entity_attachments") REFERENCES "entities" ("id") ON DELETE CASCADE;
UPDATE "attachments" SET "entity_attachments" = "item_attachments";
ALTER TABLE "attachments" DROP COLUMN "item_attachments";
CREATE UNIQUE INDEX "attachments_attachment_thumbnail_key" ON "attachments" ("attachment_thumbnail");
`)
if err != nil {
return fmt.Errorf("failed to migrate attachments to use entities: %w", err)
}
_, err = tx.ExecContext(ctx, `
CREATE TABLE "entity_fields" (
"id" uuid NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"name" character varying NOT NULL,
"description" character varying NULL,
"type" character varying NOT NULL,
"text_value" character varying NULL,
"number_value" bigint NULL,
"boolean_value" boolean NOT NULL DEFAULT false,
"time_value" timestamptz NOT NULL,
"entity_fields" uuid NULL,
PRIMARY KEY ("id"),
CONSTRAINT "entity_fields_entities_fields" FOREIGN KEY ("entity_fields") REFERENCES "entities" ("id") ON DELETE CASCADE);
INSERT INTO "entity_fields" ("id", "created_at", "updated_at", "name", "description", "type", "text_value", "number_value", "boolean_value", "time_value", "entity_fields")
SELECT "id", "created_at", "updated_at", "name", "description", "type", "text_value", "number_value", "boolean_value", "time_value", item_fields."item_fields"
FROM "item_fields";
`)
if err != nil {
return fmt.Errorf("failed to create entity_fields table and migrate data: %w", err)
}
_, err = tx.ExecContext(ctx, `
CREATE TABLE "label_entities"(
"label_id" uuid NOT NULL,
"entity_id" uuid NOT NULL,
PRIMARY KEY ("label_id", "entity_id"),
CONSTRAINT "label_entities_label_id" FOREIGN KEY ("label_id") REFERENCES "labels" ("id") ON DELETE CASCADE,
CONSTRAINT "label_entities_entity_id" FOREIGN KEY ("entity_id") REFERENCES "entities" ("id") ON DELETE CASCADE);
INSERT INTO "label_entities" ("label_id", "entity_id")
SELECT "label_id", "item_id" FROM "label_items";
`)
if err != nil {
return fmt.Errorf("failed to create label_entities table and migrate data: %w", err)
}
_, err = tx.ExecContext(ctx, `
DROP TABLE IF EXISTS "label_items";
DROP TABLE IF EXISTS "item_fields";
DROP TABLE IF EXISTS "items";
DROP TABLE IF EXISTS "locations";
`)
if err != nil {
return fmt.Errorf("failed to drop old tables: %w", err)
}
return nil
}
func Down20250831120000(ctx context.Context, tx *sql.DB) error {
return nil
}

Some files were not shown because too many files have changed in this diff Show More