Compare commits

..

36 Commits

Author SHA1 Message Date
Katos
87c1f0333f Fix test data 2025-12-27 21:36:26 +00:00
Katos
570ad8fbf8 Attempt to fix tests action 2025-12-27 21:32:15 +00:00
Harrison Conlin
f0b8bb8b7f refactor(backend): use constants for database driver names (#1177)
magic constants are bad m'kay
2025-12-27 16:16:48 -05:00
Katos
ecc9fa1959 Disable triggers in upgrade-test.yaml
Comment out the workflow triggers in upgrade-test.yaml
2025-12-27 20:28:31 +00:00
Katos
7068a85dfb Merge pull request #1178 from sysadminsmedia/copilot/create-ci-cd-pipeline
Add CI/CD workflow for upgrade testing with data integrity verification
2025-12-27 20:18:37 +00:00
Katos
c73922c754 Merge branch 'main' into copilot/create-ci-cd-pipeline 2025-12-27 20:16:41 +00:00
Matthew Kilgore
ae2179c01c Add blog link 2025-12-27 12:05:05 -05:00
copilot-swe-agent[bot]
09e056a3fb Move upgrade verification tests to separate directory
- Move upgrade-verification.spec.ts from test/e2e/ to test/upgrade/
- This prevents the test from running during normal E2E CI runs
- The upgrade test is only meant for the upgrade-test workflow
- Update workflow and documentation to reflect new location

Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 16:12:51 +00:00
Katos
4abfc76865 Fix CodeRabbit date quoting issue 2025-12-27 16:01:57 +00:00
copilot-swe-agent[bot]
afd7a10003 Fix TypeScript null check in upgrade-verification test
Add null check for pageContent before accessing length property

Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:34:59 +00:00
copilot-swe-agent[bot]
8eedd1e39d Fix ESLint errors in upgrade-verification.spec.ts
- Remove unused 'path' import
- Replace 'any' types with proper TypeScript interfaces
- Fix all Prettier formatting issues

Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:32:57 +00:00
copilot-swe-agent[bot]
fedeb1a7e5 Add proper GITHUB_TOKEN permissions to workflow
Set minimal required permissions (contents:read, packages:read) to follow security best practices

Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:14:52 +00:00
copilot-swe-agent[bot]
69b31a3be5 Improve test reliability and fix security issues
- Replace waitForTimeout with waitForSelector and waitForLoadState
- Remove eval security risk in bash script
- Use proper wait mechanisms for better test reliability

Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:12:22 +00:00
copilot-swe-agent[bot]
31d306ca05 Add comprehensive documentation for upgrade test workflow
Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:09:37 +00:00
copilot-swe-agent[bot]
1bfb716cea Add upgrade test workflow with data generation and verification
Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:08:13 +00:00
copilot-swe-agent[bot]
13b1524c56 Initial plan for upgrade test workflow
Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
2025-12-27 14:06:05 +00:00
copilot-swe-agent[bot]
b18599b6f4 Initial plan 2025-12-27 14:02:31 +00:00
Matthew Kilgore
473027c1ae Fix notifiers gettings wiped 2025-12-26 17:27:18 -05:00
Matthew Kilgore
3a77440996 Fix flip flopped columns 2025-12-26 15:50:04 -05:00
Matthew Kilgore
731765c36c Make sure the right columns get migrated into the correct columns 2025-12-26 15:09:02 -05:00
Matthew Kilgore
a86b1bd17b Update dependencies 2025-12-26 09:51:33 -05:00
Matthew Kilgore
064b298968 Merge branch 'main' into main-weblate
# Conflicts:
#	frontend/locales/en.json
2025-12-26 09:28:10 -05:00
Tonya
2638f218f3 fix: templates that dont have a location set (#1160) 2025-12-24 17:30:46 +00:00
Dan
0f4f398b5a Added documentation for the external label service feature. (#1018)
* Added documentation for the external label service feature. Re-ordered the columns in the config page to make it easier to read.

* Update docs/en/configure/index.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Matt <tankerkiller125@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-12-23 21:36:19 +00:00
Copilot
545993a8aa Fix Windows attachment path encoding in blob storage operations (#1144)
* Initial plan

* Initial plan for fixing Windows attachment path issue

Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>

* Fix Windows attachment path encoding issue by normalizing to forward slashes

Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>

* Refactor path normalization into helper function per code review

Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>

* Update progress - all checks complete

Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tankerkiller125 <3457368+tankerkiller125@users.noreply.github.com>
2025-12-23 10:27:42 -05:00
tonyaellie
a1947dd09e feat: autosave after image upload 2025-12-22 23:46:29 +00:00
tonyaellie
018f1f5977 fix: use logical sorting for locations 2025-12-22 23:34:29 +00:00
tonyaellie
9a9e3d462e feat: add a clear button for selectors and stop create modal overflow 2025-12-22 23:24:01 +00:00
Weblate
fc8b6f0dcf Translated using Weblate (German)
Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 95.4% (581 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Russian)

Currently translated at 96.2% (586 of 609 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Czech)

Currently translated at 99.8% (608 of 609 strings)

Translated using Weblate (German)

Currently translated at 99.3% (605 of 609 strings)

Translated using Weblate (German)

Currently translated at 99.1% (604 of 609 strings)

Translated using Weblate (German)

Currently translated at 99.1% (604 of 609 strings)

Translated using Weblate (German)

Currently translated at 90.3% (550 of 609 strings)

Translated using Weblate (German)

Currently translated at 90.3% (550 of 609 strings)

Translated using Weblate (German)

Currently translated at 90.1% (549 of 609 strings)

Translated using Weblate (German)

Currently translated at 89.9% (548 of 609 strings)

Translated using Weblate (Indonesian)

Currently translated at 60.0% (366 of 609 strings)

Translated using Weblate (Thai)

Currently translated at 22.0% (134 of 609 strings)

Translated using Weblate (Norwegian Bokmål)

Currently translated at 80.4% (490 of 609 strings)

Translated using Weblate (Slovak)

Currently translated at 84.8% (517 of 609 strings)

Translated using Weblate (Finnish)

Currently translated at 53.3% (325 of 609 strings)

Translated using Weblate (Ukrainian)

Currently translated at 59.7% (364 of 609 strings)

Translated using Weblate (English)

Currently translated at 100.0% (609 of 609 strings)

Translated using Weblate (Greek)

Currently translated at 0.3% (2 of 551 strings)

Added translation using Weblate (Greek)

Translated using Weblate (Italian)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (Russian)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (Telugu)

Currently translated at 0.9% (5 of 551 strings)

Translated using Weblate (Telugu)

Currently translated at 0.9% (5 of 551 strings)

Added translation using Weblate (Telugu)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Bosnian)

Currently translated at 21.9% (121 of 551 strings)

Translated using Weblate (Danish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Turkish)

Currently translated at 91.6% (505 of 551 strings)

Translated using Weblate (Turkish)

Currently translated at 89.2% (492 of 551 strings)

Translated using Weblate (Turkish)

Currently translated at 89.2% (492 of 551 strings)

Translated using Weblate (Russian)

Currently translated at 99.2% (547 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 65.8% (363 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 64.4% (355 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 62.7% (346 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 62.4% (344 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 61.1% (337 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 60.4% (333 of 551 strings)

Translated using Weblate (Ukrainian)

Currently translated at 59.3% (327 of 551 strings)

Translated using Weblate (Thai)

Currently translated at 24.1% (133 of 551 strings)

Translated using Weblate (Thai)

Currently translated at 24.1% (133 of 551 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (French)

Currently translated at 94.1% (519 of 551 strings)

Translated using Weblate (Polish)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (German)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (German)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (German)

Currently translated at 99.8% (550 of 551 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.9% (545 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Swedish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (551 of 551 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Polish)

Currently translated at 98.7% (543 of 550 strings)

Translated using Weblate (Polish)

Currently translated at 98.7% (543 of 550 strings)

Translated using Weblate (Polish)

Currently translated at 98.7% (543 of 550 strings)

Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 98.5% (542 of 550 strings)

Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 98.5% (542 of 550 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 98.3% (541 of 550 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 98.3% (541 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Indonesian)

Currently translated at 66.3% (365 of 550 strings)

Translated using Weblate (Portuguese (Portugal))

Currently translated at 93.4% (514 of 550 strings)

Translated using Weblate (Swedish)

Currently translated at 68.3% (376 of 550 strings)

Translated using Weblate (Swedish)

Currently translated at 68.3% (376 of 550 strings)

Translated using Weblate (Swedish)

Currently translated at 68.3% (376 of 550 strings)

Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 98.1% (540 of 550 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Dutch)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (550 of 550 strings)

Translated using Weblate (German)

Currently translated at 96.0% (528 of 550 strings)

Translated using Weblate (German)

Currently translated at 96.0% (528 of 550 strings)

Translated using Weblate (Turkish)

Currently translated at 87.7% (482 of 549 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Arabic)

Currently translated at 0.7% (4 of 518 strings)

Translated using Weblate (Arabic)

Currently translated at 0.5% (3 of 518 strings)

Added translation using Weblate (Arabic)

Translated using Weblate (Thai)

Currently translated at 22.9% (119 of 518 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (518 of 518 strings)

Translated using Weblate (Swedish)

Currently translated at 71.2% (369 of 518 strings)

Translated using Weblate (Swedish)

Currently translated at 71.2% (369 of 518 strings)

Co-authored-by: Adam Havránek <adamhavra@seznam.cz>
Co-authored-by: Aniruddh Kotte <aniruddhkotte@gmail.com>
Co-authored-by: BoneGear <bonegear@hotmail.com>
Co-authored-by: DevHrytsan <3axapHrytsan@gmail.com>
Co-authored-by: Eisa Al Shamsi <awwase@gmail.com>
Co-authored-by: Hannes Salen <hannes.salen@gmail.com>
Co-authored-by: Heine Olsen <olsen10051988@gmail.com>
Co-authored-by: Henrique dos Santos Wisniewski <henriqueswisniewski@gmail.com>
Co-authored-by: Jackxwb <xwb9606@163.com>
Co-authored-by: Jan Fader <jan.fader@web.de>
Co-authored-by: JorgeS15 <jorgea15santos@gmail.com>
Co-authored-by: Loffa <jesperfalk94@gmail.com>
Co-authored-by: Marcelo Sandrini <sandrini.marcelo@gmail.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
Co-authored-by: Matvey <mrspanky@yandex.ru>
Co-authored-by: Mikolaj Wolicki <MIKOLAJW1997@gmail.com>
Co-authored-by: Mirad Maglic <mirad.maglic@gmail.com>
Co-authored-by: Muhammad Ikhsan <pararang@gmail.com>
Co-authored-by: Mutagenic <mkardas@gmail.com>
Co-authored-by: MyMemory <noreply-mt-mymemory@weblate.org>
Co-authored-by: Ricardo González <notorius28@gmail.com>
Co-authored-by: Robert Eggl <robert@eggl.dev>
Co-authored-by: Sara Wattanasombat <saraten2@gmail.com>
Co-authored-by: Simone Girardi <s.girardi92@gmail.com>
Co-authored-by: Slydite4 <39199098+Slydite4@users.noreply.github.com>
Co-authored-by: Stratos Palaiologos <stpa03@betssongroup.com>
Co-authored-by: Supphakorn <supphakorn5343@gmail.com>
Co-authored-by: Weblate <noreply-mt-weblate@weblate.org>
Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: WilliamStark <yujinghao007@163.com>
Co-authored-by: Yao Yimeng <yym900902@gmail.com>
Co-authored-by: akrstlv <zmilex@gmail.com>
Co-authored-by: arsenius88 <arsenovich_andr@ukr.net>
Co-authored-by: buzz <buzz.eclair@gmail.com>
Co-authored-by: dARK raVEr <Dark.Raver@gmx.net>
Co-authored-by: efe <vastly-fax-brim@duck.com>
Co-authored-by: fjrefluxx <julianzobel@gmail.com>
Co-authored-by: jesper rezler lang <jesper.rezler.lang@gmail.com>
Co-authored-by: jjxxzz <jaro689@gmail.com>
Co-authored-by: noxmyn <vladcraft93@gmail.com>
Co-authored-by: sg4r3z <giovannigln@gmail.com>
Co-authored-by: swedishpete <nyhetsutskick@outlook.com>
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/ar/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/bs/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/cs/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/da/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/de/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/el/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/en/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/es/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/fi/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/fr/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/id/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/it/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/nb_NO/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/nl/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/pl/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/pt_BR/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/pt_PT/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/ru/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/sk/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/sv/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/te/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/th/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/tr/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/uk/
Translate-URL: https://translate.sysadminsmedia.com/projects/homebox/frontend/zh_Hans/
Translation: Homebox/Frontend
2025-12-22 11:19:55 +00:00
tonyaellie
37890c2a22 docs: update OIDC configuration details 2025-12-22 11:19:49 +00:00
Tonya
096b682f0a Improve oidc docs and fix attachment issue (#1153)
* fix: sort auth issues for oidc

* feat: improve oidc docs
2025-12-21 22:11:38 +00:00
Tonya
e4d8bb2ada chore: use example.com for example
better safe than sorry
2025-12-20 21:50:44 +00:00
Katos
3becf046e6 Merge pull request #1147 from sysadminsmedia/katos/docs-variable
Update max file upload environment variable
2025-12-20 16:01:04 +00:00
Katos
a21b3257d4 Update max file upload environment variable 2025-12-20 15:57:14 +00:00
Robert Eggl
5f9ab577bb fix: request camera permission in ScannerModal (#1113)
* feat: request camera permission in ScannerModal

* chore: simplify source code
2025-12-19 21:47:37 +00:00
Robert Eggl
0a969bb64d fix(sidebar): prevent dropdown menu layout shift on hover (#1116) 2025-12-19 21:38:06 +00:00
188 changed files with 21654 additions and 26500 deletions

259
.github/scripts/upgrade-test/README.md vendored Normal file
View File

@@ -0,0 +1,259 @@
# HomeBox Upgrade Testing Workflow
This document describes the automated upgrade testing workflow for HomeBox.
## Overview
The upgrade test workflow is designed to ensure data integrity and functionality when upgrading HomeBox from one version to another. It automatically:
1. Deploys a stable version of HomeBox
2. Creates test data (users, items, locations, labels, notifiers, attachments)
3. Upgrades to the latest version from the main branch
4. Verifies all data and functionality remain intact
## Workflow File
**Location**: `.github/workflows/upgrade-test.yaml`
## Trigger Conditions
The workflow runs:
- **Daily**: Automatically at 2 AM UTC (via cron schedule)
- **Manual**: Can be triggered manually via GitHub Actions UI
- **On Push**: When changes are made to the workflow files or test scripts
## Test Scenarios
### 1. Environment Setup
- Pulls the latest stable HomeBox Docker image from GHCR
- Starts the application with test configuration
- Ensures the service is healthy and ready
### 2. Data Creation
The workflow creates comprehensive test data using the `create-test-data.sh` script:
#### Users and Groups
- **Group 1**: 5 users (user1@homebox.test through user5@homebox.test)
- **Group 2**: 2 users (user6@homebox.test and user7@homebox.test)
- All users have password: `TestPassword123!`
#### Locations
- **Group 1**: Living Room, Garage
- **Group 2**: Home Office
#### Labels
- **Group 1**: Electronics, Important
- **Group 2**: Work Equipment
#### Items
- **Group 1**: 5 items (Laptop Computer, Power Drill, TV Remote, Tool Box, Coffee Maker)
- **Group 2**: 2 items (Monitor, Keyboard)
#### Attachments
- Multiple attachments added to various items (receipts, manuals, warranties)
#### Notifiers
- **Group 1**: Test notifier named "TESTING"
### 3. Upgrade Process
1. Stops the stable version container
2. Builds a fresh image from the current main branch
3. Copies the database to a new location
4. Starts the new version with the existing data
### 4. Verification Tests
The Playwright test suite (`upgrade-verification.spec.ts`) verifies:
-**User Authentication**: All 7 users can log in with their credentials
-**Data Persistence**: All items, locations, and labels are present
-**Attachments**: File attachments are correctly associated with items
-**Notifiers**: The "TESTING" notifier is still configured
-**UI Functionality**: Version display, theme switching work correctly
-**Data Isolation**: Groups can only see their own data
## Test Data File
The setup script generates a JSON file at `/tmp/test-users.json` containing:
```json
{
"users": [
{
"email": "user1@homebox.test",
"password": "TestPassword123!",
"token": "...",
"group": "1"
},
...
],
"locations": {
"group1": ["location-id-1", "location-id-2"],
"group2": ["location-id-3"]
},
"labels": {...},
"items": {...},
"notifiers": {...}
}
```
This file is used by the Playwright tests to verify data integrity.
## Scripts
### create-test-data.sh
**Location**: `.github/scripts/upgrade-test/create-test-data.sh`
**Purpose**: Creates all test data via the HomeBox REST API
**Environment Variables**:
- `HOMEBOX_URL`: Base URL of the HomeBox instance (default: http://localhost:7745)
- `TEST_DATA_FILE`: Path to output JSON file (default: /tmp/test-users.json)
**Requirements**:
- `curl`: For API calls
- `jq`: For JSON processing
**Usage**:
```bash
export HOMEBOX_URL=http://localhost:7745
./.github/scripts/upgrade-test/create-test-data.sh
```
## Running Tests Locally
To run the upgrade tests locally:
### Prerequisites
```bash
# Install dependencies
sudo apt-get install -y jq curl docker.io
# Install pnpm and Playwright
cd frontend
pnpm install
pnpm exec playwright install --with-deps chromium
```
### Run the test
```bash
# Start stable version
docker run -d \
--name homebox-test \
-p 7745:7745 \
-e HBOX_OPTIONS_ALLOW_REGISTRATION=true \
-v /tmp/homebox-data:/data \
ghcr.io/sysadminsmedia/homebox:latest
# Wait for startup
sleep 10
# Create test data
export HOMEBOX_URL=http://localhost:7745
./.github/scripts/upgrade-test/create-test-data.sh
# Stop container
docker stop homebox-test
docker rm homebox-test
# Build new version
docker build -t homebox:test .
# Start new version with existing data
docker run -d \
--name homebox-test \
-p 7745:7745 \
-e HBOX_OPTIONS_ALLOW_REGISTRATION=true \
-v /tmp/homebox-data:/data \
homebox:test
# Wait for startup
sleep 10
# Run verification tests
cd frontend
TEST_DATA_FILE=/tmp/test-users.json \
E2E_BASE_URL=http://localhost:7745 \
pnpm exec playwright test \
--project=chromium \
test/upgrade/upgrade-verification.spec.ts
# Cleanup
docker stop homebox-test
docker rm homebox-test
```
## Artifacts
The workflow produces several artifacts:
1. **playwright-report-upgrade-test**: HTML report of test results
2. **playwright-traces**: Detailed traces for debugging failures
3. **Docker logs**: Collected on failure for troubleshooting
## Failure Scenarios
The workflow will fail if:
- The stable version fails to start
- Test data creation fails
- The new version fails to start with existing data
- Any verification test fails
- Database migrations fail
## Troubleshooting
### Test Data Creation Fails
Check the Docker logs:
```bash
docker logs homebox-old
```
Verify the API is accessible:
```bash
curl http://localhost:7745/api/v1/status
```
### Verification Tests Fail
1. Download the Playwright report from GitHub Actions artifacts
2. Review the HTML report for detailed failure information
3. Check traces for visual debugging
### Database Issues
If migrations fail:
```bash
# Check database file
ls -lh /tmp/homebox-data-new/homebox.db
# Check Docker logs for migration errors
docker logs homebox-new
```
## Future Enhancements
Potential improvements:
- [ ] Test multiple upgrade paths (e.g., v0.10 → v0.11 → v0.12)
- [ ] Test with PostgreSQL backend in addition to SQLite
- [ ] Add performance benchmarks
- [ ] Test with larger datasets
- [ ] Add API-level verification in addition to UI tests
- [ ] Test backup and restore functionality
## Related Files
- `.github/workflows/upgrade-test.yaml` - Main workflow definition
- `.github/scripts/upgrade-test/create-test-data.sh` - Data generation script
- `frontend/test/upgrade/upgrade-verification.spec.ts` - Playwright verification tests
- `.github/workflows/e2e-partial.yaml` - Standard E2E test workflow (for reference)
## Support
For issues or questions about this workflow:
1. Check the GitHub Actions run logs
2. Review this documentation
3. Open an issue in the repository

View File

@@ -0,0 +1,153 @@
#!/bin/bash
# Script to create test data in HomeBox for upgrade testing
set -e
HOMEBOX_URL="${HOMEBOX_URL:-http://localhost:7745}"
API_URL="${HOMEBOX_URL}/api/v1"
TEST_DATA_FILE="${TEST_DATA_FILE:-/tmp/test-users.json}"
echo "Creating test data in HomeBox at $HOMEBOX_URL"
# Function to make API calls with error handling
api_call() {
local method=$1
local endpoint=$2
local data=$3
local token=$4
local response
if [ -n "$token" ]; then
response=$(curl -s -X "$method" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d "$data" \
"$API_URL$endpoint")
else
response=$(curl -s -X "$method" \
-H "Content-Type: application/json" \
-d "$data" \
"$API_URL$endpoint")
fi
# Validate response is proper JSON
if ! echo "$response" | jq '.' > /dev/null 2>&1; then
echo "Invalid API response for $endpoint: $response" >&2
exit 1
fi
echo "$response"
}
# Function to initialize the test data JSON file
initialize_test_data() {
echo "Initializing test data JSON file: $TEST_DATA_FILE"
if [ -f "$TEST_DATA_FILE" ]; then
echo "Removing existing test data file..."
rm -f "$TEST_DATA_FILE"
fi
echo "{\"users\":[],\"locations\":[],\"labels\":[],\"items\":[],\"attachments\":[],\"notifiers\":[]}" > "$TEST_DATA_FILE"
}
# Function to add content to JSON data file
add_to_test_data() {
local key=$1
local value=$2
jq --argjson data "$value" ".${key} += [\$data]" "$TEST_DATA_FILE" > "${TEST_DATA_FILE}.tmp" && mv "${TEST_DATA_FILE}.tmp" "$TEST_DATA_FILE"
}
# Register a user and get their auth token
register_user() {
local email=$1
local name=$2
local password=$3
local group_token=$4
echo "Registering user: $email"
local payload="{\"email\":\"$email\",\"name\":\"$name\",\"password\":\"$password\""
if [ -n "$group_token" ]; then
payload="$payload,\"groupToken\":\"$group_token\""
fi
payload="$payload}"
api_call "POST" "/users/register" "$payload"
}
# Main logic for creating test data
initialize_test_data
# Group 1: Create 5 users
echo "=== Creating Group 1 Users ==="
group1_user1_response=$(register_user "user1@homebox.test" "User One" "password123")
group1_user1_token=$(echo "$group1_user1_response" | jq -r '.token // empty')
group1_invite_token=$(echo "$group1_user1_response" | jq -r '.group.inviteToken // empty')
if [ -z "$group1_user1_token" ]; then
echo "Failed to register the first group user" >&2
exit 1
fi
add_to_test_data "users" "{\"email\": \"user1@homebox.test\", \"token\": \"$group1_user1_token\", \"group\": 1}"
# Add 4 more users to the same group
for user in 2 3 4 5; do
response=$(register_user "user$user@homebox.test" "User $user" "password123" "$group1_invite_token")
token=$(echo "$response" | jq -r '.token // empty')
add_to_test_data "users" "{\"email\": \"user$user@homebox.test\", \"token\": \"$token\", \"group\": 1}"
done
# Group 2: Create 2 users
echo "=== Creating Group 2 Users ==="
group2_user1_response=$(register_user "user6@homebox.test" "User Six" "password123")
group2_user1_token=$(echo "$group2_user1_response" | jq -r '.token // empty')
group2_invite_token=$(echo "$group2_user1_response" | jq -r '.group.inviteToken // empty')
add_to_test_data "users" "{\"email\": \"user6@homebox.test\", \"token\": \"$group2_user1_token\", \"group\": 2}"
response=$(register_user "user7@homebox.test" "User Seven" "password123" "$group2_invite_token")
group2_user2_token=$(echo "$response" | jq -r '.token // empty')
add_to_test_data "users" "{\"email\": \"user7@homebox.test\", \"token\": \"$group2_user2_token\", \"group\": 2}"
# Create Locations
echo "=== Creating Locations ==="
group1_locations=()
group1_locations+=("$(api_call "POST" "/locations" "{ \"name\": \"Living Room\", \"description\": \"Family area\" }" "$group1_user1_token")")
group1_locations+=("$(api_call "POST" "/locations" "{ \"name\": \"Garage\", \"description\": \"Storage area\" }" "$group1_user1_token")")
group2_locations=()
group2_locations+=("$(api_call "POST" "/locations" "{ \"name\": \"Office\", \"description\": \"Workspace\" }" "$group2_user1_token")")
# Add Locations to Test Data
for loc in "${group1_locations[@]}"; do
loc_id=$(echo "$loc" | jq -r '.id // empty')
add_to_test_data "locations" "{\"id\": \"$loc_id\", \"group\": 1}"
done
for loc in "${group2_locations[@]}"; do
loc_id=$(echo "$loc" | jq -r '.id // empty')
add_to_test_data "locations" "{\"id\": \"$loc_id\", \"group\": 2}"
done
# Create Labels
echo "=== Creating Labels ==="
label1=$(api_call "POST" "/labels" "{ \"name\": \"Electronics\", \"description\": \"Devices\" }" "$group1_user1_token")
add_to_test_data "labels" "$label1"
label2=$(api_call "POST" "/labels" "{ \"name\": \"Important\", \"description\": \"High Priority\" }" "$group1_user1_token")
add_to_test_data "labels" "$label2"
# Create Items and Attachments
echo "=== Creating Items and Attachments ==="
item1=$(api_call "POST" "/items" "{ \"name\": \"Laptop\", \"description\": \"Work laptop\", \"locationId\": \"$(echo ${group1_locations[0]} | jq -r '.id // empty')\" }" "$group1_user1_token")
item1_id=$(echo "$item1" | jq -r '.id // empty')
add_to_test_data "items" "{\"id\": \"$item1_id\", \"group\": 1}"
attachment1=$(api_call "POST" "/items/$item1_id/attachments" "" "$group1_user1_token")
add_to_test_data "attachments" "{\"id\": \"$(echo $attachment1 | jq -r '.id // empty')\", \"itemId\": \"$item1_id\"}"
# Create Test Notifier
echo "=== Creating Notifiers ==="
notifier=$(api_call "POST" "/notifiers" "{ \"name\": \"TESTING\", \"url\": \"https://example.com/webhook\", \"isActive\": true }" "$group1_user1_token")
add_to_test_data "notifiers" "$notifier"
echo "=== Test Data Creation Complete ==="
cat "$TEST_DATA_FILE" | jq

184
.github/workflows/upgrade-test.yaml vendored Normal file
View File

@@ -0,0 +1,184 @@
name: HomeBox Upgrade Test
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger
push:
branches:
- main
paths:
- '.github/workflows/upgrade-test.yaml'
- '.github/scripts/upgrade-test/**'
jobs:
upgrade-test:
name: Test Upgrade Path
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
packages: read
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Setup dependencies (Node.js, Docker, pnpm, and Playwright)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install pnpm
uses: pnpm/action-setup@v3.0.0
with:
version: 9.12.2
- name: Install Playwright
run: |
cd frontend
pnpm install
pnpm exec playwright install --with-deps chromium
# Step 3: Prepare environment and /tmp directories
- name: Create test data directories
run: |
mkdir -p /tmp/homebox-data-old
mkdir -p /tmp/homebox-data-new
chmod -R 777 /tmp/homebox-data-old
chmod -R 777 /tmp/homebox-data-new
echo "Directories created:"
ls -la /tmp/
# Step 4: Pull and start the stable HomeBox image
- name: Pull latest stable HomeBox image
run: |
docker pull ghcr.io/sysadminsmedia/homebox:latest
- name: Start HomeBox (stable version)
run: |
docker run -d \
--name homebox-old \
--restart unless-stopped \
-p 7745:7745 \
-e HBOX_LOG_LEVEL=debug \
-e HBOX_OPTIONS_ALLOW_REGISTRATION=true \
-e TZ=UTC \
-v /tmp/homebox-data-old:/data \
ghcr.io/sysadminsmedia/homebox:latest
# Wait for the service to be ready
timeout 60 bash -c 'until curl -f http://localhost:7745/api/v1/status; do sleep 2; done'
echo "HomeBox stable version is ready"
# Step 5: Run test data script
- name: Create test data (users, items, locations, labels)
run: |
chmod +x .github/scripts/upgrade-test/create-test-data.sh
.github/scripts/upgrade-test/create-test-data.sh
env:
HOMEBOX_URL: http://localhost:7745
- name: Validate test data creation
run: |
echo "Verifying test data was created..."
# Check test-users.json content
cat /tmp/test-users.json | jq || echo "Test-users file is empty or malformed!"
# Check the database file exists
if [ ! -f /tmp/homebox-data-old/homebox.db ]; then
echo "No database found in the old instance directory!" && exit 1
fi
echo "Test data creation validated successfully!"
# Step 6: Stop the HomeBox stable instance
- name: Stop old HomeBox instance
run: |
docker stop homebox-old
docker rm homebox-old
# Step 7: Build HomeBox from the main branch
- name: Build HomeBox from main branch
run: |
docker build \
--build-arg VERSION=main \
--build-arg COMMIT=${{ github.sha }} \
--build-arg BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
-t homebox:test \
-f Dockerfile \
.
# Step 8: Start the new HomeBox version with migrated data
- name: Copy data to new location
run: |
cp -r /tmp/homebox-data-old/* /tmp/homebox-data-new/
chmod -R 777 /tmp/homebox-data-new
- name: Start HomeBox (new version)
run: |
docker run -d \
--name homebox-new \
--restart unless-stopped \
-p 7745:7745 \
-e HBOX_LOG_LEVEL=debug \
-e HBOX_OPTIONS_ALLOW_REGISTRATION=true \
-e TZ=UTC \
-v /tmp/homebox-data-new:/data \
homebox:test
# Wait for the updated service to be ready
timeout 60 bash -c 'until curl -f http://localhost:7745/api/v1/status; do sleep 2; done'
echo "HomeBox new version is ready"
# Step 9: Execute Playwright verification tests
- name: Run Playwright verification tests
run: |
cd frontend
TEST_DATA_FILE=/tmp/test-users.json \
E2E_BASE_URL=http://localhost:7745 \
pnpm exec playwright test \
-c ./test/playwright.config.ts \
test/upgrade/upgrade-verification.spec.ts
env:
HOMEBOX_URL: http://localhost:7745
# Step 10: Upload reports for review
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-upgrade-test
path: frontend/playwright-report/
retention-days: 30
- name: Upload test traces
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-traces
path: frontend/test-results/
retention-days: 7
# Step 11: Collect logs for failed instances
- name: Collect logs on failure
if: failure()
run: |
echo "=== Docker logs for new version ==="
docker logs homebox-new || true
echo "=== Database content ==="
ls -la /tmp/homebox-data-new || true
# Step 12: Cleanup resources
- name: Cleanup
if: always()
run: |
docker stop homebox-new || true
docker rm homebox-new || true
docker rmi homebox:test || true

14
.scaffold/go.sum Normal file
View File

@@ -0,0 +1,14 @@
entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=
entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/sysadminsmedia/homebox/backend v0.0.0-20251212183312-2d1d3d927bfd h1:QULUJSgHc4rSlTjb2qYT6FIgwDWFCqEpnYqc/ltsrkk=
github.com/sysadminsmedia/homebox/backend v0.0.0-20251212183312-2d1d3d927bfd/go.mod h1:jB+tPmHtPDM1VnAjah0gvcRfP/s7c+rtQwpA8cvZD/U=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

87
.vscode/launch.json vendored
View File

@@ -1,44 +1,47 @@
{
// 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

@@ -124,7 +124,7 @@ func (ctrl *V1Controller) HandleAuthLogin(ps ...AuthProvider) errchain.HandlerFu
return validate.NewUnauthorizedError()
}
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true)
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true, newToken.AttachmentToken)
return server.JSON(w, http.StatusOK, TokenResponse{
Token: "Bearer " + newToken.Raw,
ExpiresAt: newToken.ExpiresAt,
@@ -178,7 +178,7 @@ func (ctrl *V1Controller) HandleAuthRefresh() errchain.HandlerFunc {
return validate.NewUnauthorizedError()
}
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, false)
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, false, newToken.AttachmentToken)
return server.JSON(w, http.StatusOK, newToken)
}
}
@@ -187,7 +187,7 @@ func noPort(host string) string {
return strings.Split(host, ":")[0]
}
func (ctrl *V1Controller) setCookies(w http.ResponseWriter, domain, token string, expires time.Time, remember bool) {
func (ctrl *V1Controller) setCookies(w http.ResponseWriter, domain, token string, expires time.Time, remember bool, attachmentToken string) {
http.SetCookie(w, &http.Cookie{
Name: cookieNameRemember,
Value: strconv.FormatBool(remember),
@@ -219,6 +219,19 @@ func (ctrl *V1Controller) setCookies(w http.ResponseWriter, domain, token string
HttpOnly: false,
Path: "/",
})
// Set attachment token cookie (accessible to frontend, not HttpOnly)
if attachmentToken != "" {
http.SetCookie(w, &http.Cookie{
Name: "hb.auth.attachment_token",
Value: attachmentToken,
Expires: expires,
Domain: domain,
Secure: ctrl.cookieSecure,
HttpOnly: false,
Path: "/",
})
}
}
func (ctrl *V1Controller) unsetCookies(w http.ResponseWriter, domain string) {
@@ -252,6 +265,17 @@ func (ctrl *V1Controller) unsetCookies(w http.ResponseWriter, domain string) {
HttpOnly: false,
Path: "/",
})
// Unset attachment token cookie
http.SetCookie(w, &http.Cookie{
Name: "hb.auth.attachment_token",
Value: "",
Expires: time.Unix(0, 0),
Domain: domain,
Secure: ctrl.cookieSecure,
HttpOnly: false,
Path: "/",
})
}
// HandleOIDCLogin godoc
@@ -310,7 +334,7 @@ func (ctrl *V1Controller) HandleOIDCCallback() errchain.HandlerFunc {
}
// Set cookies and redirect to home
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true)
ctrl.setCookies(w, noPort(r.Host), newToken.Raw, newToken.ExpiresAt, true, newToken.AttachmentToken)
http.Redirect(w, r, "/home", http.StatusFound)
return nil
}

View File

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

View File

@@ -1,243 +0,0 @@
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

@@ -1,99 +0,0 @@
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 (Deprecated) Query All Items
// @Summary Query All Items
// @Tags Items
// @Produce json
// @Param q query string false "search string"
@@ -34,7 +34,6 @@ 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()
@@ -113,14 +112,13 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
// HandleItemFullPath godoc
//
// @Summary (Deprecated) Get the full path of an item
// @Summary 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())
@@ -156,15 +154,13 @@ func (ctrl *V1Controller) HandleItemFullPath() errchain.HandlerFunc {
// HandleItemsCreate godoc
//
// @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
// @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
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)
@@ -175,14 +171,13 @@ func (ctrl *V1Controller) HandleItemsCreate() errchain.HandlerFunc {
// HandleItemGet godocs
//
// @Summary (Deprecated) Get Item
// @Summary 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())
@@ -195,14 +190,13 @@ func (ctrl *V1Controller) HandleItemGet() errchain.HandlerFunc {
// HandleItemDelete godocs
//
// @Summary (Deprecated) Delete Item
// @Summary 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())
@@ -215,7 +209,7 @@ func (ctrl *V1Controller) HandleItemDelete() errchain.HandlerFunc {
// HandleItemUpdate godocs
//
// @Summary (Deprecated) Update Item
// @Summary Update Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
@@ -223,7 +217,6 @@ 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())
@@ -237,7 +230,7 @@ func (ctrl *V1Controller) HandleItemUpdate() errchain.HandlerFunc {
// HandleItemPatch godocs
//
// @Summary (Deprecated) Update Item
// @Summary Update Item
// @Tags Items
// @Produce json
// @Param id path string true "Item ID"
@@ -245,7 +238,6 @@ 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())
@@ -283,14 +275,13 @@ func (ctrl *V1Controller) HandleItemDuplicate() errchain.HandlerFunc {
// HandleGetAllCustomFieldNames godocs
//
// @Summary (Deprecated) Get All Custom Field Names
// @Summary 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())
@@ -302,14 +293,13 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldNames() errchain.HandlerFunc {
// HandleGetAllCustomFieldValues godocs
//
// @Summary (Deprecated) Get All Custom Field Values
// @Summary 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"`
@@ -325,15 +315,14 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldValues() errchain.HandlerFunc {
// HandleItemsImport godocs
//
// @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
// @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
func (ctrl *V1Controller) HandleItemsImport() errchain.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)
@@ -362,12 +351,11 @@ func (ctrl *V1Controller) HandleItemsImport() errchain.HandlerFunc {
// HandleItemsExport godocs
//
// @Summary (Deprecated) Export Items
// @Summary 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,7 +45,6 @@ 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)
@@ -131,7 +130,6 @@ 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
}
@@ -145,7 +143,6 @@ 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
}
@@ -156,11 +153,10 @@ 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.EntityAttachmentUpdate true "Attachment Update"
// @Param payload body repo.ItemAttachmentUpdate 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
}
@@ -226,7 +222,7 @@ func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r
// Update Attachment Handler
case http.MethodPut:
var attachment repo.EntityAttachmentUpdate
var attachment repo.ItemAttachmentUpdate
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,14 +14,13 @@ import (
// HandleLocationTreeQuery godoc
//
// @Summary (Deprecated) Get Locations Tree
// @Summary 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())
@@ -33,14 +32,13 @@ func (ctrl *V1Controller) HandleLocationTreeQuery() errchain.HandlerFunc {
// HandleLocationGetAll godoc
//
// @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
// @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
func (ctrl *V1Controller) HandleLocationGetAll() errchain.HandlerFunc {
fn := func(r *http.Request, q repo.LocationQuery) ([]repo.LocationOutCount, error) {
auth := services.NewContext(r.Context())
@@ -52,14 +50,13 @@ func (ctrl *V1Controller) HandleLocationGetAll() errchain.HandlerFunc {
// HandleLocationCreate godoc
//
// @Summary (Deprecated) Create Location
// @Summary 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())
@@ -71,14 +68,13 @@ func (ctrl *V1Controller) HandleLocationCreate() errchain.HandlerFunc {
// HandleLocationDelete godoc
//
// @Summary (Deprecated) Delete Location
// @Summary 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())
@@ -133,14 +129,13 @@ func (ctrl *V1Controller) GetLocationWithPrice(auth context.Context, gid uuid.UU
// HandleLocationGet godoc
//
// @Summary (Deprecated) Get Location
// @Summary 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())
@@ -154,7 +149,7 @@ func (ctrl *V1Controller) HandleLocationGet() errchain.HandlerFunc {
// HandleLocationUpdate godoc
//
// @Summary (Deprecated) Update Location
// @Summary Update Location
// @Tags Locations
// @Produce json
// @Param id path string true "Location ID"
@@ -162,7 +157,6 @@ 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,26 +10,6 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
)
// HandleMaintenanceItemsLogGet 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/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
@@ -38,7 +18,7 @@ func (ctrl *V1Controller) HandleMaintenanceItemsLogGet() errchain.HandlerFunc {
// @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]
// @Router /v1/items/{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) {
@@ -49,7 +29,7 @@ func (ctrl *V1Controller) HandleMaintenanceLogGet() errchain.HandlerFunc {
return adapters.QueryID("id", fn, http.StatusOK)
}
// HandleMaintenanceItemsEntryCreate godoc
// HandleMaintenanceEntryCreate godoc
//
// @Summary Create Maintenance Entry
// @Tags Item Maintenance
@@ -59,26 +39,6 @@ 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,10 +1,9 @@
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

@@ -108,7 +108,7 @@ func run(cfg *config.Config) error {
return err
}
if strings.ToLower(cfg.Database.Driver) == "postgres" {
if strings.ToLower(cfg.Database.Driver) == config.DriverPostgres {
if !validatePostgresSSLMode(cfg.Database.SslMode) {
log.Error().Str("sslmode", cfg.Database.SslMode).Msg("invalid sslmode")
return fmt.Errorf("invalid sslmode: %s", cfg.Database.SslMode)

View File

@@ -109,7 +109,6 @@ 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...))
@@ -123,7 +122,6 @@ 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...))
@@ -131,7 +129,6 @@ 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...))
@@ -139,28 +136,12 @@ 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("/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("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceLogGet(), userMW...))
r.Post("/items/{id}/maintenance", chain.ToHandlerFunc(v1Ctrl.HandleMaintenanceEntryCreate(), userMW...))
r.Get("/assets/{id}", chain.ToHandlerFunc(v1Ctrl.HandleAssetGet(), userMW...))
@@ -184,9 +165,19 @@ 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...))
@@ -196,30 +187,6 @@ 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)
})

View File

@@ -41,7 +41,7 @@ func setupStorageDir(cfg *config.Config) error {
func setupDatabaseURL(cfg *config.Config) (string, error) {
databaseURL := ""
switch strings.ToLower(cfg.Database.Driver) {
case "sqlite3":
case config.DriverSqlite3:
databaseURL = cfg.Database.SqlitePath
dbFilePath := strings.Split(cfg.Database.SqlitePath, "?")[0]
dbDir := filepath.Dir(dbFilePath)
@@ -49,7 +49,7 @@ func setupDatabaseURL(cfg *config.Config) (string, error) {
log.Error().Err(err).Str("path", dbDir).Msg("failed to create SQLite database directory")
return "", fmt.Errorf("failed to create SQLite database directory: %w", err)
}
case "postgres":
case config.DriverPostgres:
databaseURL = fmt.Sprintf("host=%s port=%s dbname=%s sslmode=%s", cfg.Database.Host, cfg.Database.Port, cfg.Database.Database, cfg.Database.SslMode)
if cfg.Database.Username != "" {
databaseURL += fmt.Sprintf(" user=%s", cfg.Database.Username)

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

@@ -11,11 +11,11 @@ require (
github.com/coreos/go-oidc/v3 v3.17.0
github.com/evanoberholster/imagemeta v0.3.1
github.com/gen2brain/avif v0.4.4
github.com/gen2brain/heic v0.4.6
github.com/gen2brain/heic v0.4.7
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.29.0
github.com/go-playground/validator/v10 v10.30.1
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
@@ -44,7 +44,7 @@ require (
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
modernc.org/sqlite v1.41.0
)
require (
@@ -54,9 +54,9 @@ require (
cloud.google.com/go/auth v0.17.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/iam v1.5.2 // indirect
cloud.google.com/go/monitoring v1.24.2 // indirect
cloud.google.com/go/pubsub v1.50.0 // indirect
cloud.google.com/go/iam v1.5.3 // indirect
cloud.google.com/go/monitoring v1.24.3 // indirect
cloud.google.com/go/pubsub v1.50.1 // indirect
cloud.google.com/go/pubsub/v2 v2.2.1 // indirect
cloud.google.com/go/storage v1.56.0 // indirect
github.com/Azure/azure-amqp-common-go/v3 v3.2.3 // indirect
@@ -119,7 +119,7 @@ require (
github.com/go-openapi/inflect v0.19.0 // 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/spec v0.22.3 // 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
@@ -135,7 +135,7 @@ require (
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/wire v0.7.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.7 // indirect
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
github.com/googleapis/gax-go/v2 v2.16.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
@@ -153,12 +153,12 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/nats-io/nats.go v1.47.0 // indirect
github.com/nats-io/nats.go v1.48.0 // indirect
github.com/nats-io/nkeys v0.4.12 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pierrec/lz4/v4 v4.1.23 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
@@ -169,7 +169,7 @@ require (
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect
github.com/swaggo/files/v2 v2.0.2 // indirect
github.com/tetratelabs/wazero v1.10.1 // indirect
github.com/tetratelabs/wazero v1.11.0 // indirect
github.com/tinylib/msgp v1.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
@@ -188,7 +188,7 @@ require (
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-20251209150349-8475f28825e9 // indirect
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // 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
@@ -196,14 +196,14 @@ require (
golang.org/x/time v0.14.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-20251213004720-97cd9d5aeac2 // indirect
google.golang.org/grpc v1.77.0 // indirect
google.golang.org/api v0.258.0 // indirect
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/grpc v1.78.0 // 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/libc v1.67.2 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)

View File

@@ -10,22 +10,22 @@ cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIi
cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
cloud.google.com/go/iam v1.5.2 h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8=
cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE=
cloud.google.com/go/logging v1.13.0 h1:7j0HgAp0B94o1YRDqiqm26w4q1rDMH7XNRU34lJXHYc=
cloud.google.com/go/logging v1.13.0/go.mod h1:36CoKh6KA/M0PbhPKMq6/qety2DCAErbhXT62TuXALA=
cloud.google.com/go/longrunning v0.6.7 h1:IGtfDWHhQCgCjwQjV9iiLnUta9LBCo8R9QmAFsS/PrE=
cloud.google.com/go/longrunning v0.6.7/go.mod h1:EAFV3IZAKmM56TyiE6VAP3VoTzhZzySwI/YI1s/nRsY=
cloud.google.com/go/monitoring v1.24.2 h1:5OTsoJ1dXYIiMiuL+sYscLc9BumrL3CarVLL7dd7lHM=
cloud.google.com/go/monitoring v1.24.2/go.mod h1:x7yzPWcgDRnPEv3sI+jJGBkwl5qINf+6qY4eq0I9B4U=
cloud.google.com/go/pubsub v1.50.0 h1:hnYpOIxVlgVD1Z8LN7est4DQZK3K6tvZNurZjIVjUe0=
cloud.google.com/go/pubsub v1.50.0/go.mod h1:Di2Y+nqXBpIS+dXUEJPQzLh8PbIQZMLE9IVUFhf2zmM=
cloud.google.com/go/iam v1.5.3 h1:+vMINPiDF2ognBJ97ABAYYwRgsaqxPbQDlMnbHMjolc=
cloud.google.com/go/iam v1.5.3/go.mod h1:MR3v9oLkZCTlaqljW6Eb2d3HGDGK5/bDv93jhfISFvU=
cloud.google.com/go/logging v1.13.1 h1:O7LvmO0kGLaHY/gq8cV7T0dyp6zJhYAOtZPX4TF3QtY=
cloud.google.com/go/logging v1.13.1/go.mod h1:XAQkfkMBxQRjQek96WLPNze7vsOmay9H5PqfsNYDqvw=
cloud.google.com/go/longrunning v0.7.0 h1:FV0+SYF1RIj59gyoWDRi45GiYUMM3K1qO51qoboQT1E=
cloud.google.com/go/longrunning v0.7.0/go.mod h1:ySn2yXmjbK9Ba0zsQqunhDkYi0+9rlXIwnoAf+h+TPY=
cloud.google.com/go/monitoring v1.24.3 h1:dde+gMNc0UhPZD1Azu6at2e79bfdztVDS5lvhOdsgaE=
cloud.google.com/go/monitoring v1.24.3/go.mod h1:nYP6W0tm3N9H/bOw8am7t62YTzZY+zUeQ+Bi6+2eonI=
cloud.google.com/go/pubsub v1.50.1 h1:fzbXpPyJnSGvWXF1jabhQeXyxdbCIkXTpjXHy7xviBM=
cloud.google.com/go/pubsub v1.50.1/go.mod h1:6YVJv3MzWJUVdvQXG081sFvS0dWQOdnV+oTo++q/xFk=
cloud.google.com/go/pubsub/v2 v2.2.1 h1:3brZcshL3fIiD1qOxAE2QW9wxsfjioy014x4yC9XuYI=
cloud.google.com/go/pubsub/v2 v2.2.1/go.mod h1:O5f0KHG9zDheZAd3z5rlCRhxt2JQtB+t/IYLKK3Bpvw=
cloud.google.com/go/storage v1.56.0 h1:iixmq2Fse2tqxMbWhLWC9HfBj1qdxqAmiK8/eqtsLxI=
cloud.google.com/go/storage v1.56.0/go.mod h1:Tpuj6t4NweCLzlNbw9Z9iwxEkrSem20AetIeH/shgVU=
cloud.google.com/go/trace v1.11.6 h1:2O2zjPzqPYAHrn3OKl029qlqG6W8ZdYaOWRyr8NgMT4=
cloud.google.com/go/trace v1.11.6/go.mod h1:GA855OeDEBiBMzcckLPE2kDunIpC72N+Pq8WFieFjnI=
cloud.google.com/go/trace v1.11.7 h1:kDNDX8JkaAG3R2nq1lIdkb7FCSi1rCmsEtKVsty7p+U=
cloud.google.com/go/trace v1.11.7/go.mod h1:TNn9d5V3fQVf6s4SCveVMIBS2LJUqo73GACmq/Tky0s=
entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=
entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U=
github.com/Azure/azure-amqp-common-go/v3 v3.2.3 h1:uDF62mbd9bypXWi19V1bN5NZEO84JqgmI5G73ibAmrk=
@@ -79,8 +79,6 @@ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7l
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
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=
@@ -174,14 +172,12 @@ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzP
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
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=
github.com/gen2brain/heic v0.4.6/go.mod h1:ECnpqbqLu0qSje4KSNWUUDK47UPXPzl80T27GWGEL5I=
github.com/gen2brain/heic v0.4.7 h1:xw/e9R3HdIvb+uEhRDMRJdviYnB3ODe/VwL8SYLaMGc=
github.com/gen2brain/heic v0.4.7/go.mod h1:ECnpqbqLu0qSje4KSNWUUDK47UPXPzl80T27GWGEL5I=
github.com/gen2brain/jpegxl v0.4.5 h1:TWpVEn5xkIfsswzkjHBArd0Cc9AE0tbjBSoa0jDsrbo=
github.com/gen2brain/jpegxl v0.4.5/go.mod h1:4kWYJ18xCEuO2vzocYdGpeqNJ990/Gjy3uLMg5TBN6I=
github.com/gen2brain/webp v0.5.5 h1:MvQR75yIPU/9nSqYT5h13k4URaJK3gf9tgz/ksRbyEg=
@@ -199,18 +195,12 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
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/spec v0.22.3 h1:qRSmj6Smz2rEBxMnLRBMeBWxbbOvuOoElvSvObIgwQc=
github.com/go-openapi/spec v0.22.3/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=
@@ -238,10 +228,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
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-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
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=
@@ -279,8 +267,8 @@ github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4=
github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18=
github.com/googleapis/enterprise-certificate-proxy v0.3.7 h1:zrn2Ee/nWmHulBx5sAVrGgAa0f2/R35S4DJwfFaUPFQ=
github.com/googleapis/enterprise-certificate-proxy v0.3.7/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=
github.com/googleapis/gax-go/v2 v2.15.0 h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81vgd/bo=
github.com/googleapis/gax-go/v2 v2.15.0/go.mod h1:zVVkkxAQHa1RQpg9z2AUCMnKhi0Qld9rcmyfL1OZhoc=
github.com/googleapis/gax-go/v2 v2.16.0 h1:iHbQmKLLZrexmb0OSsNGTeSTS0HO4YvFOG8g5E4Zd0Y=
github.com/googleapis/gax-go/v2 v2.16.0/go.mod h1:o1vfQjjNZn4+dPnRdl/4ZD7S9414Y4xA+a/6Icj6l14=
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
@@ -337,8 +325,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
@@ -351,8 +337,8 @@ github.com/nats-io/jwt/v2 v2.5.0 h1:WQQ40AAlqqfx+f6ku+i0pOVm+ASirD4fUh+oQsiE9Ak=
github.com/nats-io/jwt/v2 v2.5.0/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI=
github.com/nats-io/nats-server/v2 v2.9.23 h1:6Wj6H6QpP9FMlpCyWUaNu2yeZ/qGj+mdRkZ1wbikExU=
github.com/nats-io/nats-server/v2 v2.9.23/go.mod h1:wEjrEy9vnqIGE4Pqz4/c75v9Pmaq7My2IgFmnykc4C0=
github.com/nats-io/nats.go v1.47.0 h1:YQdADw6J/UfGUd2Oy6tn4Hq6YHxCaJrVKayxxFqYrgM=
github.com/nats-io/nats.go v1.47.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g=
github.com/nats-io/nats.go v1.48.0 h1:pSFyXApG+yWU/TgbKCjmm5K4wrHu86231/w84qRVR+U=
github.com/nats-io/nats.go v1.48.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g=
github.com/nats-io/nkeys v0.4.12 h1:nssm7JKOG9/x4J8II47VWCL1Ds29avyiQDRn0ckMvDc=
github.com/nats-io/nkeys v0.4.12/go.mod h1:MT59A1HYcjIcyQDJStTfaOY6vhy9XTUjOFo+SVsvpBg=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
@@ -361,16 +347,14 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI=
github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.23 h1:oJE7T90aYBGtFNrI8+KbETnPymobAhzRrR8Mu8n1yfU=
github.com/pierrec/lz4/v4 v4.1.23/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -405,10 +389,6 @@ github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAX
github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=
github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -428,8 +408,8 @@ github.com/swaggo/http-swagger/v2 v2.0.2 h1:FKCdLsl+sFCx60KFsyM0rDarwiUSZ8DqbfSy
github.com/swaggo/http-swagger/v2 v2.0.2/go.mod h1:r7/GBkAWIfK6E/OLnE8fXnviHiDeAHmgIyooa4xm3AQ=
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
github.com/tetratelabs/wazero v1.10.1 h1:2DugeJf6VVk58KTPszlNfeeN8AhhpwcZqkJj2wwFuH8=
github.com/tetratelabs/wazero v1.10.1/go.mod h1:DRm5twOQ5Gr1AoEdSi0CLjDQF1J9ZAuyqFIjl1KKfQU=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY=
github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
@@ -465,26 +445,16 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.6
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0/go.mod h1:ru6KHrNtNHxM4nD/vd6QrLVWgKhxPYgblq4VAtNawTQ=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU=
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=
@@ -505,21 +475,13 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
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/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
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=
@@ -529,18 +491,12 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
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=
@@ -556,8 +512,6 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.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=
@@ -567,8 +521,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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=
@@ -576,8 +528,6 @@ 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=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
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=
@@ -586,20 +536,16 @@ golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhS
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/api v0.257.0 h1:8Y0lzvHlZps53PEaw+G29SsQIkuKrumGWs9puiexNAA=
google.golang.org/api v0.257.0/go.mod h1:4eJrr+vbVaZSqs7vovFd1Jb/A6ml6iw2e6FBYf3GAO4=
google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 h1:Nt6z9UHqSlIdIGJdz6KhTIs2VRx/iOsA5iE8bmQNcxs=
google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79/go.mod h1:kTmlBHMPqR5uCZPBvwa2B18mvubkjyY3CRLI0c6fj0s=
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 h1:mepRgnBZa07I4TRuomDE4sTIYieg/osKmzIf4USdWS4=
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/api v0.258.0 h1:IKo1j5FBlN74fe5isA2PVozN3Y5pwNKriEgAXPOkDAc=
google.golang.org/api v0.258.0/go.mod h1:qhOMTQEZ6lUps63ZNq9jhODswwjkjYYguA7fA3TBFww=
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 h1:GvESR9BIyHUahIb0NcTum6itIWtdoglGX+rnGxm2934=
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:yJ2HH4EHEDTd3JiLmhds6NkJ17ITVYOdV3m3VKOnws0=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc=
google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U=
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=
@@ -621,8 +567,8 @@ modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=
modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.67.1 h1:bFaqOaa5/zbWYJo8aW0tXPX21hXsngG2M7mckCnFSVk=
modernc.org/libc v1.67.1/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA=
modernc.org/libc v1.67.2 h1:ZbNmly1rcbjhot5jlOZG0q4p5VwFfjwWqZ5rY2xxOXo=
modernc.org/libc v1.67.2/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
@@ -631,8 +577,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY=
modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=
modernc.org/sqlite v1.41.0 h1:bJXddp4ZpsqMsNN1vS0jWo4IJTZzb8nWpcgvyCFG9Ck=
modernc.org/sqlite v1.41.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=

View File

@@ -2,12 +2,11 @@ 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,13 +2,12 @@ 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) {
@@ -20,7 +19,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.EntityAttachmentUpdate) (repo.ItemOut, error) {
func (svc *ItemService) AttachmentUpdate(ctx Context, gid uuid.UUID, itemID uuid.UUID, data *repo.ItemAttachmentUpdate) (repo.ItemOut, error) {
// Update Attachment
attachment, err := svc.repo.Attachments.Update(ctx, gid, data.ID, data)
if err != nil {
@@ -48,7 +47,7 @@ func (svc *ItemService) AttachmentAdd(ctx Context, itemID uuid.UUID, filename st
}
// Create the attachment
_, err = svc.repo.Attachments.Create(ctx, itemID, repo.EntityCreateAttachment{Title: filename, Content: file}, attachmentType, primary)
_, err = svc.repo.Attachments.Create(ctx, itemID, repo.ItemCreateAttachment{Title: filename, Content: file}, attachmentType, primary)
if err != nil {
log.Err(err).Msg("failed to create attachment")
return repo.ItemOut{}, err

View File

@@ -105,12 +105,6 @@ 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
)
// 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
entity_attachments *uuid.UUID
item_attachments *uuid.UUID
selectValues sql.SelectValues
}
// AttachmentEdges holds the relations/edges for other nodes in the graph.
type AttachmentEdges struct {
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// Item holds the value of the item edge.
Item *Item `json:"item,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
}
// EntityOrErr returns the Entity value or an error if the edge
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AttachmentEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
func (e AttachmentEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: entity.Label}
return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "entity"}
return nil, &NotLoadedError{edge: "item"}
}
// 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]: // entity_attachments
case attachment.ForeignKeys[1]: // item_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 entity_attachments", values[i])
return fmt.Errorf("unexpected type %T for field item_attachments", values[i])
} else if value.Valid {
_m.entity_attachments = new(uuid.UUID)
*_m.entity_attachments = *value.S.(*uuid.UUID)
_m.item_attachments = new(uuid.UUID)
*_m.item_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)
}
// QueryEntity queries the "entity" edge of the Attachment entity.
func (_m *Attachment) QueryEntity() *EntityQuery {
return NewAttachmentClient(_m.config).QueryEntity(_m)
// QueryItem queries the "item" edge of the Attachment entity.
func (_m *Attachment) QueryItem() *ItemQuery {
return NewAttachmentClient(_m.config).QueryItem(_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"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// EdgeItem holds the string denoting the item edge name in mutations.
EdgeItem = "item"
// 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"
// 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"
// 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"
// 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",
"entity_attachments",
"item_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()
}
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newItemStep(), 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 newEntityStep() *sqlgraph.Step {
func newItemStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
}
func newThumbnailStep() *sqlgraph.Step {

View File

@@ -391,21 +391,21 @@ func MimeTypeContainsFold(v string) predicate.Attachment {
return predicate.Attachment(sql.FieldContainsFold(FieldMimeType, v))
}
// HasEntity applies the HasEdge predicate on the "entity" edge.
func HasEntity() predicate.Attachment {
// HasItem applies the HasEdge predicate on the "item" edge.
func HasItem() predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
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.Attachment {
// HasItemWith applies the HasEdge predicate on the "item" edge with a given conditions (other predicates).
func HasItemWith(preds ...predicate.Item) predicate.Attachment {
return predicate.Attachment(func(s *sql.Selector) {
step := newEntityStep()
step := newItemStep()
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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
)
// AttachmentCreate is the builder for creating a Attachment entity.
@@ -134,23 +134,23 @@ func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate {
return _c
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_c *AttachmentCreate) SetItemID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetItemID(id)
return _c
}
// 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 {
// 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 {
if id != nil {
_c = _c.SetEntityID(*id)
_c = _c.SetItemID(*id)
}
return _c
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate {
return _c.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_c *AttachmentCreate) SetItem(v *Item) *AttachmentCreate {
return _c.SetItemID(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.EntityIDs(); len(nodes) > 0 {
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.entity_attachments = &nodes[0]
_node.item_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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -24,7 +24,7 @@ type AttachmentQuery struct {
order []attachment.OrderOption
inters []Interceptor
predicates []predicate.Attachment
withEntity *EntityQuery
withItem *ItemQuery
withThumbnail *AttachmentQuery
withFKs bool
// intermediate query (i.e. traversal path).
@@ -63,9 +63,9 @@ func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery {
return _q
}
// QueryEntity chains the current query on the "entity" edge.
func (_q *AttachmentQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
// QueryItem chains the current query on the "item" edge.
func (_q *AttachmentQuery) QueryItem() *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
@@ -76,8 +76,8 @@ func (_q *AttachmentQuery) QueryEntity() *EntityQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(attachment.Table, attachment.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn),
)
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...),
withEntity: _q.withEntity.Clone(),
withItem: _q.withItem.Clone(),
withThumbnail: _q.withThumbnail.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
@@ -307,14 +307,14 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery {
}
}
// 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()
// 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()
for _, opt := range opts {
opt(query)
}
_q.withEntity = query
_q.withItem = 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.withEntity != nil,
_q.withItem != nil,
_q.withThumbnail != nil,
}
)
if _q.withEntity != nil || _q.withThumbnail != nil {
if _q.withItem != 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.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != 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 {
return nil, err
}
}
@@ -452,14 +452,14 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
return nodes, nil
}
func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error {
func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Item)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*Attachment)
for i := range nodes {
if nodes[i].entity_attachments == nil {
if nodes[i].item_attachments == nil {
continue
}
fk := *nodes[i].entity_attachments
fk := *nodes[i].item_attachments
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -468,7 +468,7 @@ func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, n
if len(ids) == 0 {
return nil
}
query.Where(entity.IDIn(ids...))
query.Where(item.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -476,7 +476,7 @@ func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, n
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "entity_attachments" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "item_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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -106,23 +106,23 @@ func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate {
return _u
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdate) SetItemID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetItemID(id)
return _u
}
// 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 {
// 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 {
if id != nil {
_u = _u.SetEntityID(*id)
_u = _u.SetItemID(*id)
}
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdate) SetItem(v *Item) *AttachmentUpdate {
return _u.SetItemID(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
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdate) ClearItem() *AttachmentUpdate {
_u.mutation.ClearItem()
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.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -391,23 +391,23 @@ func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateO
return _u
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdateOne) SetItemID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetItemID(id)
return _u
}
// 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 {
// 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 {
if id != nil {
_u = _u.SetEntityID(*id)
_u = _u.SetItemID(*id)
}
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) SetItem(v *Item) *AttachmentUpdateOne {
return _u.SetItemID(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
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) ClearItem() *AttachmentUpdateOne {
_u.mutation.ClearItem()
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.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.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,

File diff suppressed because it is too large Load Diff

View File

@@ -1,550 +0,0 @@
// 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

@@ -1,533 +0,0 @@
// 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

@@ -1,691 +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/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

@@ -1,755 +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/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"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,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"`
// 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,19 +62,28 @@ func (e GroupEdges) UsersOrErr() ([]*User, error) {
return nil, &NotLoadedError{edge: "users"}
}
// EntitiesOrErr returns the Entities value or an error if the edge
// LocationsOrErr returns the Locations value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) {
func (e GroupEdges) LocationsOrErr() ([]*Location, error) {
if e.loadedTypes[1] {
return e.Entities, nil
return e.Locations, nil
}
return nil, &NotLoadedError{edge: "entities"}
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"}
}
// 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[2] {
if e.loadedTypes[3] {
return e.Labels, nil
}
return nil, &NotLoadedError{edge: "labels"}
@@ -83,7 +92,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[3] {
if e.loadedTypes[4] {
return e.InvitationTokens, nil
}
return nil, &NotLoadedError{edge: "invitation_tokens"}
@@ -92,21 +101,12 @@ 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[4] {
if e.loadedTypes[5] {
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,9 +190,14 @@ func (_m *Group) QueryUsers() *UserQuery {
return NewGroupClient(_m.config).QueryUsers(_m)
}
// QueryEntities queries the "entities" edge of the Group entity.
func (_m *Group) QueryEntities() *EntityQuery {
return NewGroupClient(_m.config).QueryEntities(_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)
}
// QueryLabels queries the "labels" edge of the Group entity.
@@ -210,11 +215,6 @@ 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"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// 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"
// 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,13 +46,20 @@ const (
UsersInverseTable = "users"
// UsersColumn is the table column denoting the users relation/edge.
UsersColumn = "group_users"
// 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"
// 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"
// LabelsTable is the table that holds the labels relation/edge.
LabelsTable = "labels"
// LabelsInverseTable is the table name for the Label entity.
@@ -74,13 +81,6 @@ 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,17 +166,31 @@ func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
// ByLocationsCount orders the results by locations count.
func ByLocationsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
sqlgraph.OrderByNeighborsCount(s, newLocationsStep(), opts...)
}
}
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByLocations orders the results by locations terms.
func ByLocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
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...)...)
}
}
@@ -222,20 +236,6 @@ 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,11 +256,18 @@ func newUsersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
)
}
func newEntitiesStep() *sqlgraph.Step {
func newLocationsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
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),
)
}
func newLabelsStep() *sqlgraph.Step {
@@ -284,13 +291,6 @@ 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,21 +309,44 @@ func HasUsersWith(preds ...predicate.User) predicate.Group {
})
}
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.Group {
// HasLocations applies the HasEdge predicate on the "locations" edge.
func HasLocations() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
)
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.Group {
// HasLocationsWith applies the HasEdge predicate on the "locations" edge with a given conditions (other predicates).
func HasLocationsWith(preds ...predicate.Location) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newEntitiesStep()
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()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
@@ -401,29 +424,6 @@ 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,19 +105,34 @@ func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate {
return _c.AddUserIDs(ids...)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddEntityIDs(ids...)
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_c *GroupCreate) AddLocationIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddLocationIDs(ids...)
return _c
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate {
// AddLocations adds the "locations" edges to the Location entity.
func (_c *GroupCreate) AddLocations(v ...*Location) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddEntityIDs(ids...)
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...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -165,21 +180,6 @@ 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,15 +334,31 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
if nodes := _c.mutation.LocationsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
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),
},
}
for _, k := range nodes {
@@ -398,22 +414,6 @@ 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
withEntities *EntityQuery
withLocations *LocationQuery
withItems *ItemQuery
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
}
// QueryEntities chains the current query on the "entities" edge.
func (_q *GroupQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
// QueryLocations chains the current query on the "locations" edge.
func (_q *GroupQuery) QueryLocations() *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
@@ -109,8 +109,30 @@ func (_q *GroupQuery) QueryEntities() *EntityQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
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),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -184,28 +206,6 @@ 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(),
withEntities: _q.withEntities.Clone(),
withLocations: _q.withLocations.Clone(),
withItems: _q.withItems.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,14 +444,25 @@ func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
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 *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery {
query := (&EntityClient{config: _q.config}).Query()
// 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()
for _, opt := range opts {
opt(query)
}
_q.withEntities = 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
return _q
}
@@ -488,17 +499,6 @@ 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.withEntities != nil,
_q.withLocations != nil,
_q.withItems != nil,
_q.withLabels != nil,
_q.withInvitationTokens != nil,
_q.withNotifiers != nil,
_q.withEntityTypes != nil,
_q.withItemTemplates != nil,
}
)
@@ -623,10 +623,17 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
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 {
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 {
return nil, err
}
}
@@ -653,13 +660,6 @@ 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) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error {
func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, nodes []*Group, init func(*Group), assign func(*Group, *Location)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
@@ -712,21 +712,52 @@ func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, node
}
}
query.withFKs = true
query.Where(predicate.Entity(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.EntitiesColumn), fks...))
query.Where(predicate.Location(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.LocationsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_entities
fk := n.group_locations
if fk == nil {
return fmt.Errorf(`foreign-key "group_entities" is nil for node %v`, n.ID)
return fmt.Errorf(`foreign-key "group_locations" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_entities" returned %v for node %v`, *fk, n.ID)
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)
}
assign(node, n)
}
@@ -824,37 +855,6 @@ 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,19 +85,34 @@ func (_u *GroupUpdate) AddUsers(v ...*User) *GroupUpdate {
return _u.AddUserIDs(ids...)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdate) AddEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddEntityIDs(ids...)
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdate) AddLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddLocationIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdate) AddEntities(v ...*Entity) *GroupUpdate {
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdate) AddLocations(v ...*Location) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
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...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -145,21 +160,6 @@ 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,25 +201,46 @@ func (_u *GroupUpdate) RemoveUsers(v ...*User) *GroupUpdate {
return _u.RemoveUserIDs(ids...)
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdate) ClearEntities() *GroupUpdate {
_u.mutation.ClearEntities()
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdate) ClearLocations() *GroupUpdate {
_u.mutation.ClearLocations()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdate) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveEntityIDs(ids...)
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdate) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveLocationIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdate) RemoveEntities(v ...*Entity) *GroupUpdate {
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdate) RemoveLocations(v ...*Location) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
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...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -285,27 +306,6 @@ 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.EntitiesCleared() {
if _u.mutation.LocationsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -468,15 +468,60 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
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),
},
}
for _, k := range nodes {
@@ -619,51 +664,6 @@ 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,19 +778,34 @@ func (_u *GroupUpdateOne) AddUsers(v ...*User) *GroupUpdateOne {
return _u.AddUserIDs(ids...)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdateOne) AddEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddEntityIDs(ids...)
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdateOne) AddLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddLocationIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) AddEntities(v ...*Entity) *GroupUpdateOne {
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdateOne) AddLocations(v ...*Location) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
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...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -838,21 +853,6 @@ 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,25 +894,46 @@ func (_u *GroupUpdateOne) RemoveUsers(v ...*User) *GroupUpdateOne {
return _u.RemoveUserIDs(ids...)
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) ClearEntities() *GroupUpdateOne {
_u.mutation.ClearEntities()
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdateOne) ClearLocations() *GroupUpdateOne {
_u.mutation.ClearLocations()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdateOne) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveLocationIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdateOne) RemoveEntities(v ...*Entity) *GroupUpdateOne {
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdateOne) RemoveLocations(v ...*Location) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
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...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -978,27 +999,6 @@ 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.EntitiesCleared() {
if _u.mutation.LocationsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -1191,15 +1191,60 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
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),
},
}
for _, k := range nodes {
@@ -1342,51 +1387,6 @@ 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,18 +16,6 @@ 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
}
@@ -36,6 +24,14 @@ 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
}
@@ -44,6 +40,10 @@ 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,42 +45,6 @@ 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)
@@ -105,6 +69,30 @@ 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)
@@ -129,6 +117,18 @@ 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)

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"
)
// Entity is the model entity for the Entity schema.
type Entity struct {
// Item is the model entity for the Item schema.
type Item struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -40,8 +40,8 @@ type Entity struct {
Archived bool `json:"archived,omitempty"`
// AssetID holds the value of the "asset_id" field.
AssetID int `json:"asset_id,omitempty"`
// SyncChildEntitiesLocations holds the value of the "sync_child_entities_locations" field.
SyncChildEntitiesLocations bool `json:"sync_child_entities_locations,omitempty"`
// SyncChildItemsLocations holds the value of the "sync_child_items_locations" field.
SyncChildItemsLocations bool `json:"sync_child_items_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,45 +69,40 @@ type Entity 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 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
// 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
}
// EntityEdges holds the relations/edges for other nodes in the graph.
type EntityEdges struct {
// ItemEdges holds the relations/edges for other nodes in the graph.
type ItemEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Children holds the value of the children edge.
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"`
Parent *Item `json:"parent,omitempty"`
// Children holds the value of the children edge.
Children []*Item `json:"children,omitempty"`
// Label holds the value of the label edge.
Label []*Label `json:"label,omitempty"`
// Type holds the value of the type edge.
Type *EntityType `json:"type,omitempty"`
// Location holds the value of the location edge.
Location *Location `json:"location,omitempty"`
// Fields holds the value of the fields edge.
Fields []*EntityField `json:"fields,omitempty"`
Fields []*ItemField `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 [10]bool
loadedTypes [8]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 EntityEdges) GroupOrErr() (*Group, error) {
func (e ItemEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[0] {
@@ -116,70 +111,50 @@ func (e EntityEdges) 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 EntityEdges) ChildrenOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
func (e ItemEdges) ChildrenOrErr() ([]*Item, error) {
if e.loadedTypes[2] {
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 EntityEdges) LabelOrErr() ([]*Label, error) {
if e.loadedTypes[5] {
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
if e.loadedTypes[3] {
return e.Label, nil
}
return nil, &NotLoadedError{edge: "label"}
}
// TypeOrErr returns the Type value or an error if the edge
// 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) TypeOrErr() (*EntityType, error) {
if e.Type != nil {
return e.Type, nil
} else if e.loadedTypes[6] {
return nil, &NotFoundError{label: entitytype.Label}
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}
}
return nil, &NotLoadedError{edge: "type"}
return nil, &NotLoadedError{edge: "location"}
}
// FieldsOrErr returns the Fields value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) FieldsOrErr() ([]*EntityField, error) {
if e.loadedTypes[7] {
func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) {
if e.loadedTypes[5] {
return e.Fields, nil
}
return nil, &NotLoadedError{edge: "fields"}
@@ -187,8 +162,8 @@ func (e EntityEdges) FieldsOrErr() ([]*EntityField, error) {
// MaintenanceEntriesOrErr returns the MaintenanceEntries value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
if e.loadedTypes[8] {
func (e ItemEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
if e.loadedTypes[6] {
return e.MaintenanceEntries, nil
}
return nil, &NotLoadedError{edge: "maintenance_entries"}
@@ -196,37 +171,35 @@ func (e EntityEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
// AttachmentsOrErr returns the Attachments value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) AttachmentsOrErr() ([]*Attachment, error) {
if e.loadedTypes[9] {
func (e ItemEdges) AttachmentsOrErr() ([]*Attachment, error) {
if e.loadedTypes[7] {
return e.Attachments, nil
}
return nil, &NotLoadedError{edge: "attachments"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Entity) scanValues(columns []string) ([]any, error) {
func (*Item) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case entity.FieldInsured, entity.FieldArchived, entity.FieldSyncChildEntitiesLocations, entity.FieldLifetimeWarranty:
case item.FieldInsured, item.FieldArchived, item.FieldSyncChildItemsLocations, item.FieldLifetimeWarranty:
values[i] = new(sql.NullBool)
case entity.FieldPurchasePrice, entity.FieldSoldPrice:
case item.FieldPurchasePrice, item.FieldSoldPrice:
values[i] = new(sql.NullFloat64)
case entity.FieldQuantity, entity.FieldAssetID:
case item.FieldQuantity, item.FieldAssetID:
values[i] = new(sql.NullInt64)
case entity.FieldName, entity.FieldDescription, entity.FieldImportRef, entity.FieldNotes, entity.FieldSerialNumber, entity.FieldModelNumber, entity.FieldManufacturer, entity.FieldWarrantyDetails, entity.FieldPurchaseFrom, entity.FieldSoldTo, entity.FieldSoldNotes:
case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes:
values[i] = new(sql.NullString)
case entity.FieldCreatedAt, entity.FieldUpdatedAt, entity.FieldWarrantyExpires, entity.FieldPurchaseTime, entity.FieldSoldTime:
case item.FieldCreatedAt, item.FieldUpdatedAt, item.FieldWarrantyExpires, item.FieldPurchaseTime, item.FieldSoldTime:
values[i] = new(sql.NullTime)
case entity.FieldID:
case item.FieldID:
values[i] = new(uuid.UUID)
case entity.ForeignKeys[0]: // entity_parent
case item.ForeignKeys[0]: // group_items
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case entity.ForeignKeys[1]: // entity_location
case item.ForeignKeys[1]: // item_children
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case entity.ForeignKeys[2]: // entity_type_entities
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case entity.ForeignKeys[3]: // group_entities
case item.ForeignKeys[2]: // location_items
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -236,190 +209,183 @@ func (*Entity) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Entity fields.
func (_m *Entity) assignValues(columns []string, values []any) error {
// to the Item fields.
func (_m *Item) 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 entity.FieldID:
case item.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 entity.FieldCreatedAt:
case item.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 entity.FieldUpdatedAt:
case item.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 entity.FieldName:
case item.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 entity.FieldDescription:
case item.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 entity.FieldImportRef:
case item.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 entity.FieldNotes:
case item.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 entity.FieldQuantity:
case item.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 entity.FieldInsured:
case item.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 entity.FieldArchived:
case item.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 entity.FieldAssetID:
case item.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 entity.FieldSyncChildEntitiesLocations:
case item.FieldSyncChildItemsLocations:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field sync_child_entities_locations", values[i])
return fmt.Errorf("unexpected type %T for field sync_child_items_locations", values[i])
} else if value.Valid {
_m.SyncChildEntitiesLocations = value.Bool
_m.SyncChildItemsLocations = value.Bool
}
case entity.FieldSerialNumber:
case item.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 entity.FieldModelNumber:
case item.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 entity.FieldManufacturer:
case item.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 entity.FieldLifetimeWarranty:
case item.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 entity.FieldWarrantyExpires:
case item.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 entity.FieldWarrantyDetails:
case item.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 entity.FieldPurchaseTime:
case item.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 entity.FieldPurchaseFrom:
case item.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 entity.FieldPurchasePrice:
case item.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 entity.FieldSoldTime:
case item.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 entity.FieldSoldTo:
case item.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 entity.FieldSoldPrice:
case item.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 entity.FieldSoldNotes:
case item.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 entity.ForeignKeys[0]:
case item.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field entity_parent", values[i])
return fmt.Errorf("unexpected type %T for field group_items", values[i])
} else if value.Valid {
_m.entity_parent = new(uuid.UUID)
*_m.entity_parent = *value.S.(*uuid.UUID)
_m.group_items = new(uuid.UUID)
*_m.group_items = *value.S.(*uuid.UUID)
}
case entity.ForeignKeys[1]:
case item.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field entity_location", values[i])
return fmt.Errorf("unexpected type %T for field item_children", values[i])
} else if value.Valid {
_m.entity_location = new(uuid.UUID)
*_m.entity_location = *value.S.(*uuid.UUID)
_m.item_children = new(uuid.UUID)
*_m.item_children = *value.S.(*uuid.UUID)
}
case entity.ForeignKeys[2]:
case item.ForeignKeys[2]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field entity_type_entities", values[i])
return fmt.Errorf("unexpected type %T for field location_items", values[i])
} else if value.Valid {
_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)
_m.location_items = new(uuid.UUID)
*_m.location_items = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -428,84 +394,74 @@ func (_m *Entity) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Entity.
// Value returns the ent.Value that was dynamically selected and assigned to the Item.
// This includes values selected through modifiers, order, etc.
func (_m *Entity) Value(name string) (ent.Value, error) {
func (_m *Item) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroup queries the "group" edge of the Entity entity.
func (_m *Entity) QueryGroup() *GroupQuery {
return NewEntityClient(_m.config).QueryGroup(_m)
// QueryGroup queries the "group" edge of the Item entity.
func (_m *Item) QueryGroup() *GroupQuery {
return NewItemClient(_m.config).QueryGroup(_m)
}
// QueryChildren queries the "children" edge of the Entity entity.
func (_m *Entity) QueryChildren() *EntityQuery {
return NewEntityClient(_m.config).QueryChildren(_m)
// QueryParent queries the "parent" edge of the Item entity.
func (_m *Item) QueryParent() *ItemQuery {
return NewItemClient(_m.config).QueryParent(_m)
}
// QueryParent queries the "parent" edge of the Entity entity.
func (_m *Entity) QueryParent() *EntityQuery {
return NewEntityClient(_m.config).QueryParent(_m)
// QueryChildren queries the "children" edge of the Item entity.
func (_m *Item) QueryChildren() *ItemQuery {
return NewItemClient(_m.config).QueryChildren(_m)
}
// QueryEntity queries the "entity" edge of the Entity entity.
func (_m *Entity) QueryEntity() *EntityQuery {
return NewEntityClient(_m.config).QueryEntity(_m)
// QueryLabel queries the "label" edge of the Item entity.
func (_m *Item) QueryLabel() *LabelQuery {
return NewItemClient(_m.config).QueryLabel(_m)
}
// QueryLocation queries the "location" edge of the Entity entity.
func (_m *Entity) QueryLocation() *EntityQuery {
return NewEntityClient(_m.config).QueryLocation(_m)
// QueryLocation queries the "location" edge of the Item entity.
func (_m *Item) QueryLocation() *LocationQuery {
return NewItemClient(_m.config).QueryLocation(_m)
}
// QueryLabel queries the "label" edge of the Entity entity.
func (_m *Entity) QueryLabel() *LabelQuery {
return NewEntityClient(_m.config).QueryLabel(_m)
// QueryFields queries the "fields" edge of the Item entity.
func (_m *Item) QueryFields() *ItemFieldQuery {
return NewItemClient(_m.config).QueryFields(_m)
}
// QueryType queries the "type" edge of the Entity entity.
func (_m *Entity) QueryType() *EntityTypeQuery {
return NewEntityClient(_m.config).QueryType(_m)
// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Item entity.
func (_m *Item) QueryMaintenanceEntries() *MaintenanceEntryQuery {
return NewItemClient(_m.config).QueryMaintenanceEntries(_m)
}
// QueryFields queries the "fields" edge of the Entity entity.
func (_m *Entity) QueryFields() *EntityFieldQuery {
return NewEntityClient(_m.config).QueryFields(_m)
// QueryAttachments queries the "attachments" edge of the Item entity.
func (_m *Item) QueryAttachments() *AttachmentQuery {
return NewItemClient(_m.config).QueryAttachments(_m)
}
// 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
// Update returns a builder for updating this Item.
// Note that you need to call Item.Unwrap() before calling this method if this Item
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Entity) Update() *EntityUpdateOne {
return NewEntityClient(_m.config).UpdateOne(_m)
func (_m *Item) Update() *ItemUpdateOne {
return NewItemClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Entity entity that was returned from a transaction after it was closed,
// Unwrap unwraps the Item 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 *Entity) Unwrap() *Entity {
func (_m *Item) Unwrap() *Item {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Entity is not a transactional entity")
panic("ent: Item is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Entity) String() string {
func (_m *Item) String() string {
var builder strings.Builder
builder.WriteString("Entity(")
builder.WriteString("Item(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -537,8 +493,8 @@ func (_m *Entity) String() string {
builder.WriteString("asset_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AssetID))
builder.WriteString(", ")
builder.WriteString("sync_child_entities_locations=")
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildEntitiesLocations))
builder.WriteString("sync_child_items_locations=")
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildItemsLocations))
builder.WriteString(", ")
builder.WriteString("serial_number=")
builder.WriteString(_m.SerialNumber)
@@ -582,5 +538,5 @@ func (_m *Entity) String() string {
return builder.String()
}
// Entities is a parsable slice of Entity.
type Entities []*Entity
// Items is a parsable slice of Item.
type Items []*Item

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package entity
package item
import (
"time"
@@ -11,8 +11,8 @@ import (
)
const (
// Label holds the string label denoting the entity type in the database.
Label = "entity"
// Label holds the string label denoting the item type in the database.
Label = "item"
// 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"
// FieldSyncChildEntitiesLocations holds the string denoting the sync_child_entities_locations field in the database.
FieldSyncChildEntitiesLocations = "sync_child_entities_locations"
// FieldSyncChildItemsLocations holds the string denoting the sync_child_items_locations field in the database.
FieldSyncChildItemsLocations = "sync_child_items_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,85 +65,73 @@ const (
FieldSoldNotes = "sold_notes"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// 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"
// 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"
// EdgeType holds the string denoting the type edge name in mutations.
EdgeType = "type"
// EdgeLocation holds the string denoting the location edge name in mutations.
EdgeLocation = "location"
// 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 entity in the database.
Table = "entities"
// Table holds the table name of the item in the database.
Table = "items"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "entities"
GroupTable = "items"
// 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_entities"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "entities"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "entity_parent"
GroupColumn = "group_items"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "entities"
ParentTable = "items"
// 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"
ParentColumn = "item_children"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "items"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "item_children"
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
LabelTable = "label_entities"
LabelTable = "label_items"
// 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"
// 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"
// 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"
// FieldsTable is the table that holds the fields relation/edge.
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"
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"
// FieldsColumn is the table column denoting the fields relation/edge.
FieldsColumn = "entity_fields"
FieldsColumn = "item_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 = "entity_id"
MaintenanceEntriesColumn = "item_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 = "entity_attachments"
AttachmentsColumn = "item_attachments"
)
// Columns holds all SQL columns for entity fields.
// Columns holds all SQL columns for item fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
@@ -156,7 +144,7 @@ var Columns = []string{
FieldInsured,
FieldArchived,
FieldAssetID,
FieldSyncChildEntitiesLocations,
FieldSyncChildItemsLocations,
FieldSerialNumber,
FieldModelNumber,
FieldManufacturer,
@@ -172,19 +160,18 @@ var Columns = []string{
FieldSoldNotes,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "entities"
// ForeignKeys holds the SQL foreign-keys that are owned by the "items"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"entity_parent",
"entity_location",
"entity_type_entities",
"group_entities",
"group_items",
"item_children",
"location_items",
}
var (
// LabelPrimaryKey and LabelColumn2 are the table columns denoting the
// primary key for the label relation (M2M).
LabelPrimaryKey = []string{"label_id", "entity_id"}
LabelPrimaryKey = []string{"label_id", "item_id"}
)
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -225,8 +212,8 @@ var (
DefaultArchived bool
// DefaultAssetID holds the default value on creation for the "asset_id" field.
DefaultAssetID int
// DefaultSyncChildEntitiesLocations holds the default value on creation for the "sync_child_entities_locations" field.
DefaultSyncChildEntitiesLocations bool
// DefaultSyncChildItemsLocations holds the default value on creation for the "sync_child_items_locations" field.
DefaultSyncChildItemsLocations 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.
@@ -247,7 +234,7 @@ var (
DefaultID func() uuid.UUID
)
// OrderOption defines the ordering options for the Entity queries.
// OrderOption defines the ordering options for the Item queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
@@ -305,9 +292,9 @@ func ByAssetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAssetID, 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()
// BySyncChildItemsLocations orders the results by the sync_child_items_locations field.
func BySyncChildItemsLocations(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSyncChildItemsLocations, opts...).ToFunc()
}
// BySerialNumber orders the results by the serial_number field.
@@ -382,6 +369,13 @@ 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) {
@@ -396,34 +390,6 @@ 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) {
@@ -438,10 +404,10 @@ func ByLabel(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByTypeField orders the results by type field.
func ByTypeField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByLocationField orders the results by location field.
func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTypeStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
}
}
@@ -493,32 +459,18 @@ func newGroupStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newChildrenStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
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),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newEntityStep() *sqlgraph.Step {
func newChildrenStep() *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),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
)
}
func newLabelStep() *sqlgraph.Step {
@@ -528,11 +480,11 @@ func newLabelStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
)
}
func newTypeStep() *sqlgraph.Step {
func newLocationStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TypeInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, TypeTable, TypeColumn),
sqlgraph.To(LocationInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, LocationTable, LocationColumn),
)
}
func newFieldsStep() *sqlgraph.Step {

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

View File

@@ -2,29 +2,30 @@ package ent
import (
"entgo.io/ent/dialect/sql"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
conf "github.com/sysadminsmedia/homebox/backend/internal/sys/config"
"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.Entity {
func AccentInsensitiveContains(field string, searchValue string) predicate.Item {
if searchValue == "" {
return func(s *sql.Selector) {
return predicate.Item(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 func(s *sql.Selector) {
return predicate.Item(func(s *sql.Selector) {
dialect := s.Dialect()
switch dialect {
case "sqlite3":
case conf.DriverSqlite3:
// For SQLite, we'll create a custom normalization function using REPLACE
// to handle common accented characters
normalizeFunc := buildSQLiteNormalizeExpression(s.C(field))
@@ -32,7 +33,7 @@ func AccentInsensitiveContains(field string, searchValue string) predicate.Entit
"LOWER("+normalizeFunc+") LIKE ?",
"%"+normalizedSearch+"%",
))
case "postgres":
case conf.DriverPostgres:
// For PostgreSQL, use REPLACE-based normalization to avoid unaccent dependency
normalizeFunc := buildGenericNormalizeExpression(s.C(field))
// Use sql.P() for proper PostgreSQL parameter binding ($1, $2, etc.)
@@ -50,7 +51,7 @@ func AccentInsensitiveContains(field string, searchValue string) predicate.Entit
"%"+normalizedSearch+"%",
))
}
}
})
}
// buildSQLiteNormalizeExpression creates a SQLite expression to normalize accented characters
@@ -90,31 +91,31 @@ func buildGenericNormalizeExpression(fieldExpr string) string {
}
// ItemNameAccentInsensitiveContains creates an accent-insensitive search predicate for the item name field.
func ItemNameAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldName, value)
func ItemNameAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldName, value)
}
// ItemDescriptionAccentInsensitiveContains creates an accent-insensitive search predicate for the item description field.
func ItemDescriptionAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldDescription, value)
func ItemDescriptionAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldDescription, value)
}
// ItemSerialNumberAccentInsensitiveContains creates an accent-insensitive search predicate for the item serial number field.
func ItemSerialNumberAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldSerialNumber, value)
func ItemSerialNumberAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldSerialNumber, value)
}
// ItemModelNumberAccentInsensitiveContains creates an accent-insensitive search predicate for the item model number field.
func ItemModelNumberAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldModelNumber, value)
func ItemModelNumberAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldModelNumber, value)
}
// ItemManufacturerAccentInsensitiveContains creates an accent-insensitive search predicate for the item manufacturer field.
func ItemManufacturerAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldManufacturer, value)
func ItemManufacturerAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.FieldManufacturer, value)
}
// ItemNotesAccentInsensitiveContains creates an accent-insensitive search predicate for the item notes field.
func ItemNotesAccentInsensitiveContains(value string) predicate.Entity {
return AccentInsensitiveContains(entity.FieldNotes, value)
func ItemNotesAccentInsensitiveContains(value string) predicate.Item {
return AccentInsensitiveContains(item.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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
)
// EntityField is the model entity for the EntityField schema.
type EntityField struct {
// ItemField is the model entity for the ItemField schema.
type ItemField struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -28,7 +28,7 @@ type EntityField struct {
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Type holds the value of the "type" field.
Type entityfield.Type `json:"type,omitempty"`
Type itemfield.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 EntityField 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 EntityFieldQuery when eager-loading is set.
Edges EntityFieldEdges `json:"edges"`
entity_fields *uuid.UUID
selectValues sql.SelectValues
// The values are being populated by the ItemFieldQuery when eager-loading is set.
Edges ItemFieldEdges `json:"edges"`
item_fields *uuid.UUID
selectValues sql.SelectValues
}
// 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"`
// 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"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// EntityOrErr returns the Entity value or an error if the edge
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityFieldEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
func (e ItemFieldEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: entity.Label}
return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "entity"}
return nil, &NotLoadedError{edge: "item"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*EntityField) scanValues(columns []string) ([]any, error) {
func (*ItemField) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case entityfield.FieldBooleanValue:
case itemfield.FieldBooleanValue:
values[i] = new(sql.NullBool)
case entityfield.FieldNumberValue:
case itemfield.FieldNumberValue:
values[i] = new(sql.NullInt64)
case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue:
case itemfield.FieldName, itemfield.FieldDescription, itemfield.FieldType, itemfield.FieldTextValue:
values[i] = new(sql.NullString)
case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue:
case itemfield.FieldCreatedAt, itemfield.FieldUpdatedAt, itemfield.FieldTimeValue:
values[i] = new(sql.NullTime)
case entityfield.FieldID:
case itemfield.FieldID:
values[i] = new(uuid.UUID)
case entityfield.ForeignKeys[0]: // entity_fields
case itemfield.ForeignKeys[0]: // item_fields
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -89,79 +89,79 @@ func (*EntityField) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the EntityField fields.
func (_m *EntityField) assignValues(columns []string, values []any) error {
// to the ItemField fields.
func (_m *ItemField) 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 entityfield.FieldID:
case itemfield.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 entityfield.FieldCreatedAt:
case itemfield.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 entityfield.FieldUpdatedAt:
case itemfield.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 entityfield.FieldName:
case itemfield.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 entityfield.FieldDescription:
case itemfield.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 entityfield.FieldType:
case itemfield.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 = entityfield.Type(value.String)
_m.Type = itemfield.Type(value.String)
}
case entityfield.FieldTextValue:
case itemfield.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 entityfield.FieldNumberValue:
case itemfield.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 entityfield.FieldBooleanValue:
case itemfield.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 entityfield.FieldTimeValue:
case itemfield.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 entityfield.ForeignKeys[0]:
case itemfield.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field entity_fields", values[i])
return fmt.Errorf("unexpected type %T for field item_fields", values[i])
} else if value.Valid {
_m.entity_fields = new(uuid.UUID)
*_m.entity_fields = *value.S.(*uuid.UUID)
_m.item_fields = new(uuid.UUID)
*_m.item_fields = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -170,39 +170,39 @@ func (_m *EntityField) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the EntityField.
// Value returns the ent.Value that was dynamically selected and assigned to the ItemField.
// This includes values selected through modifiers, order, etc.
func (_m *EntityField) Value(name string) (ent.Value, error) {
func (_m *ItemField) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryEntity queries the "entity" edge of the EntityField entity.
func (_m *EntityField) QueryEntity() *EntityQuery {
return NewEntityFieldClient(_m.config).QueryEntity(_m)
// QueryItem queries the "item" edge of the ItemField entity.
func (_m *ItemField) QueryItem() *ItemQuery {
return NewItemFieldClient(_m.config).QueryItem(_m)
}
// Update returns a builder for updating this EntityField.
// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField
// Update returns a builder for updating this ItemField.
// Note that you need to call ItemField.Unwrap() before calling this method if this ItemField
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *EntityField) Update() *EntityFieldUpdateOne {
return NewEntityFieldClient(_m.config).UpdateOne(_m)
func (_m *ItemField) Update() *ItemFieldUpdateOne {
return NewItemFieldClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the EntityField entity that was returned from a transaction after it was closed,
// Unwrap unwraps the ItemField 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 *EntityField) Unwrap() *EntityField {
func (_m *ItemField) Unwrap() *ItemField {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: EntityField is not a transactional entity")
panic("ent: ItemField is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *EntityField) String() string {
func (_m *ItemField) String() string {
var builder strings.Builder
builder.WriteString("EntityField(")
builder.WriteString("ItemField(")
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 *EntityField) String() string {
return builder.String()
}
// EntityFields is a parsable slice of EntityField.
type EntityFields []*EntityField
// ItemFields is a parsable slice of ItemField.
type ItemFields []*ItemField

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package entityfield
package itemfield
import (
"fmt"
@@ -12,8 +12,8 @@ import (
)
const (
// Label holds the string label denoting the entityfield type in the database.
Label = "entity_field"
// Label holds the string label denoting the itemfield type in the database.
Label = "item_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"
// 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"
// 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"
)
// Columns holds all SQL columns for entityfield fields.
// Columns holds all SQL columns for itemfield 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 "entity_fields"
// ForeignKeys holds the SQL foreign-keys that are owned by the "item_fields"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"entity_fields",
"item_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("entityfield: invalid enum value for type field: %q", _type)
return fmt.Errorf("itemfield: invalid enum value for type field: %q", _type)
}
}
// OrderOption defines the ordering options for the EntityField queries.
// OrderOption defines the ordering options for the ItemField 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()
}
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
}
}
func newEntityStep() *sqlgraph.Step {
func newItemStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
}

View File

@@ -0,0 +1,550 @@
// 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,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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
)
// EntityFieldCreate is the builder for creating a EntityField entity.
type EntityFieldCreate struct {
// ItemFieldCreate is the builder for creating a ItemField entity.
type ItemFieldCreate struct {
config
mutation *EntityFieldMutation
mutation *ItemFieldMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (_c *EntityFieldCreate) SetCreatedAt(v time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetCreatedAt(v time.Time) *ItemFieldCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableCreatedAt(v *time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableCreatedAt(v *time.Time) *ItemFieldCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
@@ -37,13 +37,13 @@ func (_c *EntityFieldCreate) SetNillableCreatedAt(v *time.Time) *EntityFieldCrea
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *EntityFieldCreate) SetUpdatedAt(v time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetUpdatedAt(v time.Time) *ItemFieldCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableUpdatedAt(v *time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableUpdatedAt(v *time.Time) *ItemFieldCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
@@ -51,19 +51,19 @@ func (_c *EntityFieldCreate) SetNillableUpdatedAt(v *time.Time) *EntityFieldCrea
}
// SetName sets the "name" field.
func (_c *EntityFieldCreate) SetName(v string) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetName(v string) *ItemFieldCreate {
_c.mutation.SetName(v)
return _c
}
// SetDescription sets the "description" field.
func (_c *EntityFieldCreate) SetDescription(v string) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetDescription(v string) *ItemFieldCreate {
_c.mutation.SetDescription(v)
return _c
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableDescription(v *string) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableDescription(v *string) *ItemFieldCreate {
if v != nil {
_c.SetDescription(*v)
}
@@ -71,19 +71,19 @@ func (_c *EntityFieldCreate) SetNillableDescription(v *string) *EntityFieldCreat
}
// SetType sets the "type" field.
func (_c *EntityFieldCreate) SetType(v entityfield.Type) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetType(v itemfield.Type) *ItemFieldCreate {
_c.mutation.SetType(v)
return _c
}
// SetTextValue sets the "text_value" field.
func (_c *EntityFieldCreate) SetTextValue(v string) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetTextValue(v string) *ItemFieldCreate {
_c.mutation.SetTextValue(v)
return _c
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableTextValue(v *string) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableTextValue(v *string) *ItemFieldCreate {
if v != nil {
_c.SetTextValue(*v)
}
@@ -91,13 +91,13 @@ func (_c *EntityFieldCreate) SetNillableTextValue(v *string) *EntityFieldCreate
}
// SetNumberValue sets the "number_value" field.
func (_c *EntityFieldCreate) SetNumberValue(v int) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNumberValue(v int) *ItemFieldCreate {
_c.mutation.SetNumberValue(v)
return _c
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableNumberValue(v *int) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableNumberValue(v *int) *ItemFieldCreate {
if v != nil {
_c.SetNumberValue(*v)
}
@@ -105,13 +105,13 @@ func (_c *EntityFieldCreate) SetNillableNumberValue(v *int) *EntityFieldCreate {
}
// SetBooleanValue sets the "boolean_value" field.
func (_c *EntityFieldCreate) SetBooleanValue(v bool) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetBooleanValue(v bool) *ItemFieldCreate {
_c.mutation.SetBooleanValue(v)
return _c
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableBooleanValue(v *bool) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableBooleanValue(v *bool) *ItemFieldCreate {
if v != nil {
_c.SetBooleanValue(*v)
}
@@ -119,13 +119,13 @@ func (_c *EntityFieldCreate) SetNillableBooleanValue(v *bool) *EntityFieldCreate
}
// SetTimeValue sets the "time_value" field.
func (_c *EntityFieldCreate) SetTimeValue(v time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetTimeValue(v time.Time) *ItemFieldCreate {
_c.mutation.SetTimeValue(v)
return _c
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableTimeValue(v *time.Time) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableTimeValue(v *time.Time) *ItemFieldCreate {
if v != nil {
_c.SetTimeValue(*v)
}
@@ -133,51 +133,51 @@ func (_c *EntityFieldCreate) SetNillableTimeValue(v *time.Time) *EntityFieldCrea
}
// SetID sets the "id" field.
func (_c *EntityFieldCreate) SetID(v uuid.UUID) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetID(v uuid.UUID) *ItemFieldCreate {
_c.mutation.SetID(v)
return _c
}
// SetNillableID sets the "id" field if the given value is not nil.
func (_c *EntityFieldCreate) SetNillableID(v *uuid.UUID) *EntityFieldCreate {
func (_c *ItemFieldCreate) SetNillableID(v *uuid.UUID) *ItemFieldCreate {
if v != nil {
_c.SetID(*v)
}
return _c
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_c *EntityFieldCreate) SetEntityID(id uuid.UUID) *EntityFieldCreate {
_c.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_c *ItemFieldCreate) SetItemID(id uuid.UUID) *ItemFieldCreate {
_c.mutation.SetItemID(id)
return _c
}
// 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 {
// 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 {
if id != nil {
_c = _c.SetEntityID(*id)
_c = _c.SetItemID(*id)
}
return _c
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *EntityFieldCreate) SetEntity(v *Entity) *EntityFieldCreate {
return _c.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_c *ItemFieldCreate) SetItem(v *Item) *ItemFieldCreate {
return _c.SetItemID(v.ID)
}
// Mutation returns the EntityFieldMutation object of the builder.
func (_c *EntityFieldCreate) Mutation() *EntityFieldMutation {
// Mutation returns the ItemFieldMutation object of the builder.
func (_c *ItemFieldCreate) Mutation() *ItemFieldMutation {
return _c.mutation
}
// Save creates the EntityField in the database.
func (_c *EntityFieldCreate) Save(ctx context.Context) (*EntityField, error) {
// Save creates the ItemField in the database.
func (_c *ItemFieldCreate) Save(ctx context.Context) (*ItemField, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
func (_c *ItemFieldCreate) SaveX(ctx context.Context) *ItemField {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -186,86 +186,86 @@ func (_c *EntityFieldCreate) SaveX(ctx context.Context) *EntityField {
}
// Exec executes the query.
func (_c *EntityFieldCreate) Exec(ctx context.Context) error {
func (_c *ItemFieldCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *EntityFieldCreate) ExecX(ctx context.Context) {
func (_c *ItemFieldCreate) 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 *EntityFieldCreate) defaults() {
func (_c *ItemFieldCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := entityfield.DefaultCreatedAt()
v := itemfield.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := entityfield.DefaultUpdatedAt()
v := itemfield.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.BooleanValue(); !ok {
v := entityfield.DefaultBooleanValue
v := itemfield.DefaultBooleanValue
_c.mutation.SetBooleanValue(v)
}
if _, ok := _c.mutation.TimeValue(); !ok {
v := entityfield.DefaultTimeValue()
v := itemfield.DefaultTimeValue()
_c.mutation.SetTimeValue(v)
}
if _, ok := _c.mutation.ID(); !ok {
v := entityfield.DefaultID()
v := itemfield.DefaultID()
_c.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *EntityFieldCreate) check() error {
func (_c *ItemFieldCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityField.created_at"`)}
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ItemField.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityField.updated_at"`)}
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ItemField.updated_at"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityField.name"`)}
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ItemField.name"`)}
}
if v, ok := _c.mutation.Name(); ok {
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
}
}
if v, ok := _c.mutation.Description(); ok {
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
}
}
if _, ok := _c.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "EntityField.type"`)}
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "ItemField.type"`)}
}
if v, ok := _c.mutation.GetType(); ok {
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
}
}
if v, ok := _c.mutation.TextValue(); ok {
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 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 _, ok := _c.mutation.BooleanValue(); !ok {
return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "EntityField.boolean_value"`)}
return &ValidationError{Name: "boolean_value", err: errors.New(`ent: missing required field "ItemField.boolean_value"`)}
}
if _, ok := _c.mutation.TimeValue(); !ok {
return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "EntityField.time_value"`)}
return &ValidationError{Name: "time_value", err: errors.New(`ent: missing required field "ItemField.time_value"`)}
}
return nil
}
func (_c *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error) {
func (_c *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
if err := _c.check(); err != nil {
return nil, err
}
@@ -288,92 +288,92 @@ func (_c *EntityFieldCreate) sqlSave(ctx context.Context) (*EntityField, error)
return _node, nil
}
func (_c *EntityFieldCreate) createSpec() (*EntityField, *sqlgraph.CreateSpec) {
func (_c *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) {
var (
_node = &EntityField{config: _c.config}
_spec = sqlgraph.NewCreateSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
_node = &ItemField{config: _c.config}
_spec = sqlgraph.NewCreateSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.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(entityfield.FieldCreatedAt, field.TypeTime, value)
_spec.SetField(itemfield.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(entityfield.FieldName, field.TypeString, value)
_spec.SetField(itemfield.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Description(); ok {
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
_node.Description = value
}
if value, ok := _c.mutation.GetType(); ok {
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
_node.Type = value
}
if value, ok := _c.mutation.TextValue(); ok {
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
_node.TextValue = value
}
if value, ok := _c.mutation.NumberValue(); ok {
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
_node.NumberValue = value
}
if value, ok := _c.mutation.BooleanValue(); ok {
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
_node.BooleanValue = value
}
if value, ok := _c.mutation.TimeValue(); ok {
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
_node.TimeValue = value
}
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.entity_fields = &nodes[0]
_node.item_fields = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// EntityFieldCreateBulk is the builder for creating many EntityField entities in bulk.
type EntityFieldCreateBulk struct {
// ItemFieldCreateBulk is the builder for creating many ItemField entities in bulk.
type ItemFieldCreateBulk struct {
config
err error
builders []*EntityFieldCreate
builders []*ItemFieldCreate
}
// Save creates the EntityField entities in the database.
func (_c *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, error) {
// Save creates the ItemField entities in the database.
func (_c *ItemFieldCreateBulk) Save(ctx context.Context) ([]*ItemField, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*EntityField, len(_c.builders))
nodes := make([]*ItemField, 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.(*EntityFieldMutation)
mutation, ok := m.(*ItemFieldMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
@@ -416,7 +416,7 @@ func (_c *EntityFieldCreateBulk) Save(ctx context.Context) ([]*EntityField, erro
}
// SaveX is like Save, but panics if an error occurs.
func (_c *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
func (_c *ItemFieldCreateBulk) SaveX(ctx context.Context) []*ItemField {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -425,13 +425,13 @@ func (_c *EntityFieldCreateBulk) SaveX(ctx context.Context) []*EntityField {
}
// Exec executes the query.
func (_c *EntityFieldCreateBulk) Exec(ctx context.Context) error {
func (_c *ItemFieldCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *EntityFieldCreateBulk) ExecX(ctx context.Context) {
func (_c *ItemFieldCreateBulk) 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/entityfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// EntityFieldDelete is the builder for deleting a EntityField entity.
type EntityFieldDelete struct {
// ItemFieldDelete is the builder for deleting a ItemField entity.
type ItemFieldDelete struct {
config
hooks []Hook
mutation *EntityFieldMutation
mutation *ItemFieldMutation
}
// Where appends a list predicates to the EntityFieldDelete builder.
func (_d *EntityFieldDelete) Where(ps ...predicate.EntityField) *EntityFieldDelete {
// Where appends a list predicates to the ItemFieldDelete builder.
func (_d *ItemFieldDelete) Where(ps ...predicate.ItemField) *ItemFieldDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *EntityFieldDelete) Exec(ctx context.Context) (int, error) {
func (_d *ItemFieldDelete) 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 *EntityFieldDelete) ExecX(ctx context.Context) int {
func (_d *ItemFieldDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
@@ -39,8 +39,8 @@ func (_d *EntityFieldDelete) ExecX(ctx context.Context) int {
return n
}
func (_d *EntityFieldDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(entityfield.Table, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
func (_d *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.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 *EntityFieldDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err
}
// EntityFieldDeleteOne is the builder for deleting a single EntityField entity.
type EntityFieldDeleteOne struct {
_d *EntityFieldDelete
// ItemFieldDeleteOne is the builder for deleting a single ItemField entity.
type ItemFieldDeleteOne struct {
_d *ItemFieldDelete
}
// Where appends a list predicates to the EntityFieldDelete builder.
func (_d *EntityFieldDeleteOne) Where(ps ...predicate.EntityField) *EntityFieldDeleteOne {
// Where appends a list predicates to the ItemFieldDelete builder.
func (_d *ItemFieldDeleteOne) Where(ps ...predicate.ItemField) *ItemFieldDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *EntityFieldDeleteOne) Exec(ctx context.Context) error {
func (_d *ItemFieldDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{entityfield.Label}
return &NotFoundError{itemfield.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *EntityFieldDeleteOne) ExecX(ctx context.Context) {
func (_d *ItemFieldDeleteOne) 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"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/predicate"
)
// EntityFieldQuery is the builder for querying EntityField entities.
type EntityFieldQuery struct {
// ItemFieldQuery is the builder for querying ItemField entities.
type ItemFieldQuery struct {
config
ctx *QueryContext
order []entityfield.OrderOption
order []itemfield.OrderOption
inters []Interceptor
predicates []predicate.EntityField
withEntity *EntityQuery
predicates []predicate.ItemField
withItem *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 EntityFieldQuery builder.
func (_q *EntityFieldQuery) Where(ps ...predicate.EntityField) *EntityFieldQuery {
// Where adds a new predicate for the ItemFieldQuery builder.
func (_q *ItemFieldQuery) Where(ps ...predicate.ItemField) *ItemFieldQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *EntityFieldQuery) Limit(limit int) *EntityFieldQuery {
func (_q *ItemFieldQuery) Limit(limit int) *ItemFieldQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *EntityFieldQuery) Offset(offset int) *EntityFieldQuery {
func (_q *ItemFieldQuery) Offset(offset int) *ItemFieldQuery {
_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 *EntityFieldQuery) Unique(unique bool) *EntityFieldQuery {
func (_q *ItemFieldQuery) Unique(unique bool) *ItemFieldQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *EntityFieldQuery) Order(o ...entityfield.OrderOption) *EntityFieldQuery {
func (_q *ItemFieldQuery) Order(o ...itemfield.OrderOption) *ItemFieldQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryEntity chains the current query on the "entity" edge.
func (_q *EntityFieldQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
// QueryItem chains the current query on the "item" edge.
func (_q *ItemFieldQuery) QueryItem() *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
@@ -74,9 +74,9 @@ func (_q *EntityFieldQuery) QueryEntity() *EntityQuery {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(entityfield.Table, entityfield.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, entityfield.EntityTable, entityfield.EntityColumn),
sqlgraph.From(itemfield.Table, itemfield.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, itemfield.ItemTable, itemfield.ItemColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -84,21 +84,21 @@ func (_q *EntityFieldQuery) QueryEntity() *EntityQuery {
return query
}
// 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) {
// 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) {
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{entityfield.Label}
return nil, &NotFoundError{itemfield.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
func (_q *ItemFieldQuery) FirstX(ctx context.Context) *ItemField {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
@@ -106,22 +106,22 @@ func (_q *EntityFieldQuery) FirstX(ctx context.Context) *EntityField {
return node
}
// 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) {
// 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) {
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{entityfield.Label}
err = &NotFoundError{itemfield.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
func (_q *ItemFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
@@ -129,10 +129,10 @@ func (_q *EntityFieldQuery) FirstIDX(ctx context.Context) uuid.UUID {
return id
}
// 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) {
// 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) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
@@ -141,14 +141,14 @@ func (_q *EntityFieldQuery) Only(ctx context.Context) (*EntityField, error) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{entityfield.Label}
return nil, &NotFoundError{itemfield.Label}
default:
return nil, &NotSingularError{entityfield.Label}
return nil, &NotSingularError{itemfield.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
func (_q *ItemFieldQuery) OnlyX(ctx context.Context) *ItemField {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
@@ -156,10 +156,10 @@ func (_q *EntityFieldQuery) OnlyX(ctx context.Context) *EntityField {
return node
}
// OnlyID is like Only, but returns the only EntityField ID in the query.
// Returns a *NotSingularError when more than one EntityField ID is found.
// OnlyID is like Only, but returns the only ItemField ID in the query.
// Returns a *NotSingularError when more than one ItemField ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
func (_q *ItemFieldQuery) 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 *EntityFieldQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error
case 1:
id = ids[0]
case 0:
err = &NotFoundError{entityfield.Label}
err = &NotFoundError{itemfield.Label}
default:
err = &NotSingularError{entityfield.Label}
err = &NotSingularError{itemfield.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
func (_q *ItemFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
@@ -184,18 +184,18 @@ func (_q *EntityFieldQuery) OnlyIDX(ctx context.Context) uuid.UUID {
return id
}
// All executes the query and returns a list of EntityFields.
func (_q *EntityFieldQuery) All(ctx context.Context) ([]*EntityField, error) {
// All executes the query and returns a list of ItemFields.
func (_q *ItemFieldQuery) All(ctx context.Context) ([]*ItemField, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*EntityField, *EntityFieldQuery]()
return withInterceptors[[]*EntityField](ctx, _q, qr, _q.inters)
qr := querierAll[[]*ItemField, *ItemFieldQuery]()
return withInterceptors[[]*ItemField](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
func (_q *ItemFieldQuery) AllX(ctx context.Context) []*ItemField {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
@@ -203,20 +203,20 @@ func (_q *EntityFieldQuery) AllX(ctx context.Context) []*EntityField {
return nodes
}
// IDs executes the query and returns a list of EntityField IDs.
func (_q *EntityFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
// IDs executes the query and returns a list of ItemField IDs.
func (_q *ItemFieldQuery) 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(entityfield.FieldID).Scan(ctx, &ids); err != nil {
if err = _q.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
func (_q *ItemFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
@@ -225,16 +225,16 @@ func (_q *EntityFieldQuery) IDsX(ctx context.Context) []uuid.UUID {
}
// Count returns the count of the given query.
func (_q *EntityFieldQuery) Count(ctx context.Context) (int, error) {
func (_q *ItemFieldQuery) 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[*EntityFieldQuery](), _q.inters)
return withInterceptors[int](ctx, _q, querierCount[*ItemFieldQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *EntityFieldQuery) CountX(ctx context.Context) int {
func (_q *ItemFieldQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
@@ -243,7 +243,7 @@ func (_q *EntityFieldQuery) CountX(ctx context.Context) int {
}
// Exist returns true if the query has elements in the graph.
func (_q *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
func (_q *ItemFieldQuery) 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 *EntityFieldQuery) Exist(ctx context.Context) (bool, error) {
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *EntityFieldQuery) ExistX(ctx context.Context) bool {
func (_q *ItemFieldQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
@@ -264,33 +264,33 @@ func (_q *EntityFieldQuery) ExistX(ctx context.Context) bool {
return exist
}
// Clone returns a duplicate of the EntityFieldQuery builder, including all associated steps. It can be
// Clone returns a duplicate of the ItemFieldQuery 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 *EntityFieldQuery) Clone() *EntityFieldQuery {
func (_q *ItemFieldQuery) Clone() *ItemFieldQuery {
if _q == nil {
return nil
}
return &EntityFieldQuery{
return &ItemFieldQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]entityfield.OrderOption{}, _q.order...),
order: append([]itemfield.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.EntityField{}, _q.predicates...),
withEntity: _q.withEntity.Clone(),
predicates: append([]predicate.ItemField{}, _q.predicates...),
withItem: _q.withItem.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// 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()
// 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()
for _, opt := range opts {
opt(query)
}
_q.withEntity = query
_q.withItem = query
return _q
}
@@ -304,15 +304,15 @@ func (_q *EntityFieldQuery) WithEntity(opts ...func(*EntityQuery)) *EntityFieldQ
// Count int `json:"count,omitempty"`
// }
//
// client.EntityField.Query().
// GroupBy(entityfield.FieldCreatedAt).
// client.ItemField.Query().
// GroupBy(itemfield.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityFieldGroupBy {
func (_q *ItemFieldQuery) GroupBy(field string, fields ...string) *ItemFieldGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &EntityFieldGroupBy{build: _q}
grbuild := &ItemFieldGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = entityfield.Label
grbuild.label = itemfield.Label
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -326,23 +326,23 @@ func (_q *EntityFieldQuery) GroupBy(field string, fields ...string) *EntityField
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.EntityField.Query().
// Select(entityfield.FieldCreatedAt).
// client.ItemField.Query().
// Select(itemfield.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *EntityFieldQuery) Select(fields ...string) *EntityFieldSelect {
func (_q *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &EntityFieldSelect{EntityFieldQuery: _q}
sbuild.label = entityfield.Label
sbuild := &ItemFieldSelect{ItemFieldQuery: _q}
sbuild.label = itemfield.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a EntityFieldSelect configured with the given aggregations.
func (_q *EntityFieldQuery) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
// Aggregate returns a ItemFieldSelect configured with the given aggregations.
func (_q *ItemFieldQuery) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *EntityFieldQuery) prepareQuery(ctx context.Context) error {
func (_q *ItemFieldQuery) 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 *EntityFieldQuery) prepareQuery(ctx context.Context) error {
}
}
for _, f := range _q.ctx.Fields {
if !entityfield.ValidColumn(f) {
if !itemfield.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
@@ -368,26 +368,26 @@ func (_q *EntityFieldQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (_q *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EntityField, error) {
func (_q *ItemFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ItemField, error) {
var (
nodes = []*EntityField{}
nodes = []*ItemField{}
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withEntity != nil,
_q.withItem != nil,
}
)
if _q.withEntity != nil {
if _q.withItem != nil {
withFKs = true
}
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, entityfield.ForeignKeys...)
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*EntityField).scanValues(nil, columns)
return (*ItemField).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &EntityField{config: _q.config}
node := &ItemField{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
@@ -401,23 +401,23 @@ func (_q *EntityFieldQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
if len(nodes) == 0 {
return nodes, 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 {
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 {
return nil, err
}
}
return nodes, nil
}
func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*EntityField, init func(*EntityField), assign func(*EntityField, *Entity)) error {
func (_q *ItemFieldQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*ItemField, init func(*ItemField), assign func(*ItemField, *Item)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*EntityField)
nodeids := make(map[uuid.UUID][]*ItemField)
for i := range nodes {
if nodes[i].entity_fields == nil {
if nodes[i].item_fields == nil {
continue
}
fk := *nodes[i].entity_fields
fk := *nodes[i].item_fields
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -426,7 +426,7 @@ func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery,
if len(ids) == 0 {
return nil
}
query.Where(entity.IDIn(ids...))
query.Where(item.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -434,7 +434,7 @@ func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery,
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "entity_fields" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "item_fields" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
@@ -443,7 +443,7 @@ func (_q *EntityFieldQuery) loadEntity(ctx context.Context, query *EntityQuery,
return nil
}
func (_q *EntityFieldQuery) sqlCount(ctx context.Context) (int, error) {
func (_q *ItemFieldQuery) 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 *EntityFieldQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
func (_q *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
@@ -462,9 +462,9 @@ func (_q *EntityFieldQuery) 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, entityfield.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID)
for i := range fields {
if fields[i] != entityfield.FieldID {
if fields[i] != itemfield.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
@@ -492,12 +492,12 @@ func (_q *EntityFieldQuery) querySpec() *sqlgraph.QuerySpec {
return _spec
}
func (_q *EntityFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
func (_q *ItemFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(entityfield.Table)
t1 := builder.Table(itemfield.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = entityfield.Columns
columns = itemfield.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
@@ -524,28 +524,28 @@ func (_q *EntityFieldQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector
}
// EntityFieldGroupBy is the group-by builder for EntityField entities.
type EntityFieldGroupBy struct {
// ItemFieldGroupBy is the group-by builder for ItemField entities.
type ItemFieldGroupBy struct {
selector
build *EntityFieldQuery
build *ItemFieldQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *EntityFieldGroupBy) Aggregate(fns ...AggregateFunc) *EntityFieldGroupBy {
func (_g *ItemFieldGroupBy) Aggregate(fns ...AggregateFunc) *ItemFieldGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *EntityFieldGroupBy) Scan(ctx context.Context, v any) error {
func (_g *ItemFieldGroupBy) 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[*EntityFieldQuery, *EntityFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
return scanWithInterceptors[*ItemFieldQuery, *ItemFieldGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *EntityFieldGroupBy) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
func (_g *ItemFieldGroupBy) sqlScan(ctx context.Context, root *ItemFieldQuery, 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 *EntityFieldGroupBy) sqlScan(ctx context.Context, root *EntityFieldQuer
return sql.ScanSlice(rows, v)
}
// EntityFieldSelect is the builder for selecting fields of EntityField entities.
type EntityFieldSelect struct {
*EntityFieldQuery
// ItemFieldSelect is the builder for selecting fields of ItemField entities.
type ItemFieldSelect struct {
*ItemFieldQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *EntityFieldSelect) Aggregate(fns ...AggregateFunc) *EntityFieldSelect {
func (_s *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *EntityFieldSelect) Scan(ctx context.Context, v any) error {
func (_s *ItemFieldSelect) 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[*EntityFieldQuery, *EntityFieldSelect](ctx, _s.EntityFieldQuery, _s, _s.inters, v)
return scanWithInterceptors[*ItemFieldQuery, *ItemFieldSelect](ctx, _s.ItemFieldQuery, _s, _s.inters, v)
}
func (_s *EntityFieldSelect) sqlScan(ctx context.Context, root *EntityFieldQuery, v any) error {
func (_s *ItemFieldSelect) sqlScan(ctx context.Context, root *ItemFieldQuery, 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
"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/predicate"
)
// EntityFieldUpdate is the builder for updating EntityField entities.
type EntityFieldUpdate struct {
// ItemFieldUpdate is the builder for updating ItemField entities.
type ItemFieldUpdate struct {
config
hooks []Hook
mutation *EntityFieldMutation
mutation *ItemFieldMutation
}
// Where appends a list predicates to the EntityFieldUpdate builder.
func (_u *EntityFieldUpdate) Where(ps ...predicate.EntityField) *EntityFieldUpdate {
// Where appends a list predicates to the ItemFieldUpdate builder.
func (_u *ItemFieldUpdate) Where(ps ...predicate.ItemField) *ItemFieldUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *EntityFieldUpdate) SetUpdatedAt(v time.Time) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetUpdatedAt(v time.Time) *ItemFieldUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *EntityFieldUpdate) SetName(v string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetName(v string) *ItemFieldUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableName(v *string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableName(v *string) *ItemFieldUpdate {
if v != nil {
_u.SetName(*v)
}
@@ -51,13 +51,13 @@ func (_u *EntityFieldUpdate) SetNillableName(v *string) *EntityFieldUpdate {
}
// SetDescription sets the "description" field.
func (_u *EntityFieldUpdate) SetDescription(v string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetDescription(v string) *ItemFieldUpdate {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableDescription(v *string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableDescription(v *string) *ItemFieldUpdate {
if v != nil {
_u.SetDescription(*v)
}
@@ -65,19 +65,19 @@ func (_u *EntityFieldUpdate) SetNillableDescription(v *string) *EntityFieldUpdat
}
// ClearDescription clears the value of the "description" field.
func (_u *EntityFieldUpdate) ClearDescription() *EntityFieldUpdate {
func (_u *ItemFieldUpdate) ClearDescription() *ItemFieldUpdate {
_u.mutation.ClearDescription()
return _u
}
// SetType sets the "type" field.
func (_u *EntityFieldUpdate) SetType(v entityfield.Type) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetType(v itemfield.Type) *ItemFieldUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableType(v *entityfield.Type) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableType(v *itemfield.Type) *ItemFieldUpdate {
if v != nil {
_u.SetType(*v)
}
@@ -85,13 +85,13 @@ func (_u *EntityFieldUpdate) SetNillableType(v *entityfield.Type) *EntityFieldUp
}
// SetTextValue sets the "text_value" field.
func (_u *EntityFieldUpdate) SetTextValue(v string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetTextValue(v string) *ItemFieldUpdate {
_u.mutation.SetTextValue(v)
return _u
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableTextValue(v *string) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableTextValue(v *string) *ItemFieldUpdate {
if v != nil {
_u.SetTextValue(*v)
}
@@ -99,20 +99,20 @@ func (_u *EntityFieldUpdate) SetNillableTextValue(v *string) *EntityFieldUpdate
}
// ClearTextValue clears the value of the "text_value" field.
func (_u *EntityFieldUpdate) ClearTextValue() *EntityFieldUpdate {
func (_u *ItemFieldUpdate) ClearTextValue() *ItemFieldUpdate {
_u.mutation.ClearTextValue()
return _u
}
// SetNumberValue sets the "number_value" field.
func (_u *EntityFieldUpdate) SetNumberValue(v int) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNumberValue(v int) *ItemFieldUpdate {
_u.mutation.ResetNumberValue()
_u.mutation.SetNumberValue(v)
return _u
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableNumberValue(v *int) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableNumberValue(v *int) *ItemFieldUpdate {
if v != nil {
_u.SetNumberValue(*v)
}
@@ -120,25 +120,25 @@ func (_u *EntityFieldUpdate) SetNillableNumberValue(v *int) *EntityFieldUpdate {
}
// AddNumberValue adds value to the "number_value" field.
func (_u *EntityFieldUpdate) AddNumberValue(v int) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) AddNumberValue(v int) *ItemFieldUpdate {
_u.mutation.AddNumberValue(v)
return _u
}
// ClearNumberValue clears the value of the "number_value" field.
func (_u *EntityFieldUpdate) ClearNumberValue() *EntityFieldUpdate {
func (_u *ItemFieldUpdate) ClearNumberValue() *ItemFieldUpdate {
_u.mutation.ClearNumberValue()
return _u
}
// SetBooleanValue sets the "boolean_value" field.
func (_u *EntityFieldUpdate) SetBooleanValue(v bool) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetBooleanValue(v bool) *ItemFieldUpdate {
_u.mutation.SetBooleanValue(v)
return _u
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableBooleanValue(v *bool) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableBooleanValue(v *bool) *ItemFieldUpdate {
if v != nil {
_u.SetBooleanValue(*v)
}
@@ -146,57 +146,57 @@ func (_u *EntityFieldUpdate) SetNillableBooleanValue(v *bool) *EntityFieldUpdate
}
// SetTimeValue sets the "time_value" field.
func (_u *EntityFieldUpdate) SetTimeValue(v time.Time) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetTimeValue(v time.Time) *ItemFieldUpdate {
_u.mutation.SetTimeValue(v)
return _u
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_u *EntityFieldUpdate) SetNillableTimeValue(v *time.Time) *EntityFieldUpdate {
func (_u *ItemFieldUpdate) SetNillableTimeValue(v *time.Time) *ItemFieldUpdate {
if v != nil {
_u.SetTimeValue(*v)
}
return _u
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *EntityFieldUpdate) SetEntityID(id uuid.UUID) *EntityFieldUpdate {
_u.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *ItemFieldUpdate) SetItemID(id uuid.UUID) *ItemFieldUpdate {
_u.mutation.SetItemID(id)
return _u
}
// 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 {
// 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 {
if id != nil {
_u = _u.SetEntityID(*id)
_u = _u.SetItemID(*id)
}
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdate) SetEntity(v *Entity) *EntityFieldUpdate {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *ItemFieldUpdate) SetItem(v *Item) *ItemFieldUpdate {
return _u.SetItemID(v.ID)
}
// Mutation returns the EntityFieldMutation object of the builder.
func (_u *EntityFieldUpdate) Mutation() *EntityFieldMutation {
// Mutation returns the ItemFieldMutation object of the builder.
func (_u *ItemFieldUpdate) Mutation() *ItemFieldMutation {
return _u.mutation
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdate) ClearEntity() *EntityFieldUpdate {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *ItemFieldUpdate) ClearItem() *ItemFieldUpdate {
_u.mutation.ClearItem()
return _u
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *EntityFieldUpdate) Save(ctx context.Context) (int, error) {
func (_u *ItemFieldUpdate) 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 *EntityFieldUpdate) SaveX(ctx context.Context) int {
func (_u *ItemFieldUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
@@ -205,56 +205,56 @@ func (_u *EntityFieldUpdate) SaveX(ctx context.Context) int {
}
// Exec executes the query.
func (_u *EntityFieldUpdate) Exec(ctx context.Context) error {
func (_u *ItemFieldUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *EntityFieldUpdate) ExecX(ctx context.Context) {
func (_u *ItemFieldUpdate) 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 *EntityFieldUpdate) defaults() {
func (_u *ItemFieldUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := entityfield.UpdateDefaultUpdatedAt()
v := itemfield.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *EntityFieldUpdate) check() error {
func (_u *ItemFieldUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
}
}
if v, ok := _u.mutation.TextValue(); ok {
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 err := itemfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)}
}
}
return nil
}
func (_u *EntityFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
func (_u *ItemFieldUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.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 *EntityFieldUpdate) sqlSave(ctx context.Context) (_node int, err error)
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(entityfield.FieldName, field.TypeString, value)
_spec.SetField(itemfield.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.TextValue(); ok {
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
}
if _u.mutation.TextValueCleared() {
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
}
if value, ok := _u.mutation.NumberValue(); ok {
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedNumberValue(); ok {
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
}
if _u.mutation.NumberValueCleared() {
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
}
if value, ok := _u.mutation.BooleanValue(); ok {
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
}
if value, ok := _u.mutation.TimeValue(); ok {
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
}
if _u.mutation.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -329,7 +329,7 @@ func (_u *EntityFieldUpdate) 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{entityfield.Label}
err = &NotFoundError{itemfield.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
@@ -339,28 +339,28 @@ func (_u *EntityFieldUpdate) sqlSave(ctx context.Context) (_node int, err error)
return _node, nil
}
// EntityFieldUpdateOne is the builder for updating a single EntityField entity.
type EntityFieldUpdateOne struct {
// ItemFieldUpdateOne is the builder for updating a single ItemField entity.
type ItemFieldUpdateOne struct {
config
fields []string
hooks []Hook
mutation *EntityFieldMutation
mutation *ItemFieldMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *EntityFieldUpdateOne) SetUpdatedAt(v time.Time) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetUpdatedAt(v time.Time) *ItemFieldUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetName sets the "name" field.
func (_u *EntityFieldUpdateOne) SetName(v string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetName(v string) *ItemFieldUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableName(v *string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableName(v *string) *ItemFieldUpdateOne {
if v != nil {
_u.SetName(*v)
}
@@ -368,13 +368,13 @@ func (_u *EntityFieldUpdateOne) SetNillableName(v *string) *EntityFieldUpdateOne
}
// SetDescription sets the "description" field.
func (_u *EntityFieldUpdateOne) SetDescription(v string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetDescription(v string) *ItemFieldUpdateOne {
_u.mutation.SetDescription(v)
return _u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableDescription(v *string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableDescription(v *string) *ItemFieldUpdateOne {
if v != nil {
_u.SetDescription(*v)
}
@@ -382,19 +382,19 @@ func (_u *EntityFieldUpdateOne) SetNillableDescription(v *string) *EntityFieldUp
}
// ClearDescription clears the value of the "description" field.
func (_u *EntityFieldUpdateOne) ClearDescription() *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) ClearDescription() *ItemFieldUpdateOne {
_u.mutation.ClearDescription()
return _u
}
// SetType sets the "type" field.
func (_u *EntityFieldUpdateOne) SetType(v entityfield.Type) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetType(v itemfield.Type) *ItemFieldUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableType(v *entityfield.Type) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableType(v *itemfield.Type) *ItemFieldUpdateOne {
if v != nil {
_u.SetType(*v)
}
@@ -402,13 +402,13 @@ func (_u *EntityFieldUpdateOne) SetNillableType(v *entityfield.Type) *EntityFiel
}
// SetTextValue sets the "text_value" field.
func (_u *EntityFieldUpdateOne) SetTextValue(v string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetTextValue(v string) *ItemFieldUpdateOne {
_u.mutation.SetTextValue(v)
return _u
}
// SetNillableTextValue sets the "text_value" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableTextValue(v *string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableTextValue(v *string) *ItemFieldUpdateOne {
if v != nil {
_u.SetTextValue(*v)
}
@@ -416,20 +416,20 @@ func (_u *EntityFieldUpdateOne) SetNillableTextValue(v *string) *EntityFieldUpda
}
// ClearTextValue clears the value of the "text_value" field.
func (_u *EntityFieldUpdateOne) ClearTextValue() *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) ClearTextValue() *ItemFieldUpdateOne {
_u.mutation.ClearTextValue()
return _u
}
// SetNumberValue sets the "number_value" field.
func (_u *EntityFieldUpdateOne) SetNumberValue(v int) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNumberValue(v int) *ItemFieldUpdateOne {
_u.mutation.ResetNumberValue()
_u.mutation.SetNumberValue(v)
return _u
}
// SetNillableNumberValue sets the "number_value" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableNumberValue(v *int) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableNumberValue(v *int) *ItemFieldUpdateOne {
if v != nil {
_u.SetNumberValue(*v)
}
@@ -437,25 +437,25 @@ func (_u *EntityFieldUpdateOne) SetNillableNumberValue(v *int) *EntityFieldUpdat
}
// AddNumberValue adds value to the "number_value" field.
func (_u *EntityFieldUpdateOne) AddNumberValue(v int) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) AddNumberValue(v int) *ItemFieldUpdateOne {
_u.mutation.AddNumberValue(v)
return _u
}
// ClearNumberValue clears the value of the "number_value" field.
func (_u *EntityFieldUpdateOne) ClearNumberValue() *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) ClearNumberValue() *ItemFieldUpdateOne {
_u.mutation.ClearNumberValue()
return _u
}
// SetBooleanValue sets the "boolean_value" field.
func (_u *EntityFieldUpdateOne) SetBooleanValue(v bool) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetBooleanValue(v bool) *ItemFieldUpdateOne {
_u.mutation.SetBooleanValue(v)
return _u
}
// SetNillableBooleanValue sets the "boolean_value" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableBooleanValue(v *bool) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableBooleanValue(v *bool) *ItemFieldUpdateOne {
if v != nil {
_u.SetBooleanValue(*v)
}
@@ -463,70 +463,70 @@ func (_u *EntityFieldUpdateOne) SetNillableBooleanValue(v *bool) *EntityFieldUpd
}
// SetTimeValue sets the "time_value" field.
func (_u *EntityFieldUpdateOne) SetTimeValue(v time.Time) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetTimeValue(v time.Time) *ItemFieldUpdateOne {
_u.mutation.SetTimeValue(v)
return _u
}
// SetNillableTimeValue sets the "time_value" field if the given value is not nil.
func (_u *EntityFieldUpdateOne) SetNillableTimeValue(v *time.Time) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) SetNillableTimeValue(v *time.Time) *ItemFieldUpdateOne {
if v != nil {
_u.SetTimeValue(*v)
}
return _u
}
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *EntityFieldUpdateOne) SetEntityID(id uuid.UUID) *EntityFieldUpdateOne {
_u.mutation.SetEntityID(id)
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *ItemFieldUpdateOne) SetItemID(id uuid.UUID) *ItemFieldUpdateOne {
_u.mutation.SetItemID(id)
return _u
}
// 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 {
// 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 {
if id != nil {
_u = _u.SetEntityID(*id)
_u = _u.SetItemID(*id)
}
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdateOne) SetEntity(v *Entity) *EntityFieldUpdateOne {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *ItemFieldUpdateOne) SetItem(v *Item) *ItemFieldUpdateOne {
return _u.SetItemID(v.ID)
}
// Mutation returns the EntityFieldMutation object of the builder.
func (_u *EntityFieldUpdateOne) Mutation() *EntityFieldMutation {
// Mutation returns the ItemFieldMutation object of the builder.
func (_u *ItemFieldUpdateOne) Mutation() *ItemFieldMutation {
return _u.mutation
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *EntityFieldUpdateOne) ClearEntity() *EntityFieldUpdateOne {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *ItemFieldUpdateOne) ClearItem() *ItemFieldUpdateOne {
_u.mutation.ClearItem()
return _u
}
// Where appends a list predicates to the EntityFieldUpdate builder.
func (_u *EntityFieldUpdateOne) Where(ps ...predicate.EntityField) *EntityFieldUpdateOne {
// Where appends a list predicates to the ItemFieldUpdate builder.
func (_u *ItemFieldUpdateOne) Where(ps ...predicate.ItemField) *ItemFieldUpdateOne {
_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 *EntityFieldUpdateOne) Select(field string, fields ...string) *EntityFieldUpdateOne {
func (_u *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFieldUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated EntityField entity.
func (_u *EntityFieldUpdateOne) Save(ctx context.Context) (*EntityField, error) {
// Save executes the query and returns the updated ItemField entity.
func (_u *ItemFieldUpdateOne) Save(ctx context.Context) (*ItemField, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
func (_u *ItemFieldUpdateOne) SaveX(ctx context.Context) *ItemField {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
@@ -535,69 +535,69 @@ func (_u *EntityFieldUpdateOne) SaveX(ctx context.Context) *EntityField {
}
// Exec executes the query on the entity.
func (_u *EntityFieldUpdateOne) Exec(ctx context.Context) error {
func (_u *ItemFieldUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *EntityFieldUpdateOne) ExecX(ctx context.Context) {
func (_u *ItemFieldUpdateOne) 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 *EntityFieldUpdateOne) defaults() {
func (_u *ItemFieldUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := entityfield.UpdateDefaultUpdatedAt()
v := itemfield.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *EntityFieldUpdateOne) check() error {
func (_u *ItemFieldUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := entityfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "EntityField.name": %w`, err)}
if err := itemfield.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ItemField.name": %w`, err)}
}
}
if v, ok := _u.mutation.Description(); ok {
if err := entityfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "EntityField.description": %w`, err)}
if err := itemfield.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "ItemField.description": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := entityfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "EntityField.type": %w`, err)}
if err := itemfield.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "ItemField.type": %w`, err)}
}
}
if v, ok := _u.mutation.TextValue(); ok {
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 err := itemfield.TextValueValidator(v); err != nil {
return &ValidationError{Name: "text_value", err: fmt.Errorf(`ent: validator failed for field "ItemField.text_value": %w`, err)}
}
}
return nil
}
func (_u *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField, err error) {
func (_u *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(entityfield.Table, entityfield.Columns, sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EntityField.id" for update`)}
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemField.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, entityfield.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, itemfield.FieldID)
for _, f := range fields {
if !entityfield.ValidColumn(f) {
if !itemfield.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != entityfield.FieldID {
if f != itemfield.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
@@ -610,63 +610,63 @@ func (_u *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(entityfield.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(entityfield.FieldName, field.TypeString, value)
_spec.SetField(itemfield.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Description(); ok {
_spec.SetField(entityfield.FieldDescription, field.TypeString, value)
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
}
if _u.mutation.DescriptionCleared() {
_spec.ClearField(entityfield.FieldDescription, field.TypeString)
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(entityfield.FieldType, field.TypeEnum, value)
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
}
if value, ok := _u.mutation.TextValue(); ok {
_spec.SetField(entityfield.FieldTextValue, field.TypeString, value)
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
}
if _u.mutation.TextValueCleared() {
_spec.ClearField(entityfield.FieldTextValue, field.TypeString)
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
}
if value, ok := _u.mutation.NumberValue(); ok {
_spec.SetField(entityfield.FieldNumberValue, field.TypeInt, value)
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedNumberValue(); ok {
_spec.AddField(entityfield.FieldNumberValue, field.TypeInt, value)
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
}
if _u.mutation.NumberValueCleared() {
_spec.ClearField(entityfield.FieldNumberValue, field.TypeInt)
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
}
if value, ok := _u.mutation.BooleanValue(); ok {
_spec.SetField(entityfield.FieldBooleanValue, field.TypeBool, value)
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
}
if value, ok := _u.mutation.TimeValue(); ok {
_spec.SetField(entityfield.FieldTimeValue, field.TypeTime, value)
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
}
if _u.mutation.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: entityfield.EntityTable,
Columns: []string{entityfield.EntityColumn},
Table: itemfield.ItemTable,
Columns: []string{itemfield.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -674,12 +674,12 @@ func (_u *EntityFieldUpdateOne) sqlSave(ctx context.Context) (_node *EntityField
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &EntityField{config: _u.config}
_node = &ItemField{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{entityfield.Label}
err = &NotFoundError{itemfield.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}

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 *Entity `json:"location,omitempty"`
Location *Location `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() (*Entity, error) {
func (e ItemTemplateEdges) LocationOrErr() (*Location, error) {
if e.Location != nil {
return e.Location, nil
} else if e.loadedTypes[2] {
return nil, &NotFoundError{label: entity.Label}
return nil, &NotFoundError{label: location.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() *EntityQuery {
func (_m *ItemTemplate) QueryLocation() *LocationQuery {
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 Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
LocationInverseTable = "entities"
// 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 = "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.Entity) predicate.ItemTemplate {
func HasLocationWith(preds ...predicate.Location) 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 Entity entity by ID.
// SetLocationID sets the "location" edge to the Location entity by ID.
func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate {
_c.mutation.SetLocationID(id)
return _c
}
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Location 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 Entity entity.
func (_c *ItemTemplateCreate) SetLocation(v *Entity) *ItemTemplateCreate {
// SetLocation sets the "location" edge to the Location entity.
func (_c *ItemTemplateCreate) SetLocation(v *Location) *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(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.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 *EntityQuery
withLocation *LocationQuery
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() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) QueryLocation() *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
@@ -124,7 +124,7 @@ func (_q *ItemTemplateQuery) QueryLocation() *EntityQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.To(location.Table, location.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(*EntityQuery)) *ItemTemplateQuery {
query := (&EntityClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery {
query := (&LocationClient{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 *Entity) { n.Edges.Location = e }); err != nil {
func(n *ItemTemplate, e *Location) { 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 *EntityQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Entity)) error {
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) 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 *EntityQuer
if len(ids) == 0 {
return nil
}
query.Where(entity.IDIn(ids...))
query.Where(location.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 Entity entity by ID.
// SetLocationID sets the "location" edge to the Location entity by ID.
func (_u *ItemTemplateUpdate) SetLocationID(id uuid.UUID) *ItemTemplateUpdate {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Location 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 Entity entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Entity) *ItemTemplateUpdate {
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Location) *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 Entity entity.
// ClearLocation clears the "location" edge to the Location 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(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.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(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.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 Entity entity by ID.
// SetLocationID sets the "location" edge to the Location entity by ID.
func (_u *ItemTemplateUpdateOne) SetLocationID(id uuid.UUID) *ItemTemplateUpdateOne {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Location 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 Entity entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Entity) *ItemTemplateUpdateOne {
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *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 Entity entity.
// ClearLocation clears the "location" edge to the Location 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(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.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(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(location.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"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,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"}
}
// EntitiesOrErr returns the Entities value or an error if the edge
// ItemsOrErr returns the Items value or an error if the edge
// was not loaded in eager-loading.
func (e LabelEdges) EntitiesOrErr() ([]*Entity, error) {
func (e LabelEdges) ItemsOrErr() ([]*Item, error) {
if e.loadedTypes[1] {
return e.Entities, nil
return e.Items, nil
}
return nil, &NotLoadedError{edge: "entities"}
return nil, &NotLoadedError{edge: "items"}
}
// 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)
}
// QueryEntities queries the "entities" edge of the Label entity.
func (_m *Label) QueryEntities() *EntityQuery {
return NewLabelClient(_m.config).QueryEntities(_m)
// QueryItems queries the "items" edge of the Label entity.
func (_m *Label) QueryItems() *ItemQuery {
return NewLabelClient(_m.config).QueryItems(_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"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// EdgeItems holds the string denoting the items edge name in mutations.
EdgeItems = "items"
// 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"
// 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"
// 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"
)
// Columns holds all SQL columns for label fields.
@@ -62,9 +62,9 @@ var ForeignKeys = []string{
}
var (
// EntitiesPrimaryKey and EntitiesColumn2 are the table columns denoting the
// primary key for the entities relation (M2M).
EntitiesPrimaryKey = []string{"label_id", "entity_id"}
// ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the
// primary key for the items relation (M2M).
ItemsPrimaryKey = []string{"label_id", "item_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 {
}
}
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
// ByItemsCount orders the results by items count.
func ByItemsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...)
}
}
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByItems orders the results by items terms.
func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
sqlgraph.OrderByNeighborTerms(s, newItemsStep(), 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 newEntitiesStep() *sqlgraph.Step {
func newItemsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, EntitiesTable, EntitiesPrimaryKey...),
sqlgraph.To(ItemsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
)
}

View File

@@ -399,21 +399,21 @@ func HasGroupWith(preds ...predicate.Group) predicate.Label {
})
}
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.Label {
// HasItems applies the HasEdge predicate on the "items" edge.
func HasItems() predicate.Label {
return predicate.Label(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, EntitiesTable, EntitiesPrimaryKey...),
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
)
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.Label {
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
func HasItemsWith(preds ...predicate.Item) predicate.Label {
return predicate.Label(func(s *sql.Selector) {
step := newEntitiesStep()
step := newItemsStep()
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)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddEntityIDs(ids...)
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddItemIDs(ids...)
return _c
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate {
// AddItems adds the "items" edges to the Item entity.
func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddEntityIDs(ids...)
return _c.AddItemIDs(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.EntitiesIDs(); len(nodes) > 0 {
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.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
withEntities *EntityQuery
withFKs bool
ctx *QueryContext
order []label.OrderOption
inters []Interceptor
predicates []predicate.Label
withGroup *GroupQuery
withItems *ItemQuery
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
}
// QueryEntities chains the current query on the "entities" edge.
func (_q *LabelQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
// QueryItems chains the current query on the "items" edge.
func (_q *LabelQuery) 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
@@ -100,8 +100,8 @@ func (_q *LabelQuery) QueryEntities() *EntityQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(label.Table, label.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
)
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(),
withEntities: _q.withEntities.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(),
withItems: _q.withItems.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
}
// 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()
// 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()
for _, opt := range opts {
opt(query)
}
_q.withEntities = query
_q.withItems = 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.withEntities != nil,
_q.withItems != 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.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 {
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 {
return nil, err
}
}
@@ -487,7 +487,7 @@ func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []
}
return nil
}
func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error {
func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) 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) loadEntities(ctx context.Context, query *EntityQuery, node
}
}
query.Where(func(s *sql.Selector) {
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...))
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...))
columns := s.SelectedColumns()
s.Select(joinT.C(label.EntitiesPrimaryKey[0]))
s.Select(joinT.C(label.ItemsPrimaryKey[0]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
@@ -533,14 +533,14 @@ func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, node
}
})
})
neighbors, err := withInterceptors[[]*Entity](ctx, query, qr, query.inters)
neighbors, err := withInterceptors[[]*Item](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 "entities" node returned %v`, n.ID)
return fmt.Errorf(`unexpected "items" 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)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddEntityIDs(ids...)
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate {
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
return _u.AddItemIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -128,25 +128,25 @@ func (_u *LabelUpdate) ClearGroup() *LabelUpdate {
return _u
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdate) ClearEntities() *LabelUpdate {
_u.mutation.ClearEntities()
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdate) ClearItems() *LabelUpdate {
_u.mutation.ClearItems()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveEntityIDs(ids...)
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate {
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
return _u.RemoveItemIDs(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.EntitiesCleared() {
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.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.EntitiesIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -403,19 +403,19 @@ func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne {
return _u.SetGroupID(v.ID)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddEntityIDs(ids...)
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne {
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityIDs(ids...)
return _u.AddItemIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -429,25 +429,25 @@ func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
return _u
}
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne {
_u.mutation.ClearEntities()
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne {
_u.mutation.ClearItems()
return _u
}
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne {
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityIDs(ids...)
return _u.RemoveItemIDs(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.EntitiesCleared() {
if _u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.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.EntitiesIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

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"
)
// EntityType is the model entity for the EntityType schema.
type EntityType struct {
// Location is the model entity for the Location schema.
type Location struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -27,33 +27,32 @@ type EntityType 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 EntityTypeQuery when eager-loading is set.
Edges EntityTypeEdges `json:"edges"`
group_entity_types *uuid.UUID
selectValues sql.SelectValues
// 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
}
// EntityTypeEdges holds the relations/edges for other nodes in the graph.
type EntityTypeEdges struct {
// LocationEdges holds the relations/edges for other nodes in the graph.
type LocationEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,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"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
loadedTypes [4]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 EntityTypeEdges) GroupOrErr() (*Group, error) {
func (e LocationEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[0] {
@@ -62,29 +61,49 @@ func (e EntityTypeEdges) GroupOrErr() (*Group, error) {
return nil, &NotLoadedError{edge: "group"}
}
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e EntityTypeEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Entities, nil
// 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: "entities"}
return nil, &NotLoadedError{edge: "parent"}
}
// ChildrenOrErr returns the Children 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
}
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"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*EntityType) scanValues(columns []string) ([]any, error) {
func (*Location) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case entitytype.FieldIsLocation:
values[i] = new(sql.NullBool)
case entitytype.FieldName, entitytype.FieldDescription, entitytype.FieldIcon, entitytype.FieldColor:
case location.FieldName, location.FieldDescription:
values[i] = new(sql.NullString)
case entitytype.FieldCreatedAt, entitytype.FieldUpdatedAt:
case location.FieldCreatedAt, location.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case entitytype.FieldID:
case location.FieldID:
values[i] = new(uuid.UUID)
case entitytype.ForeignKeys[0]: // group_entity_types
case location.ForeignKeys[0]: // group_locations
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case location.ForeignKeys[1]: // location_children
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -94,67 +113,56 @@ func (*EntityType) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the EntityType fields.
func (_m *EntityType) assignValues(columns []string, values []any) error {
// to the Location fields.
func (_m *Location) 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 entitytype.FieldID:
case location.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 entitytype.FieldCreatedAt:
case location.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 entitytype.FieldUpdatedAt:
case location.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 entitytype.FieldName:
case location.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 entitytype.FieldDescription:
case location.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 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.Icon = value.String
}
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.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]:
case location.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field group_entity_types", values[i])
return fmt.Errorf("unexpected type %T for field group_locations", values[i])
} else if value.Valid {
_m.group_entity_types = new(uuid.UUID)
*_m.group_entity_types = *value.S.(*uuid.UUID)
_m.group_locations = new(uuid.UUID)
*_m.group_locations = *value.S.(*uuid.UUID)
}
case location.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field location_children", values[i])
} else if value.Valid {
_m.location_children = new(uuid.UUID)
*_m.location_children = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -163,44 +171,54 @@ func (_m *EntityType) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the EntityType.
// Value returns the ent.Value that was dynamically selected and assigned to the Location.
// This includes values selected through modifiers, order, etc.
func (_m *EntityType) Value(name string) (ent.Value, error) {
func (_m *Location) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroup queries the "group" edge of the EntityType entity.
func (_m *EntityType) QueryGroup() *GroupQuery {
return NewEntityTypeClient(_m.config).QueryGroup(_m)
// QueryGroup queries the "group" edge of the Location entity.
func (_m *Location) QueryGroup() *GroupQuery {
return NewLocationClient(_m.config).QueryGroup(_m)
}
// QueryEntities queries the "entities" edge of the EntityType entity.
func (_m *EntityType) QueryEntities() *EntityQuery {
return NewEntityTypeClient(_m.config).QueryEntities(_m)
// QueryParent queries the "parent" edge of the Location entity.
func (_m *Location) QueryParent() *LocationQuery {
return NewLocationClient(_m.config).QueryParent(_m)
}
// Update returns a builder for updating this EntityType.
// Note that you need to call EntityType.Unwrap() before calling this method if this EntityType
// 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
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *EntityType) Update() *EntityTypeUpdateOne {
return NewEntityTypeClient(_m.config).UpdateOne(_m)
func (_m *Location) Update() *LocationUpdateOne {
return NewLocationClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the EntityType entity that was returned from a transaction after it was closed,
// Unwrap unwraps the Location 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 *EntityType) Unwrap() *EntityType {
func (_m *Location) Unwrap() *Location {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: EntityType is not a transactional entity")
panic("ent: Location is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *EntityType) String() string {
func (_m *Location) String() string {
var builder strings.Builder
builder.WriteString("EntityType(")
builder.WriteString("Location(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -213,18 +231,9 @@ func (_m *EntityType) 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()
}
// EntityTypes is a parsable slice of EntityType.
type EntityTypes []*EntityType
// Locations is a parsable slice of Location.
type Locations []*Location

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package entitytype
package location
import (
"time"
@@ -11,8 +11,8 @@ import (
)
const (
// Label holds the string label denoting the entitytype type in the database.
Label = "entity_type"
// Label holds the string label denoting the location type in the database.
Label = "location"
// 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,50 +23,54 @@ 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"
// 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"
// 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"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "entity_types"
GroupTable = "locations"
// 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_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"
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"
)
// Columns holds all SQL columns for entitytype fields.
// Columns holds all SQL columns for location fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldName,
FieldDescription,
FieldIcon,
FieldColor,
FieldIsLocation,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "entity_types"
// ForeignKeys holds the SQL foreign-keys that are owned by the "locations"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"group_entity_types",
"group_locations",
"location_children",
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -95,17 +99,11 @@ 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 EntityType queries.
// OrderOption defines the ordering options for the Location queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
@@ -133,21 +131,6 @@ 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) {
@@ -155,17 +138,38 @@ func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
}
}
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(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.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
}
}
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByChildrenCount orders the results by children count.
func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
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...)...)
}
}
func newGroupStep() *sqlgraph.Step {
@@ -175,10 +179,24 @@ func newGroupStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newEntitiesStep() *sqlgraph.Step {
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
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),
)
}

View File

@@ -0,0 +1,404 @@
// 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

@@ -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"
)
// EntityTypeCreate is the builder for creating a EntityType entity.
type EntityTypeCreate struct {
// LocationCreate is the builder for creating a Location entity.
type LocationCreate struct {
config
mutation *EntityTypeMutation
mutation *LocationMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (_c *EntityTypeCreate) SetCreatedAt(v time.Time) *EntityTypeCreate {
func (_c *LocationCreate) SetCreatedAt(v time.Time) *LocationCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableCreatedAt(v *time.Time) *EntityTypeCreate {
func (_c *LocationCreate) SetNillableCreatedAt(v *time.Time) *LocationCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
@@ -38,13 +38,13 @@ func (_c *EntityTypeCreate) SetNillableCreatedAt(v *time.Time) *EntityTypeCreate
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *EntityTypeCreate) SetUpdatedAt(v time.Time) *EntityTypeCreate {
func (_c *LocationCreate) SetUpdatedAt(v time.Time) *LocationCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableUpdatedAt(v *time.Time) *EntityTypeCreate {
func (_c *LocationCreate) SetNillableUpdatedAt(v *time.Time) *LocationCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
@@ -52,75 +52,33 @@ func (_c *EntityTypeCreate) SetNillableUpdatedAt(v *time.Time) *EntityTypeCreate
}
// SetName sets the "name" field.
func (_c *EntityTypeCreate) SetName(v string) *EntityTypeCreate {
func (_c *LocationCreate) SetName(v string) *LocationCreate {
_c.mutation.SetName(v)
return _c
}
// SetDescription sets the "description" field.
func (_c *EntityTypeCreate) SetDescription(v string) *EntityTypeCreate {
func (_c *LocationCreate) SetDescription(v string) *LocationCreate {
_c.mutation.SetDescription(v)
return _c
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableDescription(v *string) *EntityTypeCreate {
func (_c *LocationCreate) SetNillableDescription(v *string) *LocationCreate {
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 *EntityTypeCreate) SetID(v uuid.UUID) *EntityTypeCreate {
func (_c *LocationCreate) SetID(v uuid.UUID) *LocationCreate {
_c.mutation.SetID(v)
return _c
}
// SetNillableID sets the "id" field if the given value is not nil.
func (_c *EntityTypeCreate) SetNillableID(v *uuid.UUID) *EntityTypeCreate {
func (_c *LocationCreate) SetNillableID(v *uuid.UUID) *LocationCreate {
if v != nil {
_c.SetID(*v)
}
@@ -128,44 +86,78 @@ func (_c *EntityTypeCreate) SetNillableID(v *uuid.UUID) *EntityTypeCreate {
}
// SetGroupID sets the "group" edge to the Group entity by ID.
func (_c *EntityTypeCreate) SetGroupID(id uuid.UUID) *EntityTypeCreate {
func (_c *LocationCreate) SetGroupID(id uuid.UUID) *LocationCreate {
_c.mutation.SetGroupID(id)
return _c
}
// SetGroup sets the "group" edge to the Group entity.
func (_c *EntityTypeCreate) SetGroup(v *Group) *EntityTypeCreate {
func (_c *LocationCreate) SetGroup(v *Group) *LocationCreate {
return _c.SetGroupID(v.ID)
}
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *EntityTypeCreate) AddEntityIDs(ids ...uuid.UUID) *EntityTypeCreate {
_c.mutation.AddEntityIDs(ids...)
// SetParentID sets the "parent" edge to the Location entity by ID.
func (_c *LocationCreate) SetParentID(id uuid.UUID) *LocationCreate {
_c.mutation.SetParentID(id)
return _c
}
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *EntityTypeCreate) AddEntities(v ...*Entity) *EntityTypeCreate {
// 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 {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddEntityIDs(ids...)
return _c.AddChildIDs(ids...)
}
// Mutation returns the EntityTypeMutation object of the builder.
func (_c *EntityTypeCreate) Mutation() *EntityTypeMutation {
// 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 {
return _c.mutation
}
// Save creates the EntityType in the database.
func (_c *EntityTypeCreate) Save(ctx context.Context) (*EntityType, error) {
// Save creates the Location in the database.
func (_c *LocationCreate) Save(ctx context.Context) (*Location, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
func (_c *LocationCreate) SaveX(ctx context.Context) *Location {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -174,79 +166,62 @@ func (_c *EntityTypeCreate) SaveX(ctx context.Context) *EntityType {
}
// Exec executes the query.
func (_c *EntityTypeCreate) Exec(ctx context.Context) error {
func (_c *LocationCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *EntityTypeCreate) ExecX(ctx context.Context) {
func (_c *LocationCreate) 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 *EntityTypeCreate) defaults() {
func (_c *LocationCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := entitytype.DefaultCreatedAt()
v := location.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := entitytype.DefaultUpdatedAt()
v := location.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 := entitytype.DefaultID()
v := location.DefaultID()
_c.mutation.SetID(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *EntityTypeCreate) check() error {
func (_c *LocationCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "EntityType.created_at"`)}
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Location.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "EntityType.updated_at"`)}
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Location.updated_at"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "EntityType.name"`)}
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Location.name"`)}
}
if v, ok := _c.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 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 := _c.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 err := location.DescriptionValidator(v); err != nil {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Location.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 "EntityType.group"`)}
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Location.group"`)}
}
return nil
}
func (_c *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
func (_c *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
if err := _c.check(); err != nil {
return nil, err
}
@@ -269,49 +244,37 @@ func (_c *EntityTypeCreate) sqlSave(ctx context.Context) (*EntityType, error) {
return _node, nil
}
func (_c *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
func (_c *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
var (
_node = &EntityType{config: _c.config}
_spec = sqlgraph.NewCreateSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
_node = &Location{config: _c.config}
_spec = sqlgraph.NewCreateSpec(location.Table, sqlgraph.NewFieldSpec(location.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(entitytype.FieldCreatedAt, field.TypeTime, value)
_spec.SetField(location.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(entitytype.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(entitytype.FieldName, field.TypeString, value)
_spec.SetField(location.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Description(); ok {
_spec.SetField(entitytype.FieldDescription, field.TypeString, value)
_spec.SetField(location.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: entitytype.GroupTable,
Columns: []string{entitytype.GroupColumn},
Table: location.GroupTable,
Columns: []string{location.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
@@ -320,18 +283,51 @@ func (_c *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.group_entity_types = &nodes[0]
_node.group_locations = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
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 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: entitytype.EntitiesTable,
Columns: []string{entitytype.EntitiesColumn},
Table: location.ChildrenTable,
Columns: []string{location.ChildrenColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
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),
},
}
for _, k := range nodes {
@@ -342,27 +338,27 @@ func (_c *EntityTypeCreate) createSpec() (*EntityType, *sqlgraph.CreateSpec) {
return _node, _spec
}
// EntityTypeCreateBulk is the builder for creating many EntityType entities in bulk.
type EntityTypeCreateBulk struct {
// LocationCreateBulk is the builder for creating many Location entities in bulk.
type LocationCreateBulk struct {
config
err error
builders []*EntityTypeCreate
builders []*LocationCreate
}
// Save creates the EntityType entities in the database.
func (_c *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, error) {
// Save creates the Location entities in the database.
func (_c *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*EntityType, len(_c.builders))
nodes := make([]*Location, 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.(*EntityTypeMutation)
mutation, ok := m.(*LocationMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
@@ -405,7 +401,7 @@ func (_c *EntityTypeCreateBulk) Save(ctx context.Context) ([]*EntityType, error)
}
// SaveX is like Save, but panics if an error occurs.
func (_c *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
func (_c *LocationCreateBulk) SaveX(ctx context.Context) []*Location {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
@@ -414,13 +410,13 @@ func (_c *EntityTypeCreateBulk) SaveX(ctx context.Context) []*EntityType {
}
// Exec executes the query.
func (_c *EntityTypeCreateBulk) Exec(ctx context.Context) error {
func (_c *LocationCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *EntityTypeCreateBulk) ExecX(ctx context.Context) {
func (_c *LocationCreateBulk) 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/entitytype"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
// EntityTypeDelete is the builder for deleting a EntityType entity.
type EntityTypeDelete struct {
// LocationDelete is the builder for deleting a Location entity.
type LocationDelete struct {
config
hooks []Hook
mutation *EntityTypeMutation
mutation *LocationMutation
}
// Where appends a list predicates to the EntityTypeDelete builder.
func (_d *EntityTypeDelete) Where(ps ...predicate.EntityType) *EntityTypeDelete {
// Where appends a list predicates to the LocationDelete builder.
func (_d *LocationDelete) Where(ps ...predicate.Location) *LocationDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *EntityTypeDelete) Exec(ctx context.Context) (int, error) {
func (_d *LocationDelete) 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 *EntityTypeDelete) ExecX(ctx context.Context) int {
func (_d *LocationDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
@@ -39,8 +39,8 @@ func (_d *EntityTypeDelete) ExecX(ctx context.Context) int {
return n
}
func (_d *EntityTypeDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(entitytype.Table, sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID))
func (_d *LocationDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(location.Table, sqlgraph.NewFieldSpec(location.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 *EntityTypeDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err
}
// EntityTypeDeleteOne is the builder for deleting a single EntityType entity.
type EntityTypeDeleteOne struct {
_d *EntityTypeDelete
// LocationDeleteOne is the builder for deleting a single Location entity.
type LocationDeleteOne struct {
_d *LocationDelete
}
// Where appends a list predicates to the EntityTypeDelete builder.
func (_d *EntityTypeDeleteOne) Where(ps ...predicate.EntityType) *EntityTypeDeleteOne {
// Where appends a list predicates to the LocationDelete builder.
func (_d *LocationDeleteOne) Where(ps ...predicate.Location) *LocationDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *EntityTypeDeleteOne) Exec(ctx context.Context) error {
func (_d *LocationDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{entitytype.Label}
return &NotFoundError{location.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *EntityTypeDeleteOne) ExecX(ctx context.Context) {
func (_d *LocationDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}

View File

@@ -0,0 +1,839 @@
// 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

@@ -0,0 +1,867 @@
// 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"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"`
// EntityID holds the value of the "entity_id" field.
EntityID uuid.UUID `json:"entity_id,omitempty"`
// ItemID holds the value of the "item_id" field.
ItemID uuid.UUID `json:"item_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 {
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// EntityOrErr returns the Entity value or an error if the edge
// ItemOrErr returns the Item value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e MaintenanceEntryEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: entity.Label}
return nil, &NotFoundError{label: item.Label}
}
return nil, &NotLoadedError{edge: "entity"}
return nil, &NotLoadedError{edge: "item"}
}
// 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.FieldEntityID:
case maintenanceentry.FieldID, maintenanceentry.FieldItemID:
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.FieldEntityID:
case maintenanceentry.FieldItemID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field entity_id", values[i])
return fmt.Errorf("unexpected type %T for field item_id", values[i])
} else if value != nil {
_m.EntityID = *value
_m.ItemID = *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)
}
// QueryEntity queries the "entity" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryEntity() *EntityQuery {
return NewMaintenanceEntryClient(_m.config).QueryEntity(_m)
// QueryItem queries the "item" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryItem() *ItemQuery {
return NewMaintenanceEntryClient(_m.config).QueryItem(_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("entity_id=")
builder.WriteString(fmt.Sprintf("%v", _m.EntityID))
builder.WriteString("item_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ItemID))
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"
// FieldEntityID holds the string denoting the entity_id field in the database.
FieldEntityID = "entity_id"
// FieldItemID holds the string denoting the item_id field in the database.
FieldItemID = "item_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"
// EdgeEntity holds the string denoting the entity edge name in mutations.
EdgeEntity = "entity"
// EdgeItem holds the string denoting the item edge name in mutations.
EdgeItem = "item"
// Table holds the table name of the maintenanceentry in the database.
Table = "maintenance_entries"
// 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"
// 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"
)
// Columns holds all SQL columns for maintenanceentry fields.
@@ -49,7 +49,7 @@ var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldEntityID,
FieldItemID,
FieldDate,
FieldScheduledDate,
FieldName,
@@ -102,9 +102,9 @@ func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByEntityID orders the results by the entity_id field.
func ByEntityID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEntityID, opts...).ToFunc()
// ByItemID orders the results by the item_id field.
func ByItemID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldItemID, 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()
}
// ByEntityField orders the results by entity field.
func ByEntityField(field string, opts ...sql.OrderTermOption) OrderOption {
// ByItemField orders the results by item field.
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityStep(), sql.OrderByField(field, opts...))
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
}
}
func newEntityStep() *sqlgraph.Step {
func newItemStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
sqlgraph.To(ItemInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
}

View File

@@ -66,9 +66,9 @@ func UpdatedAt(v time.Time) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldUpdatedAt, 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))
// 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))
}
// 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))
}
// EntityIDEQ applies the EQ predicate on the "entity_id" field.
func EntityIDEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldEQ(FieldEntityID, 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))
}
// EntityIDNEQ applies the NEQ predicate on the "entity_id" field.
func EntityIDNEQ(v uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNEQ(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))
}
// EntityIDIn applies the In predicate on the "entity_id" field.
func EntityIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldIn(FieldEntityID, vs...))
// ItemIDIn applies the In predicate on the "item_id" field.
func ItemIDIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldIn(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...))
// ItemIDNotIn applies the NotIn predicate on the "item_id" field.
func ItemIDNotIn(vs ...uuid.UUID) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(sql.FieldNotIn(FieldItemID, 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))
}
// HasEntity applies the HasEdge predicate on the "entity" edge.
func HasEntity() predicate.MaintenanceEntry {
// HasItem applies the HasEdge predicate on the "item" edge.
func HasItem() predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
)
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.MaintenanceEntry {
// HasItemWith applies the HasEdge predicate on the "item" edge with a given conditions (other predicates).
func HasItemWith(preds ...predicate.Item) predicate.MaintenanceEntry {
return predicate.MaintenanceEntry(func(s *sql.Selector) {
step := newEntityStep()
step := newItemStep()
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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
)
@@ -50,9 +50,9 @@ func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *Maintenanc
return _c
}
// SetEntityID sets the "entity_id" field.
func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetEntityID(v)
// SetItemID sets the "item_id" field.
func (_c *MaintenanceEntryCreate) SetItemID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetItemID(v)
return _c
}
@@ -132,9 +132,9 @@ func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryC
return _c
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate {
return _c.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_c *MaintenanceEntryCreate) SetItem(v *Item) *MaintenanceEntryCreate {
return _c.SetItemID(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.EntityID(); !ok {
return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)}
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.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.EntityIDs()) == 0 {
return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)}
if len(_c.mutation.ItemIDs()) == 0 {
return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)}
}
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.EntityIDs(); len(nodes) > 0 {
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.EntityID = nodes[0]
_node.ItemID = 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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"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
withEntity *EntityQuery
withItem *ItemQuery
// 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
}
// QueryEntity chains the current query on the "entity" edge.
func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
// QueryItem chains the current query on the "item" edge.
func (_q *MaintenanceEntryQuery) QueryItem() *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
@@ -74,8 +74,8 @@ func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, selector),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn),
)
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...),
withEntity: _q.withEntity.Clone(),
withItem: _q.withItem.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// 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()
// 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()
for _, opt := range opts {
opt(query)
}
_q.withEntity = query
_q.withItem = 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.withEntity != nil,
_q.withItem != 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.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != 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 {
return nil, err
}
}
return nodes, nil
}
func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error {
func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Item)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*MaintenanceEntry)
for i := range nodes {
fk := nodes[i].EntityID
fk := nodes[i].ItemID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -415,7 +415,7 @@ func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQu
if len(ids) == 0 {
return nil
}
query.Where(entity.IDIn(ids...))
query.Where(item.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -423,7 +423,7 @@ func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQu
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "entity_id" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "item_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.withEntity != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID)
if _q.withItem != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldItemID)
}
}
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/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"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
}
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetEntityID(v)
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdate) SetItemID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetItemID(v)
return _u
}
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate {
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdate {
if v != nil {
_u.SetEntityID(*v)
_u.SetItemID(*v)
}
return _u
}
@@ -145,9 +145,9 @@ func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate {
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) SetItem(v *Item) *MaintenanceEntryUpdate {
return _u.SetItemID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -155,9 +155,9 @@ func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate {
_u.mutation.ClearItem()
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.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
}
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.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -312,16 +312,16 @@ func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntry
return _u
}
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetEntityID(v)
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdateOne) SetItemID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetItemID(v)
return _u
}
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
if v != nil {
_u.SetEntityID(*v)
_u.SetItemID(*v)
}
return _u
}
@@ -421,9 +421,9 @@ func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateO
return _u
}
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne {
return _u.SetEntityID(v.ID)
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) SetItem(v *Item) *MaintenanceEntryUpdateOne {
return _u.SetItemID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -431,9 +431,9 @@ func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne {
_u.mutation.ClearEntity()
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne {
_u.mutation.ClearItem()
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.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
}
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.EntityCleared() {
if _u.mutation.ItemCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(item.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: "entity_attachments", Type: field.TypeUUID, Nullable: true},
{Name: "item_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_entities_attachments",
Symbol: "attachments_items_attachments",
Columns: []*schema.Column{AttachmentsColumns[9]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -91,168 +91,6 @@ 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},
@@ -291,6 +129,123 @@ 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},
@@ -327,9 +282,9 @@ var (
OnDelete: schema.Cascade,
},
{
Symbol: "item_templates_entities_location",
Symbol: "item_templates_locations_location",
Columns: []*schema.Column{ItemTemplatesColumns[19]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
RefColumns: []*schema.Column{LocationsColumns[0]},
OnDelete: schema.SetNull,
},
},
@@ -365,6 +320,36 @@ 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},
@@ -375,7 +360,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: "entity_id", Type: field.TypeUUID},
{Name: "item_id", Type: field.TypeUUID},
}
// MaintenanceEntriesTable holds the schema information for the "maintenance_entries" table.
MaintenanceEntriesTable = &schema.Table{
@@ -384,9 +369,9 @@ var (
PrimaryKey: []*schema.Column{MaintenanceEntriesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "maintenance_entries_entities_maintenance_entries",
Symbol: "maintenance_entries_items_maintenance_entries",
Columns: []*schema.Column{MaintenanceEntriesColumns[8]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -506,27 +491,27 @@ var (
},
},
}
// LabelEntitiesColumns holds the columns for the "label_entities" table.
LabelEntitiesColumns = []*schema.Column{
// LabelItemsColumns holds the columns for the "label_items" table.
LabelItemsColumns = []*schema.Column{
{Name: "label_id", Type: field.TypeUUID},
{Name: "entity_id", Type: field.TypeUUID},
{Name: "item_id", Type: field.TypeUUID},
}
// 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]},
// 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]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "label_entities_label_id",
Columns: []*schema.Column{LabelEntitiesColumns[0]},
Symbol: "label_items_label_id",
Columns: []*schema.Column{LabelItemsColumns[0]},
RefColumns: []*schema.Column{LabelsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "label_entities_entity_id",
Columns: []*schema.Column{LabelEntitiesColumns[1]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
Symbol: "label_items_item_id",
Columns: []*schema.Column{LabelItemsColumns[1]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -536,41 +521,41 @@ var (
AttachmentsTable,
AuthRolesTable,
AuthTokensTable,
EntitiesTable,
EntityFieldsTable,
EntityTypesTable,
GroupsTable,
GroupInvitationTokensTable,
ItemsTable,
ItemFieldsTable,
ItemTemplatesTable,
LabelsTable,
LocationsTable,
MaintenanceEntriesTable,
NotifiersTable,
TemplateFieldsTable,
UsersTable,
LabelEntitiesTable,
LabelItemsTable,
}
)
func init() {
AttachmentsTable.ForeignKeys[0].RefTable = AttachmentsTable
AttachmentsTable.ForeignKeys[1].RefTable = EntitiesTable
AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable
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 = EntitiesTable
ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = EntitiesTable
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
UsersTable.ForeignKeys[0].RefTable = GroupsTable
LabelEntitiesTable.ForeignKeys[0].RefTable = LabelsTable
LabelEntitiesTable.ForeignKeys[1].RefTable = EntitiesTable
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
}

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,219 +86,6 @@ 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
@@ -367,6 +154,164 @@ 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
@@ -505,6 +450,49 @@ 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("entity", Entity.Type).
edge.From("item", Item.Type).
Ref("attachments").
Unique(),
edge.To("thumbnail", Attachment.Type).

View File

@@ -1,48 +0,0 @@
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("entities", Entity.Type),
owned("locations", Location.Type),
owned("items", Item.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

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

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", Entity.Type).
edge.To("location", Location.Type).
Unique(),
}
}

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