mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 11:29:12 +00:00
re-init because of weird subtree shit
This commit is contained in:
commit
68254ddd13
85 changed files with 13501 additions and 0 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
bazel-bin
|
||||
bazel-out
|
||||
bazel-roleypoly
|
||||
bazel-testlogs
|
||||
node_modules
|
0
.prettierrc
Normal file
0
.prettierrc
Normal file
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"go.inferGopath": false,
|
||||
"editor.tabSize": 4,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.formatOnSave": true
|
||||
}
|
41
BUILD.bazel
Normal file
41
BUILD.bazel
Normal file
|
@ -0,0 +1,41 @@
|
|||
load("@bazel_gazelle//:def.bzl", "gazelle")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
|
||||
|
||||
# gazelle:prefix github.com/roleypoly/roleypoly
|
||||
gazelle(name = "gazelle")
|
||||
|
||||
exports_files(
|
||||
["tsconfig.json"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "node_modules",
|
||||
srcs = glob(
|
||||
include = [
|
||||
"node_modules/**/*.js",
|
||||
"node_modules/**/*.d.ts",
|
||||
"node_modules/**/*.json",
|
||||
"node_modules/.bin/*",
|
||||
],
|
||||
exclude = [
|
||||
# Files under test & docs may contain file names that
|
||||
# are not legal Bazel labels (e.g.,
|
||||
# node_modules/ecstatic/test/public/中文/檔案.html)
|
||||
"node_modules/**/test/**",
|
||||
"node_modules/**/docs/**",
|
||||
# Files with spaces in the name are not legal Bazel labels
|
||||
"node_modules/**/* */**",
|
||||
"node_modules/**/* *",
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
# Create a tsc_wrapped compiler rule to use in the ts_library
|
||||
# compiler attribute when using self-managed dependencies
|
||||
nodejs_binary(
|
||||
name = "@bazel/typescript/tsc_wrapped",
|
||||
entry_point = "@npm//:node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js",
|
||||
# Point bazel to your node_modules to find the entry point
|
||||
node_modules = "//:node_modules",
|
||||
)
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 roleypoly maintainers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
62
README.md
Normal file
62
README.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# Roleypoly
|
||||
|
||||
https://roleypoly.com
|
||||
|
||||
Tame your Discord roles.
|
||||
|
||||
### Need Help with the App?
|
||||
|
||||
📚 [Please read through our community documentation.](https://github.com/roleypoly/community-docs)
|
||||
|
||||
## Developing
|
||||
|
||||
This is a meta-package for all of the sub-repos under Roleypoly. Because this is a distributed system, you might not need to develop on all of these at once to get something done. *Docs in future.*
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Discord OAuth/Bot Application](https://discordapp.com/developers)
|
||||
- Go 1.12+ w/ `GO111MODULES=on`
|
||||
- Node 12+
|
||||
- Yarn
|
||||
- [mkcert](https://github.com/FiloSottile/mkcert) for self-signing certs for `roleypoly.local *.roleypoly.local`
|
||||
- /etc/hosts entry for the above
|
||||
|
||||
Some parts of development can be done online or integrated into the online systems hosted on roleypoly.com or canary.roleypoly.com.
|
||||
|
||||
### Repos
|
||||
|
||||
- [**Aoi 青い**](https://github.com/roleypoly/aoi)
|
||||
- https://aoi.roleypoly.com
|
||||
- admin & devops dashboard
|
||||
- go, typescript, react
|
||||
- [**Auth**](https://github.com/roleypoly/auth)
|
||||
- authentication, authorization, and session server.
|
||||
- go
|
||||
- [**Discord**](https://github.com/roleypoly/discord)
|
||||
- discord api client, and bot responder
|
||||
- go
|
||||
- [**Design**](https://github.com/roleypoly/design)
|
||||
- https://ui.roleypoly.com
|
||||
- branding, ui kit, storybooks
|
||||
- typescript, react
|
||||
- [**DevOps**](https://github.com/roleypoly/devops)
|
||||
- docker wiring and other tooling
|
||||
- [**Gripkit**](https://github.com/roleypoly/gripkit)
|
||||
- gRPC wiring toolkit
|
||||
- go
|
||||
- [**Platform**](https://github.com/roleypoly/platform)
|
||||
- main business logic, data & presentation layer
|
||||
- go
|
||||
- [**RPC**](https://github.com/roleypoly/rpc)
|
||||
- protobuf definitions, grpc-go and grpc-web libraries
|
||||
- [**UI**](https://github.com/roleypoly/ui)
|
||||
- https://roleypoly.com, https://canary.roleypoly.com
|
||||
- frontend component
|
||||
- node, express, typescript, react, next.js
|
||||
|
||||
### Other Repos
|
||||
|
||||
- [Docker Hub](https://hub.docker.com/u/roleypoly)
|
||||
- [npm](https://www.npmjs.com/org/roleypoly)
|
||||
- [GitHub](https://github.com/roleypoly)
|
||||
- [Original Repo](https://github.com/kayteh/roleypoly)
|
86
WORKSPACE
Normal file
86
WORKSPACE
Normal file
|
@ -0,0 +1,86 @@
|
|||
workspace(
|
||||
name = "roleypoly",
|
||||
managed_directories = {
|
||||
"@npm": ["node_modules"],
|
||||
},
|
||||
)
|
||||
|
||||
### BAZEL
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "08c3cd71857d58af3cda759112437d9e63339ac9c6e0042add43f4d94caf632d",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.2/rules_go-v0.24.2.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.2/rules_go-v0.24.2.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bazel_gazelle",
|
||||
sha256 = "d4113967ab451dd4d2d767c3ca5f927fec4b30f3b2c6f8135a2033b9c05a5687",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.0/bazel-gazelle-v0.22.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.0/bazel-gazelle-v0.22.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_nodejs",
|
||||
sha256 = "b16a03bf63952ae436185c74a5c63bec03c010ed422e230db526af55441a02dd",
|
||||
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.1.0/rules_nodejs-2.1.0.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_docker",
|
||||
sha256 = "4521794f0fba2e20f3bf15846ab5e01d5332e587e9ce81629c7f96c793bb7036",
|
||||
strip_prefix = "rules_docker-0.14.4",
|
||||
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.14.4/rules_docker-v0.14.4.tar.gz"],
|
||||
)
|
||||
|
||||
### GO
|
||||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
|
||||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
|
||||
load("//:deps.bzl", "go_repositories")
|
||||
|
||||
# gazelle:repository_macro deps.bzl%go_repositories
|
||||
go_repositories()
|
||||
|
||||
go_rules_dependencies()
|
||||
|
||||
go_register_toolchains()
|
||||
|
||||
gazelle_dependencies()
|
||||
|
||||
### NODE
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
|
||||
|
||||
node_repositories(
|
||||
node_version = "14.9.0",
|
||||
package_json = ["//:package.json"],
|
||||
yarn_version = "1.22.4",
|
||||
)
|
||||
|
||||
### DOCKER/CONTAINER
|
||||
load(
|
||||
"@io_bazel_rules_docker//repositories:repositories.bzl",
|
||||
container_repositories = "repositories",
|
||||
)
|
||||
|
||||
container_repositories()
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_docker//go:image.bzl",
|
||||
_go_image_repos = "repositories",
|
||||
)
|
||||
|
||||
_go_image_repos()
|
||||
|
||||
load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")
|
||||
|
||||
container_deps()
|
||||
|
||||
load("@io_bazel_rules_docker//repositories:pip_repositories.bzl", "pip_deps")
|
||||
|
||||
pip_deps()
|
852
deps.bzl
Normal file
852
deps.bzl
Normal file
|
@ -0,0 +1,852 @@
|
|||
load("@bazel_gazelle//:deps.bzl", "go_repository")
|
||||
|
||||
def go_repositories():
|
||||
go_repository(
|
||||
name = "co_honnef_go_tools",
|
||||
importpath = "honnef.co/go/tools",
|
||||
sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=",
|
||||
version = "v0.0.0-20190523083050-ea95bdfd59fc",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_alecthomas_template",
|
||||
importpath = "github.com/alecthomas/template",
|
||||
sum = "h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=",
|
||||
version = "v0.0.0-20160405071501-a0175ee3bccc",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_alecthomas_units",
|
||||
importpath = "github.com/alecthomas/units",
|
||||
sum = "h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=",
|
||||
version = "v0.0.0-20151022065526-2efee857e7cf",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_andybalholm_cascadia",
|
||||
importpath = "github.com/andybalholm/cascadia",
|
||||
sum = "h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=",
|
||||
version = "v1.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_armon_consul_api",
|
||||
importpath = "github.com/armon/consul-api",
|
||||
sum = "h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA=",
|
||||
version = "v0.0.0-20180202201655-eb2c6b5be1b6",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_beorn7_perks",
|
||||
importpath = "github.com/beorn7/perks",
|
||||
sum = "h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_burntsushi_toml",
|
||||
importpath = "github.com/BurntSushi/toml",
|
||||
sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=",
|
||||
version = "v0.3.1",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_bwmarrin_discordgo",
|
||||
importpath = "github.com/bwmarrin/discordgo",
|
||||
sum = "h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM=",
|
||||
version = "v0.22.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_census_instrumentation_opencensus_proto",
|
||||
importpath = "github.com/census-instrumentation/opencensus-proto",
|
||||
sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=",
|
||||
version = "v0.2.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_cespare_xxhash",
|
||||
importpath = "github.com/cespare/xxhash",
|
||||
sum = "h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=",
|
||||
version = "v1.1.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_client9_misspell",
|
||||
importpath = "github.com/client9/misspell",
|
||||
sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=",
|
||||
version = "v0.3.4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_cncf_udpa_go",
|
||||
importpath = "github.com/cncf/udpa/go",
|
||||
sum = "h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU=",
|
||||
version = "v0.0.0-20191209042840-269d4d468f6f",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_coreos_bbolt",
|
||||
importpath = "github.com/coreos/bbolt",
|
||||
sum = "h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=",
|
||||
version = "v1.3.2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_coreos_etcd",
|
||||
importpath = "github.com/coreos/etcd",
|
||||
sum = "h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=",
|
||||
version = "v3.3.10+incompatible",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_coreos_go_semver",
|
||||
importpath = "github.com/coreos/go-semver",
|
||||
sum = "h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=",
|
||||
version = "v0.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_coreos_go_systemd",
|
||||
importpath = "github.com/coreos/go-systemd",
|
||||
sum = "h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=",
|
||||
version = "v0.0.0-20190321100706-95778dfbb74e",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_coreos_pkg",
|
||||
importpath = "github.com/coreos/pkg",
|
||||
sum = "h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=",
|
||||
version = "v0.0.0-20180928190104-399ea9e2e55f",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_cpuguy83_go_md2man_v2",
|
||||
importpath = "github.com/cpuguy83/go-md2man/v2",
|
||||
sum = "h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=",
|
||||
version = "v2.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_data_dog_go_sqlmock",
|
||||
importpath = "github.com/DATA-DOG/go-sqlmock",
|
||||
sum = "h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=",
|
||||
version = "v1.5.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_davecgh_go_spew",
|
||||
importpath = "github.com/davecgh/go-spew",
|
||||
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
|
||||
version = "v1.1.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_desertbit_timer",
|
||||
importpath = "github.com/desertbit/timer",
|
||||
sum = "h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I=",
|
||||
version = "v0.0.0-20180107155436-c41aec40b27f",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_dgrijalva_jwt_go",
|
||||
importpath = "github.com/dgrijalva/jwt-go",
|
||||
sum = "h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=",
|
||||
version = "v3.2.0+incompatible",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_dgryski_go_sip13",
|
||||
importpath = "github.com/dgryski/go-sip13",
|
||||
sum = "h1:RMLoZVzv4GliuWafOuPuQDKSm1SJph7uCRnnS61JAn4=",
|
||||
version = "v0.0.0-20181026042036-e10d5fee7954",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_envoyproxy_go_control_plane",
|
||||
importpath = "github.com/envoyproxy/go-control-plane",
|
||||
sum = "h1:rEvIZUSZ3fx39WIi3JkQqQBitGwpELBIYWeBVh6wn+E=",
|
||||
version = "v0.9.4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_envoyproxy_protoc_gen_validate",
|
||||
importpath = "github.com/envoyproxy/protoc-gen-validate",
|
||||
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
|
||||
version = "v0.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_facebook_ent",
|
||||
importpath = "github.com/facebook/ent",
|
||||
sum = "h1:ds9HENceKzpGBgCRlkZNq6TqBIegwKcF3e5reuV9Z0M=",
|
||||
version = "v0.4.3",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_facebookincubator_ent",
|
||||
importpath = "github.com/facebookincubator/ent",
|
||||
sum = "h1:Jht3vZio7eshMo7yaEZJ6LHk4oM8xUCxKNNDj/Kb4fE=",
|
||||
version = "v0.3.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_fsnotify_fsnotify",
|
||||
importpath = "github.com/fsnotify/fsnotify",
|
||||
sum = "h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=",
|
||||
version = "v1.4.7",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_ghodss_yaml",
|
||||
importpath = "github.com/ghodss/yaml",
|
||||
sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_bindata_go_bindata",
|
||||
importpath = "github.com/go-bindata/go-bindata",
|
||||
sum = "h1:WNHfSP1q2vuAa9vF54RrhCl4nqxCjVcXhlbsRXbGOSY=",
|
||||
version = "v1.0.1-0.20190711162640-ee3c2418e368",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_kit_kit",
|
||||
importpath = "github.com/go-kit/kit",
|
||||
sum = "h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0=",
|
||||
version = "v0.8.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_logfmt_logfmt",
|
||||
importpath = "github.com/go-logfmt/logfmt",
|
||||
sum = "h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=",
|
||||
version = "v0.4.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_go_logr_logr",
|
||||
importpath = "github.com/go-logr/logr",
|
||||
sum = "h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=",
|
||||
version = "v0.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_openapi_inflect",
|
||||
importpath = "github.com/go-openapi/inflect",
|
||||
sum = "h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=",
|
||||
version = "v0.19.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_sql_driver_mysql",
|
||||
importpath = "github.com/go-sql-driver/mysql",
|
||||
sum = "h1:L6V0ANsMIMdLgXly241UXhXNFWYgXbgjHupTAAURrV0=",
|
||||
version = "v1.5.1-0.20200311113236-681ffa848bae",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_go_stack_stack",
|
||||
importpath = "github.com/go-stack/stack",
|
||||
sum = "h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=",
|
||||
version = "v1.8.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_gogo_protobuf",
|
||||
importpath = "github.com/gogo/protobuf",
|
||||
sum = "h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=",
|
||||
version = "v1.2.1",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_golang_glog",
|
||||
importpath = "github.com/golang/glog",
|
||||
sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
|
||||
version = "v0.0.0-20160126235308-23def4e6c14b",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_golang_groupcache",
|
||||
importpath = "github.com/golang/groupcache",
|
||||
sum = "h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=",
|
||||
version = "v0.0.0-20200121045136-8c9f03a8e57e",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_golang_mock",
|
||||
importpath = "github.com/golang/mock",
|
||||
sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=",
|
||||
version = "v1.1.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_golang_protobuf",
|
||||
importpath = "github.com/golang/protobuf",
|
||||
sum = "h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=",
|
||||
version = "v1.4.2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_google_btree",
|
||||
importpath = "github.com/google/btree",
|
||||
sum = "h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_google_go_cmp",
|
||||
importpath = "github.com/google/go-cmp",
|
||||
sum = "h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=",
|
||||
version = "v0.5.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_google_gofuzz",
|
||||
importpath = "github.com/google/gofuzz",
|
||||
sum = "h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_google_uuid",
|
||||
importpath = "github.com/google/uuid",
|
||||
sum = "h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=",
|
||||
version = "v1.1.2",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_gorilla_websocket",
|
||||
importpath = "github.com/gorilla/websocket",
|
||||
sum = "h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=",
|
||||
version = "v1.4.2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_grpc_ecosystem_go_grpc_middleware",
|
||||
importpath = "github.com/grpc-ecosystem/go-grpc-middleware",
|
||||
sum = "h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_grpc_ecosystem_go_grpc_prometheus",
|
||||
importpath = "github.com/grpc-ecosystem/go-grpc-prometheus",
|
||||
sum = "h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=",
|
||||
version = "v1.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_grpc_ecosystem_grpc_gateway",
|
||||
importpath = "github.com/grpc-ecosystem/grpc-gateway",
|
||||
sum = "h1:bM6ZAFZmc/wPFaRDi0d5L7hGEZEx/2u+Tmr2evNHDiI=",
|
||||
version = "v1.9.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_hashicorp_hcl",
|
||||
importpath = "github.com/hashicorp/hcl",
|
||||
sum = "h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_improbable_eng_grpc_web",
|
||||
importpath = "github.com/improbable-eng/grpc-web",
|
||||
sum = "h1:7XqtaBWaOCH0cVGKHyvhtcuo6fgW32Y10yRKrDHFHOc=",
|
||||
version = "v0.13.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_inconshreveable_mousetrap",
|
||||
importpath = "github.com/inconshreveable/mousetrap",
|
||||
sum = "h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_jessevdk_go_flags",
|
||||
importpath = "github.com/jessevdk/go-flags",
|
||||
sum = "h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=",
|
||||
version = "v1.4.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_joho_godotenv",
|
||||
importpath = "github.com/joho/godotenv",
|
||||
sum = "h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=",
|
||||
version = "v1.3.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_jonboulle_clockwork",
|
||||
importpath = "github.com/jonboulle/clockwork",
|
||||
sum = "h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=",
|
||||
version = "v0.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_json_iterator_go",
|
||||
importpath = "github.com/json-iterator/go",
|
||||
sum = "h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=",
|
||||
version = "v1.1.10",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_julienschmidt_httprouter",
|
||||
importpath = "github.com/julienschmidt/httprouter",
|
||||
sum = "h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=",
|
||||
version = "v1.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kisielk_errcheck",
|
||||
importpath = "github.com/kisielk/errcheck",
|
||||
sum = "h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E=",
|
||||
version = "v1.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kisielk_gotool",
|
||||
importpath = "github.com/kisielk/gotool",
|
||||
sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_konsorten_go_windows_terminal_sequences",
|
||||
importpath = "github.com/konsorten/go-windows-terminal-sequences",
|
||||
sum = "h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=",
|
||||
version = "v1.0.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kr_logfmt",
|
||||
importpath = "github.com/kr/logfmt",
|
||||
sum = "h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=",
|
||||
version = "v0.0.0-20140226030751-b84e30acd515",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kr_pretty",
|
||||
importpath = "github.com/kr/pretty",
|
||||
sum = "h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=",
|
||||
version = "v0.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kr_pty",
|
||||
importpath = "github.com/kr/pty",
|
||||
sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=",
|
||||
version = "v1.1.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_kr_text",
|
||||
importpath = "github.com/kr/text",
|
||||
sum = "h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=",
|
||||
version = "v0.1.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_lampjaw_discordclient",
|
||||
importpath = "github.com/lampjaw/discordclient",
|
||||
sum = "h1:jrRFvccla3/+7EMUrQxpdwy0Jy1O3b0IK/k3KqJKoec=",
|
||||
version = "v0.0.0-20200914142129-e3b4f5747970",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_lib_pq",
|
||||
importpath = "github.com/lib/pq",
|
||||
sum = "h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=",
|
||||
version = "v1.8.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_magiconair_properties",
|
||||
importpath = "github.com/magiconair/properties",
|
||||
sum = "h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=",
|
||||
version = "v1.8.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_mattn_go_runewidth",
|
||||
importpath = "github.com/mattn/go-runewidth",
|
||||
sum = "h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=",
|
||||
version = "v0.0.9",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_mattn_go_sqlite3",
|
||||
importpath = "github.com/mattn/go-sqlite3",
|
||||
sum = "h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA=",
|
||||
version = "v1.14.3",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_matttproud_golang_protobuf_extensions",
|
||||
importpath = "github.com/matttproud/golang_protobuf_extensions",
|
||||
sum = "h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=",
|
||||
version = "v1.0.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_mitchellh_go_homedir",
|
||||
importpath = "github.com/mitchellh/go-homedir",
|
||||
sum = "h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=",
|
||||
version = "v1.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_mitchellh_mapstructure",
|
||||
importpath = "github.com/mitchellh/mapstructure",
|
||||
sum = "h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=",
|
||||
version = "v1.3.3",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_modern_go_concurrent",
|
||||
importpath = "github.com/modern-go/concurrent",
|
||||
sum = "h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=",
|
||||
version = "v0.0.0-20180306012644-bacd9c7ef1dd",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_modern_go_reflect2",
|
||||
importpath = "github.com/modern-go/reflect2",
|
||||
sum = "h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=",
|
||||
version = "v1.0.1",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_mwitkow_go_conntrack",
|
||||
importpath = "github.com/mwitkow/go-conntrack",
|
||||
sum = "h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=",
|
||||
version = "v0.0.0-20190716064945-2f068394615f",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_niemeyer_pretty",
|
||||
importpath = "github.com/niemeyer/pretty",
|
||||
sum = "h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=",
|
||||
version = "v0.0.0-20200227124842-a10e7caefd8e",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_oklog_ulid",
|
||||
importpath = "github.com/oklog/ulid",
|
||||
sum = "h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=",
|
||||
version = "v1.3.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_olekukonko_tablewriter",
|
||||
importpath = "github.com/olekukonko/tablewriter",
|
||||
sum = "h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=",
|
||||
version = "v0.0.4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_oneofone_xxhash",
|
||||
importpath = "github.com/OneOfOne/xxhash",
|
||||
sum = "h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=",
|
||||
version = "v1.2.2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_pelletier_go_toml",
|
||||
importpath = "github.com/pelletier/go-toml",
|
||||
sum = "h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=",
|
||||
version = "v1.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_pkg_errors",
|
||||
importpath = "github.com/pkg/errors",
|
||||
sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=",
|
||||
version = "v0.9.1",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_pmezard_go_difflib",
|
||||
importpath = "github.com/pmezard/go-difflib",
|
||||
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_prometheus_client_golang",
|
||||
importpath = "github.com/prometheus/client_golang",
|
||||
sum = "h1:9iH4JKXLzFbOAdtqv/a+j8aewx2Y8lAjAydhbaScPF8=",
|
||||
version = "v0.9.3",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_prometheus_client_model",
|
||||
importpath = "github.com/prometheus/client_model",
|
||||
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
|
||||
version = "v0.0.0-20190812154241-14fe0d1b01d4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_prometheus_common",
|
||||
importpath = "github.com/prometheus/common",
|
||||
sum = "h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM=",
|
||||
version = "v0.4.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_prometheus_procfs",
|
||||
importpath = "github.com/prometheus/procfs",
|
||||
sum = "h1:sofwID9zm4tzrgykg80hfFph1mryUeLRsUfoocVVmRY=",
|
||||
version = "v0.0.0-20190507164030-5867b95ac084",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_prometheus_tsdb",
|
||||
importpath = "github.com/prometheus/tsdb",
|
||||
sum = "h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=",
|
||||
version = "v0.7.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_puerkitobio_goquery",
|
||||
importpath = "github.com/PuerkitoBio/goquery",
|
||||
sum = "h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE=",
|
||||
version = "v1.5.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_rogpeppe_fastuuid",
|
||||
importpath = "github.com/rogpeppe/fastuuid",
|
||||
sum = "h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng=",
|
||||
version = "v0.0.0-20150106093220-6724a57986af",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_roleypoly_db",
|
||||
importpath = "github.com/roleypoly/db",
|
||||
sum = "h1:6As+Zl6a+YeIvpJXWOyDtxHTIP/kZdcYvSDrVkeJRLs=",
|
||||
version = "v0.0.0-20200815123444-57c7f8a08f84",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_rs_cors",
|
||||
importpath = "github.com/rs/cors",
|
||||
sum = "h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=",
|
||||
version = "v1.7.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_russross_blackfriday_v2",
|
||||
importpath = "github.com/russross/blackfriday/v2",
|
||||
sum = "h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=",
|
||||
version = "v2.0.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_shurcool_sanitized_anchor_name",
|
||||
importpath = "github.com/shurcooL/sanitized_anchor_name",
|
||||
sum = "h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_sirupsen_logrus",
|
||||
importpath = "github.com/sirupsen/logrus",
|
||||
sum = "h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=",
|
||||
version = "v1.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_soheilhy_cmux",
|
||||
importpath = "github.com/soheilhy/cmux",
|
||||
sum = "h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=",
|
||||
version = "v0.1.4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spaolacci_murmur3",
|
||||
importpath = "github.com/spaolacci/murmur3",
|
||||
sum = "h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=",
|
||||
version = "v0.0.0-20180118202830-f09979ecbc72",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_afero",
|
||||
importpath = "github.com/spf13/afero",
|
||||
sum = "h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=",
|
||||
version = "v1.1.2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_cast",
|
||||
importpath = "github.com/spf13/cast",
|
||||
sum = "h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=",
|
||||
version = "v1.3.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_cobra",
|
||||
importpath = "github.com/spf13/cobra",
|
||||
sum = "h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_jwalterweatherman",
|
||||
importpath = "github.com/spf13/jwalterweatherman",
|
||||
sum = "h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_pflag",
|
||||
importpath = "github.com/spf13/pflag",
|
||||
sum = "h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=",
|
||||
version = "v1.0.5",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_spf13_viper",
|
||||
importpath = "github.com/spf13/viper",
|
||||
sum = "h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=",
|
||||
version = "v1.4.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_github_stretchr_objx",
|
||||
importpath = "github.com/stretchr/objx",
|
||||
sum = "h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=",
|
||||
version = "v0.2.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_stretchr_testify",
|
||||
importpath = "github.com/stretchr/testify",
|
||||
sum = "h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=",
|
||||
version = "v1.6.1",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_tmc_grpc_websocket_proxy",
|
||||
importpath = "github.com/tmc/grpc-websocket-proxy",
|
||||
sum = "h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=",
|
||||
version = "v0.0.0-20190109142713-0ad062ec5ee5",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_ugorji_go",
|
||||
importpath = "github.com/ugorji/go",
|
||||
sum = "h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=",
|
||||
version = "v1.1.4",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_xiang90_probing",
|
||||
importpath = "github.com/xiang90/probing",
|
||||
sum = "h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=",
|
||||
version = "v0.0.0-20190116061207-43a291ad63a2",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_xordataexchange_crypt",
|
||||
importpath = "github.com/xordataexchange/crypt",
|
||||
sum = "h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow=",
|
||||
version = "v0.0.3-0.20170626215501-b2862e3d0a77",
|
||||
)
|
||||
go_repository(
|
||||
name = "com_github_yuin_goldmark",
|
||||
importpath = "github.com/yuin/goldmark",
|
||||
sum = "h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM=",
|
||||
version = "v1.2.1",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "com_google_cloud_go",
|
||||
importpath = "cloud.google.com/go",
|
||||
sum = "h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=",
|
||||
version = "v0.26.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "in_gopkg_alecthomas_kingpin_v2",
|
||||
importpath = "gopkg.in/alecthomas/kingpin.v2",
|
||||
sum = "h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=",
|
||||
version = "v2.2.6",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "in_gopkg_check_v1",
|
||||
importpath = "gopkg.in/check.v1",
|
||||
sum = "h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=",
|
||||
version = "v1.0.0-20200902074654-038fdea0a05b",
|
||||
)
|
||||
go_repository(
|
||||
name = "in_gopkg_resty_v1",
|
||||
importpath = "gopkg.in/resty.v1",
|
||||
sum = "h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=",
|
||||
version = "v1.12.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "in_gopkg_yaml_v2",
|
||||
importpath = "gopkg.in/yaml.v2",
|
||||
sum = "h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=",
|
||||
version = "v2.2.2",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "in_gopkg_yaml_v3",
|
||||
importpath = "gopkg.in/yaml.v3",
|
||||
sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=",
|
||||
version = "v3.0.0-20200313102051-9f266ea9e77c",
|
||||
)
|
||||
go_repository(
|
||||
name = "io_etcd_go_bbolt",
|
||||
importpath = "go.etcd.io/bbolt",
|
||||
sum = "h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=",
|
||||
version = "v1.3.2",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "io_k8s_klog",
|
||||
importpath = "k8s.io/klog",
|
||||
sum = "h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=",
|
||||
version = "v1.0.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "io_opencensus_go",
|
||||
importpath = "go.opencensus.io",
|
||||
sum = "h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=",
|
||||
version = "v0.22.4",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_google_appengine",
|
||||
importpath = "google.golang.org/appengine",
|
||||
sum = "h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=",
|
||||
version = "v1.4.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_google_genproto",
|
||||
importpath = "google.golang.org/genproto",
|
||||
sum = "h1:2S8dcPkOK9QyAAKa46Cgl//VOCS6ZOsY+iwD3bb9Phg=",
|
||||
version = "v0.0.0-20200921165018-b9da36f5f452",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_google_grpc",
|
||||
importpath = "google.golang.org/grpc",
|
||||
sum = "h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0=",
|
||||
version = "v1.32.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_google_protobuf",
|
||||
importpath = "google.golang.org/protobuf",
|
||||
sum = "h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=",
|
||||
version = "v1.25.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_crypto",
|
||||
importpath = "golang.org/x/crypto",
|
||||
sum = "h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=",
|
||||
version = "v0.0.0-20200820211705-5c72a883971a",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_exp",
|
||||
importpath = "golang.org/x/exp",
|
||||
sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=",
|
||||
version = "v0.0.0-20190121172915-509febef88a4",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_lint",
|
||||
importpath = "golang.org/x/lint",
|
||||
sum = "h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=",
|
||||
version = "v0.0.0-20190409202823-959b441ac422",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_mod",
|
||||
importpath = "golang.org/x/mod",
|
||||
sum = "h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=",
|
||||
version = "v0.3.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_net",
|
||||
importpath = "golang.org/x/net",
|
||||
sum = "h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=",
|
||||
version = "v0.0.0-20200904194848-62affa334b73",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_oauth2",
|
||||
importpath = "golang.org/x/oauth2",
|
||||
sum = "h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=",
|
||||
version = "v0.0.0-20180821212333-d2e6202438be",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_sync",
|
||||
importpath = "golang.org/x/sync",
|
||||
sum = "h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=",
|
||||
version = "v0.0.0-20200625203802-6e8e738ad208",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_sys",
|
||||
importpath = "golang.org/x/sys",
|
||||
sum = "h1:YEu4SMq7D0cmT7CBbXfcH0NZeuChAXwsHe/9XueUO6o=",
|
||||
version = "v0.0.0-20200922070232-aee5d888a860",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_text",
|
||||
importpath = "golang.org/x/text",
|
||||
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
|
||||
version = "v0.3.3",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_time",
|
||||
importpath = "golang.org/x/time",
|
||||
sum = "h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=",
|
||||
version = "v0.0.0-20190308202827-9d24e82272b4",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_tools",
|
||||
importpath = "golang.org/x/tools",
|
||||
sum = "h1:xLt+iB5ksWcZVxqc+g9K41ZHy+6MKWfXCDsjSThnsPA=",
|
||||
version = "v0.0.0-20200904185747-39188db58858",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_golang_x_xerrors",
|
||||
importpath = "golang.org/x/xerrors",
|
||||
sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=",
|
||||
version = "v0.0.0-20200804184101-5ec99f83aff1",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_uber_go_atomic",
|
||||
importpath = "go.uber.org/atomic",
|
||||
sum = "h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=",
|
||||
version = "v1.4.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_uber_go_multierr",
|
||||
importpath = "go.uber.org/multierr",
|
||||
sum = "h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=",
|
||||
version = "v1.1.0",
|
||||
)
|
||||
go_repository(
|
||||
name = "org_uber_go_zap",
|
||||
importpath = "go.uber.org/zap",
|
||||
sum = "h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=",
|
||||
version = "v1.10.0",
|
||||
)
|
26
go.mod
Normal file
26
go.mod
Normal file
|
@ -0,0 +1,26 @@
|
|||
module github.com/roleypoly/roleypoly
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.22.0
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/facebook/ent v0.4.3
|
||||
github.com/golang/protobuf v1.4.2 // indirect
|
||||
github.com/improbable-eng/grpc-web v0.13.0
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/lampjaw/discordclient v0.0.0-20200914142129-e3b4f5747970
|
||||
github.com/lib/pq v1.8.0
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
|
||||
github.com/roleypoly/db v0.0.0-20200815123444-57c7f8a08f84
|
||||
github.com/rs/cors v1.7.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
|
||||
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 // indirect
|
||||
golang.org/x/text v0.3.3 // indirect
|
||||
google.golang.org/genproto v0.0.0-20200921165018-b9da36f5f452 // indirect
|
||||
google.golang.org/grpc v1.32.0
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
|
||||
k8s.io/klog v1.0.0
|
||||
)
|
314
go.sum
Normal file
314
go.sum
Normal file
|
@ -0,0 +1,314 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bwmarrin/discordgo v0.22.0 h1:uBxY1HmlVCsW1IuaPjpCGT6A2DBwRn0nvOguQIxDdFM=
|
||||
github.com/bwmarrin/discordgo v0.22.0/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I=
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/facebook/ent v0.4.3 h1:ds9HENceKzpGBgCRlkZNq6TqBIegwKcF3e5reuV9Z0M=
|
||||
github.com/facebook/ent v0.4.3/go.mod h1:4e/LKv3FFjj/867jPJYCxycZg0aGeEIgkiQ8jv2j6iQ=
|
||||
github.com/facebookincubator/ent v0.3.0 h1:Jht3vZio7eshMo7yaEZJ6LHk4oM8xUCxKNNDj/Kb4fE=
|
||||
github.com/facebookincubator/ent v0.3.0/go.mod h1:0PIsj0mNbnwufO/bqBiQmA1WEdxcYkU+ONxf7PRM9q4=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-bindata/go-bindata v1.0.1-0.20190711162640-ee3c2418e368/go.mod h1:7xCgX1lzlrXPHkfvn3EhumqHkmSlzt8at9q7v0ax19c=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
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-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/improbable-eng/grpc-web v0.13.0 h1:7XqtaBWaOCH0cVGKHyvhtcuo6fgW32Y10yRKrDHFHOc=
|
||||
github.com/improbable-eng/grpc-web v0.13.0/go.mod h1:6hRR09jOEG81ADP5wCQju1z71g6OL4eEvELdran/3cs=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lampjaw/discordclient v0.0.0-20200914142129-e3b4f5747970 h1:jrRFvccla3/+7EMUrQxpdwy0Jy1O3b0IK/k3KqJKoec=
|
||||
github.com/lampjaw/discordclient v0.0.0-20200914142129-e3b4f5747970/go.mod h1:lOfqvGl1HcXws86Sczusw1DyV5d0KHPtTTtdjneekto=
|
||||
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
|
||||
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
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.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
|
||||
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/roleypoly/db v0.0.0-20200815123444-57c7f8a08f84 h1:6As+Zl6a+YeIvpJXWOyDtxHTIP/kZdcYvSDrVkeJRLs=
|
||||
github.com/roleypoly/db v0.0.0-20200815123444-57c7f8a08f84/go.mod h1:dq8nCSix491Pvgq84GcbSgrLNKU8AwTNz3wCSHvTvss=
|
||||
github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
|
||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
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/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA=
|
||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 h1:YEu4SMq7D0cmT7CBbXfcH0NZeuChAXwsHe/9XueUO6o=
|
||||
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200615222825-6aa8f57aacd9 h1:cwgUY+1ja2qxWb2dyaCoixaA66WGWmrijSlxaM+JM/g=
|
||||
golang.org/x/tools v0.0.0-20200615222825-6aa8f57aacd9/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858 h1:xLt+iB5ksWcZVxqc+g9K41ZHy+6MKWfXCDsjSThnsPA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200921165018-b9da36f5f452 h1:2S8dcPkOK9QyAAKa46Cgl//VOCS6ZOsY+iwD3bb9Phg=
|
||||
google.golang.org/genproto v0.0.0-20200921165018-b9da36f5f452/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0=
|
||||
google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
|
||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
4
hack/gazelle.sh
Executable file
4
hack/gazelle.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
bazel run //:gazelle
|
||||
bazel run //:gazelle -- update-repos -from_file=./go.mod --to_macro=deps.bzl%go_repositories -prune=true
|
29
package.json
Normal file
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "roleypoly",
|
||||
"version": "1.0.0",
|
||||
"description": "https://roleypoly.com",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/roleypoly/roleypoly.git"
|
||||
},
|
||||
"author": "Katalina Okano <git@kat.cafe>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/roleypoly/roleypoly/issues"
|
||||
},
|
||||
"homepage": "https://github.com/roleypoly/roleypoly#readme",
|
||||
"dependencies": {
|
||||
"@improbable-eng/grpc-web": "0.13.0",
|
||||
"google-protobuf": "3.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bazel/typescript": "^2.2.0",
|
||||
"prettier": "^2.1.1",
|
||||
"typescript": "^4.0.2",
|
||||
"@roleypoly/ts-protoc-gen": "^1.0.1-promises.1",
|
||||
"@types/google-protobuf": "3.7.3"
|
||||
}
|
||||
}
|
14
src/common/version/BUILD.bazel
Normal file
14
src/common/version/BUILD.bazel
Normal file
|
@ -0,0 +1,14 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "version",
|
||||
srcs = ["version.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/common/version",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "version_test",
|
||||
srcs = ["version_test.go"],
|
||||
embed = [":version"],
|
||||
)
|
21
src/common/version/version.go
Normal file
21
src/common/version/version.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
GitCommit = "unknown"
|
||||
GitBranch = "unknown"
|
||||
BuildDate = "unknown"
|
||||
)
|
||||
|
||||
func StartupInfo(serviceName string) string {
|
||||
return fmt.Sprintf(
|
||||
"Starting %s service.\n Build %s (%s) at %s",
|
||||
serviceName,
|
||||
GitCommit,
|
||||
GitBranch,
|
||||
BuildDate,
|
||||
)
|
||||
}
|
18
src/common/version/version_test.go
Normal file
18
src/common/version/version_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestStartup(t *testing.T) {
|
||||
GitBranch = "test"
|
||||
GitCommit = "e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"
|
||||
BuildDate = time.Now().UTC().Format("2006-01-02T15:04:05.000Z")
|
||||
|
||||
expected := "Starting test service.\n Build e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e (test) at " + BuildDate
|
||||
value := StartupInfo("test")
|
||||
if value != expected {
|
||||
t.Error("Incorrect render, got `", value, "`")
|
||||
}
|
||||
}
|
1
src/db/.gitignore
vendored
Normal file
1
src/db/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.env
|
21
src/db/LICENSE
Normal file
21
src/db/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 roleypoly maintainers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
17
src/db/README.md
Normal file
17
src/db/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# DB
|
||||
|
||||
Roleypoly's DB schemas, connectors, and other useful database admin tools.
|
||||
|
||||
## Tools
|
||||
|
||||
### ent
|
||||
|
||||
ent schema and the files it generates.
|
||||
|
||||
Edit nothing outside of the `schemas` folder, as all others are generated.
|
||||
|
||||
When done editing, do `go generate ./ent` to update generation.
|
||||
|
||||
*Failing to generate files will make CI fail.*
|
||||
|
||||
All schemas must be backwards compatible with previous versions of this library, and be compatible with **CockroachDB**-based Postgres.
|
23
src/db/cmd/db-tool/BUILD.bazel
Normal file
23
src/db/cmd/db-tool/BUILD.bazel
Normal file
|
@ -0,0 +1,23 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "db-tool_lib",
|
||||
srcs = [
|
||||
"import.go",
|
||||
"migrate.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/cmd/db-tool",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"@com_github_lib_pq//:pq",
|
||||
"@com_github_roleypoly_db//ent",
|
||||
"@com_github_roleypoly_db//ent/migrate",
|
||||
"@com_github_roleypoly_db//ent/schema",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "db-tool",
|
||||
embed = [":db-tool_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
59
src/db/cmd/db-tool/Dockerfile
Normal file
59
src/db/cmd/db-tool/Dockerfile
Normal file
|
@ -0,0 +1,59 @@
|
|||
# Accept the Go version for the image to be set as a build argument.
|
||||
# Default to Go 1.12
|
||||
ARG GO_VERSION=1.13
|
||||
|
||||
# First stage: build the executable.
|
||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS builder
|
||||
|
||||
ARG GOPROXY
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETARCH
|
||||
ARG TARGETOS
|
||||
ENV GOPROXY ${GOPROXY}
|
||||
ENV GOOS ${TARGETOS}
|
||||
ENV GOARCH ${TARGETARCH}
|
||||
|
||||
# Create the user and group files that will be used in the running container to
|
||||
# run the process as an unprivileged user.
|
||||
RUN mkdir /user && \
|
||||
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
|
||||
echo 'nobody:x:65534:' > /user/group
|
||||
|
||||
# Install the Certificate-Authority certificates for the app to be able to make
|
||||
# calls to HTTPS endpoints.
|
||||
# Git is required for fetching the dependencies.
|
||||
RUN apk add --no-cache ca-certificates git
|
||||
|
||||
# Set the working directory outside $GOPATH to enable the support for modules.
|
||||
WORKDIR /src
|
||||
|
||||
# Fetch dependencies first; they are less susceptible to change on every build
|
||||
# and will therefore be cached for speeding up the next build
|
||||
COPY ./go.mod ./go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Import the code from the context.
|
||||
COPY ./ ./
|
||||
|
||||
# Build the executable to `/app`. Mark the build as statically linked.
|
||||
RUN CGO_ENABLED=0 go build \
|
||||
-installsuffix 'static' \
|
||||
-o /app ./cmd/db-tool
|
||||
|
||||
# Final stage: the running container.
|
||||
FROM scratch AS final
|
||||
|
||||
# Import the user and group files from the first stage.
|
||||
COPY --from=builder /user/group /user/passwd /etc/
|
||||
|
||||
# Import the Certificate-Authority certificates for enabling HTTPS.
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
# Import the compiled executable from the first stage.
|
||||
COPY --from=builder /app /app
|
||||
|
||||
# Perform any further action as an unprivileged user.
|
||||
USER nobody:nobody
|
||||
|
||||
# Run the compiled binary.
|
||||
ENTRYPOINT ["/app"]
|
14
src/db/cmd/db-tool/docker-compose.yaml
Normal file
14
src/db/cmd/db-tool/docker-compose.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
version: '2'
|
||||
|
||||
services:
|
||||
pg:
|
||||
image: postgres:11-alpine
|
||||
ports:
|
||||
- 5432
|
||||
volumes:
|
||||
- './.data/pg:/var/lib/postgresql/data'
|
||||
environment:
|
||||
POSTGRES_PASSWORD: 19216801
|
||||
POSTGRES_DB: roleypoly
|
||||
POSTGRES_USER: roleypoly
|
||||
POSTGRES_INITDB_ARGS: -A trust
|
104
src/db/cmd/db-tool/import.go
Normal file
104
src/db/cmd/db-tool/import.go
Normal file
|
@ -0,0 +1,104 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
ent "github.com/roleypoly/db/ent"
|
||||
"github.com/roleypoly/db/ent/schema"
|
||||
)
|
||||
|
||||
type v1Category struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Roles []string `json:"roles"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Type string `json:"type"`
|
||||
Position int `json:"position"`
|
||||
}
|
||||
|
||||
type v1Server struct {
|
||||
ID string `json:"id"`
|
||||
Categories []v1Category `json:"categories"`
|
||||
Message string `json:"message"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func fromCategories(cats []v1Category) []schema.Category {
|
||||
out := make([]schema.Category, len(cats))
|
||||
for i, cat := range cats {
|
||||
out[i] = schema.Category{
|
||||
ID: cat.ID,
|
||||
Name: cat.Name,
|
||||
Hidden: cat.Hidden,
|
||||
Type: cat.Type,
|
||||
Position: cat.Position,
|
||||
Roles: cat.Roles,
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func runImport(newDB *ent.Client, oldDB *sql.DB) {
|
||||
ctx := ent.NewContext(context.Background(), newDB)
|
||||
tx, err := newDB.Tx(ctx)
|
||||
|
||||
oldServers, err := oldDB.Query(`SELECT * FROM servers`)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
log.Fatalln("query error", err)
|
||||
}
|
||||
|
||||
defer oldServers.Close()
|
||||
|
||||
for oldServers.Next() == true {
|
||||
var data v1Server
|
||||
|
||||
log.Printf("importing %s\n", data.ID)
|
||||
|
||||
err = oldServers.Scan(&data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
log.Fatalln("data scan error", err)
|
||||
}
|
||||
|
||||
guild := tx.Guild.Create()
|
||||
|
||||
guild.SetMessage(data.Message).
|
||||
SetSnowflake(data.ID).
|
||||
SetCategories(fromCategories(data.Categories)).
|
||||
SetCreateTime(data.CreatedAt)
|
||||
|
||||
ctx := ent.NewContext(context.Background(), newDB)
|
||||
guild.SaveX(ctx)
|
||||
}
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
log.Fatalln("tx commit error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func importFromV1() {
|
||||
log.Println("Import from V1 starting.")
|
||||
|
||||
client, err := ent.Open("postgres", os.Getenv("DB_URL"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
oldClient, err := sql.Open("postgres", os.Getenv("OLD_DB_URL"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
defer oldClient.Close()
|
||||
|
||||
runImport(client, oldClient)
|
||||
log.Println("Import from V1 finished.")
|
||||
}
|
58
src/db/cmd/db-tool/migrate.go
Normal file
58
src/db/cmd/db-tool/migrate.go
Normal file
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
ent "github.com/roleypoly/db/ent"
|
||||
"github.com/roleypoly/db/ent/migrate"
|
||||
)
|
||||
|
||||
func retryMigrate(client *ent.Client) {
|
||||
for i := 0; i < 10; i++ {
|
||||
err := client.Schema.Create(context.Background(), migrate.WithGlobalUniqueID(true))
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Migration failed --", err)
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
log.Fatalln("Migration failed after 20 seconds.")
|
||||
return
|
||||
}
|
||||
|
||||
func doMigrate() {
|
||||
log.Println("Migrations starting.")
|
||||
|
||||
client, err := ent.Open("postgres", os.Getenv("DB_URL"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer client.Close()
|
||||
|
||||
retryMigrate(client)
|
||||
log.Println("Migrations finished.")
|
||||
}
|
||||
|
||||
func main() {
|
||||
tool := os.Args[1]
|
||||
if tool == "" {
|
||||
tool = "migrate"
|
||||
}
|
||||
|
||||
switch tool {
|
||||
case "migrate":
|
||||
doMigrate()
|
||||
case "import":
|
||||
importFromV1()
|
||||
default:
|
||||
log.Fatalln("supported tools: migrate, import")
|
||||
}
|
||||
|
||||
}
|
45
src/db/ent/BUILD.bazel
Normal file
45
src/db/ent/BUILD.bazel
Normal file
|
@ -0,0 +1,45 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "ent",
|
||||
srcs = [
|
||||
"challenge.go",
|
||||
"challenge_create.go",
|
||||
"challenge_delete.go",
|
||||
"challenge_query.go",
|
||||
"challenge_update.go",
|
||||
"client.go",
|
||||
"config.go",
|
||||
"context.go",
|
||||
"ent.go",
|
||||
"generate.go",
|
||||
"guild.go",
|
||||
"guild_create.go",
|
||||
"guild_delete.go",
|
||||
"guild_query.go",
|
||||
"guild_update.go",
|
||||
"mutation.go",
|
||||
"runtime.go",
|
||||
"session.go",
|
||||
"session_create.go",
|
||||
"session_delete.go",
|
||||
"session_query.go",
|
||||
"session_update.go",
|
||||
"tx.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/db/ent/challenge",
|
||||
"//src/db/ent/guild",
|
||||
"//src/db/ent/migrate",
|
||||
"//src/db/ent/predicate",
|
||||
"//src/db/ent/schema",
|
||||
"//src/db/ent/session",
|
||||
"@com_github_facebook_ent//:ent",
|
||||
"@com_github_facebook_ent//dialect",
|
||||
"@com_github_facebook_ent//dialect/sql",
|
||||
"@com_github_facebook_ent//dialect/sql/sqlgraph",
|
||||
"@com_github_facebook_ent//schema/field",
|
||||
],
|
||||
)
|
147
src/db/ent/challenge.go
Normal file
147
src/db/ent/challenge.go
Normal file
|
@ -0,0 +1,147 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
)
|
||||
|
||||
// Challenge is the model entity for the Challenge schema.
|
||||
type Challenge struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime time.Time `json:"update_time,omitempty"`
|
||||
// ChallengeID holds the value of the "challenge_id" field.
|
||||
ChallengeID string `json:"challenge_id,omitempty"`
|
||||
// UserID holds the value of the "user_id" field.
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
// Human holds the value of the "human" field.
|
||||
Human string `json:"human,omitempty"`
|
||||
// Magic holds the value of the "magic" field.
|
||||
Magic string `json:"magic,omitempty"`
|
||||
// ExpiresAt holds the value of the "expires_at" field.
|
||||
ExpiresAt time.Time `json:"expires_at,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Challenge) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullTime{}, // create_time
|
||||
&sql.NullTime{}, // update_time
|
||||
&sql.NullString{}, // challenge_id
|
||||
&sql.NullString{}, // user_id
|
||||
&sql.NullString{}, // human
|
||||
&sql.NullString{}, // magic
|
||||
&sql.NullTime{}, // expires_at
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Challenge fields.
|
||||
func (c *Challenge) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(challenge.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
c.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[0])
|
||||
} else if value.Valid {
|
||||
c.CreateTime = value.Time
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[1])
|
||||
} else if value.Valid {
|
||||
c.UpdateTime = value.Time
|
||||
}
|
||||
if value, ok := values[2].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field challenge_id", values[2])
|
||||
} else if value.Valid {
|
||||
c.ChallengeID = value.String
|
||||
}
|
||||
if value, ok := values[3].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_id", values[3])
|
||||
} else if value.Valid {
|
||||
c.UserID = value.String
|
||||
}
|
||||
if value, ok := values[4].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field human", values[4])
|
||||
} else if value.Valid {
|
||||
c.Human = value.String
|
||||
}
|
||||
if value, ok := values[5].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field magic", values[5])
|
||||
} else if value.Valid {
|
||||
c.Magic = value.String
|
||||
}
|
||||
if value, ok := values[6].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expires_at", values[6])
|
||||
} else if value.Valid {
|
||||
c.ExpiresAt = value.Time
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Challenge.
|
||||
// Note that, you need to call Challenge.Unwrap() before calling this method, if this Challenge
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (c *Challenge) Update() *ChallengeUpdateOne {
|
||||
return (&ChallengeClient{config: c.config}).UpdateOne(c)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (c *Challenge) Unwrap() *Challenge {
|
||||
tx, ok := c.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Challenge is not a transactional entity")
|
||||
}
|
||||
c.config.driver = tx.drv
|
||||
return c
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (c *Challenge) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Challenge(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", c.ID))
|
||||
builder.WriteString(", create_time=")
|
||||
builder.WriteString(c.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", update_time=")
|
||||
builder.WriteString(c.UpdateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", challenge_id=")
|
||||
builder.WriteString(c.ChallengeID)
|
||||
builder.WriteString(", user_id=")
|
||||
builder.WriteString(c.UserID)
|
||||
builder.WriteString(", human=")
|
||||
builder.WriteString(c.Human)
|
||||
builder.WriteString(", magic=")
|
||||
builder.WriteString(c.Magic)
|
||||
builder.WriteString(", expires_at=")
|
||||
builder.WriteString(c.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Challenges is a parsable slice of Challenge.
|
||||
type Challenges []*Challenge
|
||||
|
||||
func (c Challenges) config(cfg config) {
|
||||
for _i := range c {
|
||||
c[_i].config = cfg
|
||||
}
|
||||
}
|
15
src/db/ent/challenge/BUILD.bazel
Normal file
15
src/db/ent/challenge/BUILD.bazel
Normal file
|
@ -0,0 +1,15 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "challenge",
|
||||
srcs = [
|
||||
"challenge.go",
|
||||
"where.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/challenge",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/db/ent/predicate",
|
||||
"@com_github_facebook_ent//dialect/sql",
|
||||
],
|
||||
)
|
54
src/db/ent/challenge/challenge.go
Normal file
54
src/db/ent/challenge/challenge.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package challenge
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the challenge type in the database.
|
||||
Label = "challenge"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldChallengeID holds the string denoting the challenge_id field in the database.
|
||||
FieldChallengeID = "challenge_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldHuman holds the string denoting the human field in the database.
|
||||
FieldHuman = "human"
|
||||
// FieldMagic holds the string denoting the magic field in the database.
|
||||
FieldMagic = "magic"
|
||||
// FieldExpiresAt holds the string denoting the expires_at field in the database.
|
||||
FieldExpiresAt = "expires_at"
|
||||
|
||||
// Table holds the table name of the challenge in the database.
|
||||
Table = "challenges"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for challenge fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldChallengeID,
|
||||
FieldUserID,
|
||||
FieldHuman,
|
||||
FieldMagic,
|
||||
FieldExpiresAt,
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
DefaultCreateTime func() time.Time
|
||||
// DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
DefaultUpdateTime func() time.Time
|
||||
// UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
UpdateDefaultUpdateTime func() time.Time
|
||||
// DefaultExpiresAt holds the default value on creation for the expires_at field.
|
||||
DefaultExpiresAt func() time.Time
|
||||
)
|
846
src/db/ent/challenge/where.go
Normal file
846
src/db/ent/challenge/where.go
Normal file
|
@ -0,0 +1,846 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package challenge
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeID applies equality check predicate on the "challenge_id" field. It's identical to ChallengeIDEQ.
|
||||
func ChallengeID(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||
func UserID(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Human applies equality check predicate on the "human" field. It's identical to HumanEQ.
|
||||
func Human(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Magic applies equality check predicate on the "magic" field. It's identical to MagicEQ.
|
||||
func Magic(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
|
||||
func ExpiresAt(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDEQ applies the EQ predicate on the "challenge_id" field.
|
||||
func ChallengeIDEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDNEQ applies the NEQ predicate on the "challenge_id" field.
|
||||
func ChallengeIDNEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDIn applies the In predicate on the "challenge_id" field.
|
||||
func ChallengeIDIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldChallengeID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDNotIn applies the NotIn predicate on the "challenge_id" field.
|
||||
func ChallengeIDNotIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldChallengeID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDGT applies the GT predicate on the "challenge_id" field.
|
||||
func ChallengeIDGT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDGTE applies the GTE predicate on the "challenge_id" field.
|
||||
func ChallengeIDGTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDLT applies the LT predicate on the "challenge_id" field.
|
||||
func ChallengeIDLT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDLTE applies the LTE predicate on the "challenge_id" field.
|
||||
func ChallengeIDLTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDContains applies the Contains predicate on the "challenge_id" field.
|
||||
func ChallengeIDContains(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDHasPrefix applies the HasPrefix predicate on the "challenge_id" field.
|
||||
func ChallengeIDHasPrefix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDHasSuffix applies the HasSuffix predicate on the "challenge_id" field.
|
||||
func ChallengeIDHasSuffix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDEqualFold applies the EqualFold predicate on the "challenge_id" field.
|
||||
func ChallengeIDEqualFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ChallengeIDContainsFold applies the ContainsFold predicate on the "challenge_id" field.
|
||||
func ChallengeIDContainsFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldChallengeID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||
func UserIDEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||
func UserIDNEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDIn applies the In predicate on the "user_id" field.
|
||||
func UserIDIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldUserID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||
func UserIDNotIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldUserID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDGT applies the GT predicate on the "user_id" field.
|
||||
func UserIDGT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDGTE applies the GTE predicate on the "user_id" field.
|
||||
func UserIDGTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDLT applies the LT predicate on the "user_id" field.
|
||||
func UserIDLT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDLTE applies the LTE predicate on the "user_id" field.
|
||||
func UserIDLTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDContains applies the Contains predicate on the "user_id" field.
|
||||
func UserIDContains(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
|
||||
func UserIDHasPrefix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
|
||||
func UserIDHasSuffix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
|
||||
func UserIDEqualFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
|
||||
func UserIDContainsFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanEQ applies the EQ predicate on the "human" field.
|
||||
func HumanEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanNEQ applies the NEQ predicate on the "human" field.
|
||||
func HumanNEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanIn applies the In predicate on the "human" field.
|
||||
func HumanIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldHuman), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanNotIn applies the NotIn predicate on the "human" field.
|
||||
func HumanNotIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldHuman), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanGT applies the GT predicate on the "human" field.
|
||||
func HumanGT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanGTE applies the GTE predicate on the "human" field.
|
||||
func HumanGTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanLT applies the LT predicate on the "human" field.
|
||||
func HumanLT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanLTE applies the LTE predicate on the "human" field.
|
||||
func HumanLTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanContains applies the Contains predicate on the "human" field.
|
||||
func HumanContains(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanHasPrefix applies the HasPrefix predicate on the "human" field.
|
||||
func HumanHasPrefix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanHasSuffix applies the HasSuffix predicate on the "human" field.
|
||||
func HumanHasSuffix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanEqualFold applies the EqualFold predicate on the "human" field.
|
||||
func HumanEqualFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// HumanContainsFold applies the ContainsFold predicate on the "human" field.
|
||||
func HumanContainsFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldHuman), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicEQ applies the EQ predicate on the "magic" field.
|
||||
func MagicEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicNEQ applies the NEQ predicate on the "magic" field.
|
||||
func MagicNEQ(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicIn applies the In predicate on the "magic" field.
|
||||
func MagicIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldMagic), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicNotIn applies the NotIn predicate on the "magic" field.
|
||||
func MagicNotIn(vs ...string) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldMagic), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicGT applies the GT predicate on the "magic" field.
|
||||
func MagicGT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicGTE applies the GTE predicate on the "magic" field.
|
||||
func MagicGTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicLT applies the LT predicate on the "magic" field.
|
||||
func MagicLT(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicLTE applies the LTE predicate on the "magic" field.
|
||||
func MagicLTE(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicContains applies the Contains predicate on the "magic" field.
|
||||
func MagicContains(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicHasPrefix applies the HasPrefix predicate on the "magic" field.
|
||||
func MagicHasPrefix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicHasSuffix applies the HasSuffix predicate on the "magic" field.
|
||||
func MagicHasSuffix(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicEqualFold applies the EqualFold predicate on the "magic" field.
|
||||
func MagicEqualFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MagicContainsFold applies the ContainsFold predicate on the "magic" field.
|
||||
func MagicContainsFold(v string) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldMagic), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
|
||||
func ExpiresAtEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
|
||||
func ExpiresAtNEQ(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtIn applies the In predicate on the "expires_at" field.
|
||||
func ExpiresAtIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldExpiresAt), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
|
||||
func ExpiresAtNotIn(vs ...time.Time) predicate.Challenge {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldExpiresAt), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtGT applies the GT predicate on the "expires_at" field.
|
||||
func ExpiresAtGT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
|
||||
func ExpiresAtGTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtLT applies the LT predicate on the "expires_at" field.
|
||||
func ExpiresAtLT(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
|
||||
func ExpiresAtLTE(v time.Time) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Challenge) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Challenge) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Challenge) predicate.Challenge {
|
||||
return predicate.Challenge(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
310
src/db/ent/challenge_create.go
Normal file
310
src/db/ent/challenge_create.go
Normal file
|
@ -0,0 +1,310 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
)
|
||||
|
||||
// ChallengeCreate is the builder for creating a Challenge entity.
|
||||
type ChallengeCreate struct {
|
||||
config
|
||||
mutation *ChallengeMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreateTime sets the create_time field.
|
||||
func (cc *ChallengeCreate) SetCreateTime(t time.Time) *ChallengeCreate {
|
||||
cc.mutation.SetCreateTime(t)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the create_time field if the given value is not nil.
|
||||
func (cc *ChallengeCreate) SetNillableCreateTime(t *time.Time) *ChallengeCreate {
|
||||
if t != nil {
|
||||
cc.SetCreateTime(*t)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the update_time field.
|
||||
func (cc *ChallengeCreate) SetUpdateTime(t time.Time) *ChallengeCreate {
|
||||
cc.mutation.SetUpdateTime(t)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableUpdateTime sets the update_time field if the given value is not nil.
|
||||
func (cc *ChallengeCreate) SetNillableUpdateTime(t *time.Time) *ChallengeCreate {
|
||||
if t != nil {
|
||||
cc.SetUpdateTime(*t)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetChallengeID sets the challenge_id field.
|
||||
func (cc *ChallengeCreate) SetChallengeID(s string) *ChallengeCreate {
|
||||
cc.mutation.SetChallengeID(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetUserID sets the user_id field.
|
||||
func (cc *ChallengeCreate) SetUserID(s string) *ChallengeCreate {
|
||||
cc.mutation.SetUserID(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetHuman sets the human field.
|
||||
func (cc *ChallengeCreate) SetHuman(s string) *ChallengeCreate {
|
||||
cc.mutation.SetHuman(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetMagic sets the magic field.
|
||||
func (cc *ChallengeCreate) SetMagic(s string) *ChallengeCreate {
|
||||
cc.mutation.SetMagic(s)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the expires_at field.
|
||||
func (cc *ChallengeCreate) SetExpiresAt(t time.Time) *ChallengeCreate {
|
||||
cc.mutation.SetExpiresAt(t)
|
||||
return cc
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the expires_at field if the given value is not nil.
|
||||
func (cc *ChallengeCreate) SetNillableExpiresAt(t *time.Time) *ChallengeCreate {
|
||||
if t != nil {
|
||||
cc.SetExpiresAt(*t)
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// Mutation returns the ChallengeMutation object of the builder.
|
||||
func (cc *ChallengeCreate) Mutation() *ChallengeMutation {
|
||||
return cc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Challenge in the database.
|
||||
func (cc *ChallengeCreate) Save(ctx context.Context) (*Challenge, error) {
|
||||
if err := cc.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Challenge
|
||||
)
|
||||
if len(cc.hooks) == 0 {
|
||||
node, err = cc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
cc.mutation = mutation
|
||||
node, err = cc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(cc.hooks) - 1; i >= 0; i-- {
|
||||
mut = cc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (cc *ChallengeCreate) SaveX(ctx context.Context) *Challenge {
|
||||
v, err := cc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (cc *ChallengeCreate) preSave() error {
|
||||
if _, ok := cc.mutation.CreateTime(); !ok {
|
||||
v := challenge.DefaultCreateTime()
|
||||
cc.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := cc.mutation.UpdateTime(); !ok {
|
||||
v := challenge.DefaultUpdateTime()
|
||||
cc.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := cc.mutation.ChallengeID(); !ok {
|
||||
return &ValidationError{Name: "challenge_id", err: errors.New("ent: missing required field \"challenge_id\"")}
|
||||
}
|
||||
if _, ok := cc.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New("ent: missing required field \"user_id\"")}
|
||||
}
|
||||
if _, ok := cc.mutation.Human(); !ok {
|
||||
return &ValidationError{Name: "human", err: errors.New("ent: missing required field \"human\"")}
|
||||
}
|
||||
if _, ok := cc.mutation.Magic(); !ok {
|
||||
return &ValidationError{Name: "magic", err: errors.New("ent: missing required field \"magic\"")}
|
||||
}
|
||||
if _, ok := cc.mutation.ExpiresAt(); !ok {
|
||||
v := challenge.DefaultExpiresAt()
|
||||
cc.mutation.SetExpiresAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cc *ChallengeCreate) sqlSave(ctx context.Context) (*Challenge, error) {
|
||||
c, _spec := cc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
c.ID = int(id)
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (cc *ChallengeCreate) createSpec() (*Challenge, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
c = &Challenge{config: cc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: challenge.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: challenge.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := cc.mutation.CreateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: challenge.FieldCreateTime,
|
||||
})
|
||||
c.CreateTime = value
|
||||
}
|
||||
if value, ok := cc.mutation.UpdateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: challenge.FieldUpdateTime,
|
||||
})
|
||||
c.UpdateTime = value
|
||||
}
|
||||
if value, ok := cc.mutation.ChallengeID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: challenge.FieldChallengeID,
|
||||
})
|
||||
c.ChallengeID = value
|
||||
}
|
||||
if value, ok := cc.mutation.UserID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: challenge.FieldUserID,
|
||||
})
|
||||
c.UserID = value
|
||||
}
|
||||
if value, ok := cc.mutation.Human(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: challenge.FieldHuman,
|
||||
})
|
||||
c.Human = value
|
||||
}
|
||||
if value, ok := cc.mutation.Magic(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: challenge.FieldMagic,
|
||||
})
|
||||
c.Magic = value
|
||||
}
|
||||
if value, ok := cc.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: challenge.FieldExpiresAt,
|
||||
})
|
||||
c.ExpiresAt = value
|
||||
}
|
||||
return c, _spec
|
||||
}
|
||||
|
||||
// ChallengeCreateBulk is the builder for creating a bulk of Challenge entities.
|
||||
type ChallengeCreateBulk struct {
|
||||
config
|
||||
builders []*ChallengeCreate
|
||||
}
|
||||
|
||||
// Save creates the Challenge entities in the database.
|
||||
func (ccb *ChallengeCreateBulk) Save(ctx context.Context) ([]*Challenge, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ccb.builders))
|
||||
nodes := make([]*Challenge, len(ccb.builders))
|
||||
mutators := make([]Mutator, len(ccb.builders))
|
||||
for i := range ccb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ccb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
if err := builder.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation, ok := m.(*ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, ccb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ccb *ChallengeCreateBulk) SaveX(ctx context.Context) []*Challenge {
|
||||
v, err := ccb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
109
src/db/ent/challenge_delete.go
Normal file
109
src/db/ent/challenge_delete.go
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ChallengeDelete is the builder for deleting a Challenge entity.
|
||||
type ChallengeDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ChallengeMutation
|
||||
predicates []predicate.Challenge
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (cd *ChallengeDelete) Where(ps ...predicate.Challenge) *ChallengeDelete {
|
||||
cd.predicates = append(cd.predicates, ps...)
|
||||
return cd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (cd *ChallengeDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(cd.hooks) == 0 {
|
||||
affected, err = cd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
cd.mutation = mutation
|
||||
affected, err = cd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(cd.hooks) - 1; i >= 0; i-- {
|
||||
mut = cd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cd *ChallengeDelete) ExecX(ctx context.Context) int {
|
||||
n, err := cd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (cd *ChallengeDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: challenge.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: challenge.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := cd.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, cd.driver, _spec)
|
||||
}
|
||||
|
||||
// ChallengeDeleteOne is the builder for deleting a single Challenge entity.
|
||||
type ChallengeDeleteOne struct {
|
||||
cd *ChallengeDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (cdo *ChallengeDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := cdo.cd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{challenge.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cdo *ChallengeDeleteOne) ExecX(ctx context.Context) {
|
||||
cdo.cd.ExecX(ctx)
|
||||
}
|
866
src/db/ent/challenge_query.go
Normal file
866
src/db/ent/challenge_query.go
Normal file
|
@ -0,0 +1,866 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ChallengeQuery is the builder for querying Challenge entities.
|
||||
type ChallengeQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.Challenge
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (cq *ChallengeQuery) Where(ps ...predicate.Challenge) *ChallengeQuery {
|
||||
cq.predicates = append(cq.predicates, ps...)
|
||||
return cq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (cq *ChallengeQuery) Limit(limit int) *ChallengeQuery {
|
||||
cq.limit = &limit
|
||||
return cq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (cq *ChallengeQuery) Offset(offset int) *ChallengeQuery {
|
||||
cq.offset = &offset
|
||||
return cq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (cq *ChallengeQuery) Order(o ...OrderFunc) *ChallengeQuery {
|
||||
cq.order = append(cq.order, o...)
|
||||
return cq
|
||||
}
|
||||
|
||||
// First returns the first Challenge entity in the query. Returns *NotFoundError when no challenge was found.
|
||||
func (cq *ChallengeQuery) First(ctx context.Context) (*Challenge, error) {
|
||||
cs, err := cq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(cs) == 0 {
|
||||
return nil, &NotFoundError{challenge.Label}
|
||||
}
|
||||
return cs[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) FirstX(ctx context.Context) *Challenge {
|
||||
c, err := cq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// FirstID returns the first Challenge id in the query. Returns *NotFoundError when no id was found.
|
||||
func (cq *ChallengeQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = cq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{challenge.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstXID is like FirstID, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) FirstXID(ctx context.Context) int {
|
||||
id, err := cq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only Challenge entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (cq *ChallengeQuery) Only(ctx context.Context) (*Challenge, error) {
|
||||
cs, err := cq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(cs) {
|
||||
case 1:
|
||||
return cs[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{challenge.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{challenge.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) OnlyX(ctx context.Context) *Challenge {
|
||||
c, err := cq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// OnlyID returns the only Challenge id in the query, returns an error if not exactly one id was returned.
|
||||
func (cq *ChallengeQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = cq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = &NotSingularError{challenge.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := cq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Challenges.
|
||||
func (cq *ChallengeQuery) All(ctx context.Context) ([]*Challenge, error) {
|
||||
if err := cq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) AllX(ctx context.Context) []*Challenge {
|
||||
cs, err := cq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return cs
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Challenge ids.
|
||||
func (cq *ChallengeQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := cq.Select(challenge.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := cq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (cq *ChallengeQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := cq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return cq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) CountX(ctx context.Context) int {
|
||||
count, err := cq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (cq *ChallengeQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := cq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return cq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (cq *ChallengeQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := cq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (cq *ChallengeQuery) Clone() *ChallengeQuery {
|
||||
return &ChallengeQuery{
|
||||
config: cq.config,
|
||||
limit: cq.limit,
|
||||
offset: cq.offset,
|
||||
order: append([]OrderFunc{}, cq.order...),
|
||||
unique: append([]string{}, cq.unique...),
|
||||
predicates: append([]predicate.Challenge{}, cq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: cq.sql.Clone(),
|
||||
path: cq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy 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 {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Challenge.Query().
|
||||
// GroupBy(challenge.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (cq *ChallengeQuery) GroupBy(field string, fields ...string) *ChallengeGroupBy {
|
||||
group := &ChallengeGroupBy{config: cq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := cq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Challenge.Query().
|
||||
// Select(challenge.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (cq *ChallengeQuery) Select(field string, fields ...string) *ChallengeSelect {
|
||||
selector := &ChallengeSelect{config: cq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := cq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) prepareQuery(ctx context.Context) error {
|
||||
if cq.path != nil {
|
||||
prev, err := cq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) sqlAll(ctx context.Context) ([]*Challenge, error) {
|
||||
var (
|
||||
nodes = []*Challenge{}
|
||||
_spec = cq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &Challenge{config: cq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, cq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := cq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, cq.driver, _spec)
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := cq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: challenge.Table,
|
||||
Columns: challenge.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: challenge.FieldID,
|
||||
},
|
||||
},
|
||||
From: cq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := cq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := cq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := cq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := cq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (cq *ChallengeQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(cq.driver.Dialect())
|
||||
t1 := builder.Table(challenge.Table)
|
||||
selector := builder.Select(t1.Columns(challenge.Columns...)...).From(t1)
|
||||
if cq.sql != nil {
|
||||
selector = cq.sql
|
||||
selector.Select(selector.Columns(challenge.Columns...)...)
|
||||
}
|
||||
for _, p := range cq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range cq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := cq.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 := cq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// ChallengeGroupBy is the builder for group-by Challenge entities.
|
||||
type ChallengeGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (cgb *ChallengeGroupBy) Aggregate(fns ...AggregateFunc) *ChallengeGroupBy {
|
||||
cgb.fns = append(cgb.fns, fns...)
|
||||
return cgb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (cgb *ChallengeGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := cgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cgb.sql = query
|
||||
return cgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := cgb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(cgb.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := cgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := cgb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = cgb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := cgb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(cgb.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := cgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := cgb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = cgb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := cgb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(cgb.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := cgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := cgb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = cgb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := cgb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(cgb.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := cgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := cgb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (cgb *ChallengeGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = cgb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (cgb *ChallengeGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := cgb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (cgb *ChallengeGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := cgb.sqlQuery().Query()
|
||||
if err := cgb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (cgb *ChallengeGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := cgb.sql
|
||||
columns := make([]string, 0, len(cgb.fields)+len(cgb.fns))
|
||||
columns = append(columns, cgb.fields...)
|
||||
for _, fn := range cgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(cgb.fields...)
|
||||
}
|
||||
|
||||
// ChallengeSelect is the builder for select fields of Challenge entities.
|
||||
type ChallengeSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (cs *ChallengeSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := cs.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cs.sql = query
|
||||
return cs.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := cs.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(cs.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := cs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := cs.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = cs.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) StringX(ctx context.Context) string {
|
||||
v, err := cs.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(cs.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := cs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := cs.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = cs.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) IntX(ctx context.Context) int {
|
||||
v, err := cs.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(cs.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := cs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := cs.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = cs.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := cs.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(cs.fields) > 1 {
|
||||
return nil, errors.New("ent: ChallengeSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := cs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := cs.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (cs *ChallengeSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = cs.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{challenge.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: ChallengeSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (cs *ChallengeSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := cs.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (cs *ChallengeSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := cs.sqlQuery().Query()
|
||||
if err := cs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (cs *ChallengeSelect) sqlQuery() sql.Querier {
|
||||
selector := cs.sql
|
||||
selector.Select(selector.Columns(cs.fields...)...)
|
||||
return selector
|
||||
}
|
228
src/db/ent/challenge_update.go
Normal file
228
src/db/ent/challenge_update.go
Normal file
|
@ -0,0 +1,228 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ChallengeUpdate is the builder for updating Challenge entities.
|
||||
type ChallengeUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ChallengeMutation
|
||||
predicates []predicate.Challenge
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (cu *ChallengeUpdate) Where(ps ...predicate.Challenge) *ChallengeUpdate {
|
||||
cu.predicates = append(cu.predicates, ps...)
|
||||
return cu
|
||||
}
|
||||
|
||||
// Mutation returns the ChallengeMutation object of the builder.
|
||||
func (cu *ChallengeUpdate) Mutation() *ChallengeMutation {
|
||||
return cu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (cu *ChallengeUpdate) Save(ctx context.Context) (int, error) {
|
||||
if _, ok := cu.mutation.UpdateTime(); !ok {
|
||||
v := challenge.UpdateDefaultUpdateTime()
|
||||
cu.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(cu.hooks) == 0 {
|
||||
affected, err = cu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
cu.mutation = mutation
|
||||
affected, err = cu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(cu.hooks) - 1; i >= 0; i-- {
|
||||
mut = cu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cu *ChallengeUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := cu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cu *ChallengeUpdate) Exec(ctx context.Context) error {
|
||||
_, err := cu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cu *ChallengeUpdate) ExecX(ctx context.Context) {
|
||||
if err := cu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (cu *ChallengeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: challenge.Table,
|
||||
Columns: challenge.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: challenge.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := cu.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cu.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: challenge.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{challenge.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// ChallengeUpdateOne is the builder for updating a single Challenge entity.
|
||||
type ChallengeUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ChallengeMutation
|
||||
}
|
||||
|
||||
// Mutation returns the ChallengeMutation object of the builder.
|
||||
func (cuo *ChallengeUpdateOne) Mutation() *ChallengeMutation {
|
||||
return cuo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (cuo *ChallengeUpdateOne) Save(ctx context.Context) (*Challenge, error) {
|
||||
if _, ok := cuo.mutation.UpdateTime(); !ok {
|
||||
v := challenge.UpdateDefaultUpdateTime()
|
||||
cuo.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Challenge
|
||||
)
|
||||
if len(cuo.hooks) == 0 {
|
||||
node, err = cuo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
cuo.mutation = mutation
|
||||
node, err = cuo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(cuo.hooks) - 1; i >= 0; i-- {
|
||||
mut = cuo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, cuo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cuo *ChallengeUpdateOne) SaveX(ctx context.Context) *Challenge {
|
||||
c, err := cuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (cuo *ChallengeUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := cuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cuo *ChallengeUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := cuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (cuo *ChallengeUpdateOne) sqlSave(ctx context.Context) (c *Challenge, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: challenge.Table,
|
||||
Columns: challenge.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: challenge.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := cuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Challenge.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := cuo.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: challenge.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
c = &Challenge{config: cuo.config}
|
||||
_spec.Assign = c.assignValues
|
||||
_spec.ScanValues = c.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{challenge.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}
|
395
src/db/ent/client.go
Normal file
395
src/db/ent/client.go
Normal file
|
@ -0,0 +1,395 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/migrate"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
type Client struct {
|
||||
config
|
||||
// Schema is the client for creating, migrating and dropping schema.
|
||||
Schema *migrate.Schema
|
||||
// Challenge is the client for interacting with the Challenge builders.
|
||||
Challenge *ChallengeClient
|
||||
// Guild is the client for interacting with the Guild builders.
|
||||
Guild *GuildClient
|
||||
// Session is the client for interacting with the Session builders.
|
||||
Session *SessionClient
|
||||
}
|
||||
|
||||
// NewClient creates a new client configured with the given options.
|
||||
func NewClient(opts ...Option) *Client {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}}
|
||||
cfg.options(opts...)
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
func (c *Client) init() {
|
||||
c.Schema = migrate.NewSchema(c.driver)
|
||||
c.Challenge = NewChallengeClient(c.config)
|
||||
c.Guild = NewGuildClient(c.config)
|
||||
c.Session = NewSessionClient(c.config)
|
||||
}
|
||||
|
||||
// Open opens a database/sql.DB specified by the driver name and
|
||||
// the data source name, and returns a new client attached to it.
|
||||
// Optional parameters can be added for configuring the client.
|
||||
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
||||
switch driverName {
|
||||
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
||||
drv, err := sql.Open(driverName, dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewClient(append(options, Driver(drv))...), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
||||
}
|
||||
}
|
||||
|
||||
// Tx returns a new transactional client. The provided context
|
||||
// is used until the transaction is committed or rolled back.
|
||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
||||
}
|
||||
tx, err := newTx(ctx, c.driver)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
|
||||
}
|
||||
cfg := config{driver: tx, log: c.log, debug: c.debug, hooks: c.hooks}
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
Challenge: NewChallengeClient(cfg),
|
||||
Guild: NewGuildClient(cfg),
|
||||
Session: NewSessionClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// BeginTx returns a transactional client with options.
|
||||
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
||||
}
|
||||
tx, err := c.driver.(*sql.Driver).BeginTx(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ent: starting a transaction: %v", err)
|
||||
}
|
||||
cfg := config{driver: &txDriver{tx: tx, drv: c.driver}, log: c.log, debug: c.debug, hooks: c.hooks}
|
||||
return &Tx{
|
||||
config: cfg,
|
||||
Challenge: NewChallengeClient(cfg),
|
||||
Guild: NewGuildClient(cfg),
|
||||
Session: NewSessionClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// Challenge.
|
||||
// Query().
|
||||
// Count(ctx)
|
||||
//
|
||||
func (c *Client) Debug() *Client {
|
||||
if c.debug {
|
||||
return c
|
||||
}
|
||||
cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true, hooks: c.hooks}
|
||||
client := &Client{config: cfg}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
|
||||
// Close closes the database connection and prevents new queries from starting.
|
||||
func (c *Client) Close() error {
|
||||
return c.driver.Close()
|
||||
}
|
||||
|
||||
// Use adds the mutation hooks to all the entity clients.
|
||||
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
c.Challenge.Use(hooks...)
|
||||
c.Guild.Use(hooks...)
|
||||
c.Session.Use(hooks...)
|
||||
}
|
||||
|
||||
// ChallengeClient is a client for the Challenge schema.
|
||||
type ChallengeClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewChallengeClient returns a client for the Challenge from the given config.
|
||||
func NewChallengeClient(c config) *ChallengeClient {
|
||||
return &ChallengeClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `challenge.Hooks(f(g(h())))`.
|
||||
func (c *ChallengeClient) Use(hooks ...Hook) {
|
||||
c.hooks.Challenge = append(c.hooks.Challenge, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for Challenge.
|
||||
func (c *ChallengeClient) Create() *ChallengeCreate {
|
||||
mutation := newChallengeMutation(c.config, OpCreate)
|
||||
return &ChallengeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of Challenge entities.
|
||||
func (c *ChallengeClient) CreateBulk(builders ...*ChallengeCreate) *ChallengeCreateBulk {
|
||||
return &ChallengeCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Challenge.
|
||||
func (c *ChallengeClient) Update() *ChallengeUpdate {
|
||||
mutation := newChallengeMutation(c.config, OpUpdate)
|
||||
return &ChallengeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *ChallengeClient) UpdateOne(ch *Challenge) *ChallengeUpdateOne {
|
||||
mutation := newChallengeMutation(c.config, OpUpdateOne, withChallenge(ch))
|
||||
return &ChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *ChallengeClient) UpdateOneID(id int) *ChallengeUpdateOne {
|
||||
mutation := newChallengeMutation(c.config, OpUpdateOne, withChallengeID(id))
|
||||
return &ChallengeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Challenge.
|
||||
func (c *ChallengeClient) Delete() *ChallengeDelete {
|
||||
mutation := newChallengeMutation(c.config, OpDelete)
|
||||
return &ChallengeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *ChallengeClient) DeleteOne(ch *Challenge) *ChallengeDeleteOne {
|
||||
return c.DeleteOneID(ch.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *ChallengeClient) DeleteOneID(id int) *ChallengeDeleteOne {
|
||||
builder := c.Delete().Where(challenge.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &ChallengeDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Challenge.
|
||||
func (c *ChallengeClient) Query() *ChallengeQuery {
|
||||
return &ChallengeQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a Challenge entity by its id.
|
||||
func (c *ChallengeClient) Get(ctx context.Context, id int) (*Challenge, error) {
|
||||
return c.Query().Where(challenge.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *ChallengeClient) GetX(ctx context.Context, id int) *Challenge {
|
||||
ch, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ch
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ChallengeClient) Hooks() []Hook {
|
||||
return c.hooks.Challenge
|
||||
}
|
||||
|
||||
// GuildClient is a client for the Guild schema.
|
||||
type GuildClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewGuildClient returns a client for the Guild from the given config.
|
||||
func NewGuildClient(c config) *GuildClient {
|
||||
return &GuildClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `guild.Hooks(f(g(h())))`.
|
||||
func (c *GuildClient) Use(hooks ...Hook) {
|
||||
c.hooks.Guild = append(c.hooks.Guild, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for Guild.
|
||||
func (c *GuildClient) Create() *GuildCreate {
|
||||
mutation := newGuildMutation(c.config, OpCreate)
|
||||
return &GuildCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of Guild entities.
|
||||
func (c *GuildClient) CreateBulk(builders ...*GuildCreate) *GuildCreateBulk {
|
||||
return &GuildCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Guild.
|
||||
func (c *GuildClient) Update() *GuildUpdate {
|
||||
mutation := newGuildMutation(c.config, OpUpdate)
|
||||
return &GuildUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *GuildClient) UpdateOne(gu *Guild) *GuildUpdateOne {
|
||||
mutation := newGuildMutation(c.config, OpUpdateOne, withGuild(gu))
|
||||
return &GuildUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *GuildClient) UpdateOneID(id int) *GuildUpdateOne {
|
||||
mutation := newGuildMutation(c.config, OpUpdateOne, withGuildID(id))
|
||||
return &GuildUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Guild.
|
||||
func (c *GuildClient) Delete() *GuildDelete {
|
||||
mutation := newGuildMutation(c.config, OpDelete)
|
||||
return &GuildDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *GuildClient) DeleteOne(gu *Guild) *GuildDeleteOne {
|
||||
return c.DeleteOneID(gu.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *GuildClient) DeleteOneID(id int) *GuildDeleteOne {
|
||||
builder := c.Delete().Where(guild.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &GuildDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Guild.
|
||||
func (c *GuildClient) Query() *GuildQuery {
|
||||
return &GuildQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a Guild entity by its id.
|
||||
func (c *GuildClient) Get(ctx context.Context, id int) (*Guild, error) {
|
||||
return c.Query().Where(guild.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *GuildClient) GetX(ctx context.Context, id int) *Guild {
|
||||
gu, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return gu
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *GuildClient) Hooks() []Hook {
|
||||
return c.hooks.Guild
|
||||
}
|
||||
|
||||
// SessionClient is a client for the Session schema.
|
||||
type SessionClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSessionClient returns a client for the Session from the given config.
|
||||
func NewSessionClient(c config) *SessionClient {
|
||||
return &SessionClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `session.Hooks(f(g(h())))`.
|
||||
func (c *SessionClient) Use(hooks ...Hook) {
|
||||
c.hooks.Session = append(c.hooks.Session, hooks...)
|
||||
}
|
||||
|
||||
// Create returns a create builder for Session.
|
||||
func (c *SessionClient) Create() *SessionCreate {
|
||||
mutation := newSessionMutation(c.config, OpCreate)
|
||||
return &SessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// BulkCreate returns a builder for creating a bulk of Session entities.
|
||||
func (c *SessionClient) CreateBulk(builders ...*SessionCreate) *SessionCreateBulk {
|
||||
return &SessionCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Session.
|
||||
func (c *SessionClient) Update() *SessionUpdate {
|
||||
mutation := newSessionMutation(c.config, OpUpdate)
|
||||
return &SessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SessionClient) UpdateOne(s *Session) *SessionUpdateOne {
|
||||
mutation := newSessionMutation(c.config, OpUpdateOne, withSession(s))
|
||||
return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SessionClient) UpdateOneID(id int) *SessionUpdateOne {
|
||||
mutation := newSessionMutation(c.config, OpUpdateOne, withSessionID(id))
|
||||
return &SessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Session.
|
||||
func (c *SessionClient) Delete() *SessionDelete {
|
||||
mutation := newSessionMutation(c.config, OpDelete)
|
||||
return &SessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a delete builder for the given entity.
|
||||
func (c *SessionClient) DeleteOne(s *Session) *SessionDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a delete builder for the given id.
|
||||
func (c *SessionClient) DeleteOneID(id int) *SessionDeleteOne {
|
||||
builder := c.Delete().Where(session.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SessionDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Session.
|
||||
func (c *SessionClient) Query() *SessionQuery {
|
||||
return &SessionQuery{config: c.config}
|
||||
}
|
||||
|
||||
// Get returns a Session entity by its id.
|
||||
func (c *SessionClient) Get(ctx context.Context, id int) (*Session, error) {
|
||||
return c.Query().Where(session.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SessionClient) GetX(ctx context.Context, id int) *Session {
|
||||
s, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SessionClient) Hooks() []Hook {
|
||||
return c.hooks.Session
|
||||
}
|
61
src/db/ent/config.go
Normal file
61
src/db/ent/config.go
Normal file
|
@ -0,0 +1,61 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect"
|
||||
)
|
||||
|
||||
// Option function to configure the client.
|
||||
type Option func(*config)
|
||||
|
||||
// Config is the configuration for the client and its builder.
|
||||
type config struct {
|
||||
// driver used for executing database requests.
|
||||
driver dialect.Driver
|
||||
// debug enable a debug logging.
|
||||
debug bool
|
||||
// log used for logging on debug mode.
|
||||
log func(...interface{})
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
}
|
||||
|
||||
// hooks per client, for fast access.
|
||||
type hooks struct {
|
||||
Challenge []ent.Hook
|
||||
Guild []ent.Hook
|
||||
Session []ent.Hook
|
||||
}
|
||||
|
||||
// Options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
opt(c)
|
||||
}
|
||||
if c.debug {
|
||||
c.driver = dialect.Debug(c.driver, c.log)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug enables debug logging on the ent.Driver.
|
||||
func Debug() Option {
|
||||
return func(c *config) {
|
||||
c.debug = true
|
||||
}
|
||||
}
|
||||
|
||||
// Log sets the logging function for debug mode.
|
||||
func Log(fn func(...interface{})) Option {
|
||||
return func(c *config) {
|
||||
c.log = fn
|
||||
}
|
||||
}
|
||||
|
||||
// Driver configures the client driver.
|
||||
func Driver(driver dialect.Driver) Option {
|
||||
return func(c *config) {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
33
src/db/ent/context.go
Normal file
33
src/db/ent/context.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns the Client stored in a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns the Tx stored in a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Client attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
246
src/db/ent/ent.go
Normal file
246
src/db/ent/ent.go
Normal file
|
@ -0,0 +1,246 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflict in user's code.
|
||||
type (
|
||||
Op = ent.Op
|
||||
Hook = ent.Hook
|
||||
Value = ent.Value
|
||||
Query = ent.Query
|
||||
Policy = ent.Policy
|
||||
Mutator = ent.Mutator
|
||||
Mutation = ent.Mutation
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
// OrderFunc applies an ordering on either graph traversal or sql selector.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Asc(f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) OrderFunc {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
s.OrderBy(sql.Desc(f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||
type AggregateFunc func(*sql.Selector) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
// GroupBy(field1, field2).
|
||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.As(fn(s), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ValidationError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ValidationError) Unwrap() error {
|
||||
return errors.Unwrap(e.err)
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validaton error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ValidationError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||
type NotFoundError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotFoundError) Error() string {
|
||||
return "ent: " + e.label + " not found"
|
||||
}
|
||||
|
||||
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||
func IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// MaskNotFound masks nor found error.
|
||||
func MaskNotFound(err error) error {
|
||||
if IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||
type NotSingularError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotSingularError) Error() string {
|
||||
return "ent: " + e.label + " not singular"
|
||||
}
|
||||
|
||||
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||
func IsNotSingular(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotSingularError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||
type NotLoadedError struct {
|
||||
edge string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotLoadedError) Error() string {
|
||||
return "ent: " + e.edge + " edge was not loaded"
|
||||
}
|
||||
|
||||
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||
func IsNotLoaded(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotLoadedError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// ConstraintError returns when trying to create/update one or more entities and
|
||||
// one or more of their constraints failed. For example, violation of edge or
|
||||
// field uniqueness.
|
||||
type ConstraintError struct {
|
||||
msg string
|
||||
wrap error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e ConstraintError) Error() string {
|
||||
return "ent: constraint failed: " + e.msg
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ConstraintError) Unwrap() error {
|
||||
return e.wrap
|
||||
}
|
||||
|
||||
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||
func IsConstraintError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
func isSQLConstraintError(err error) (*ConstraintError, bool) {
|
||||
var (
|
||||
msg = err.Error()
|
||||
// error format per dialect.
|
||||
errors = [...]string{
|
||||
"Error 1062", // MySQL 1062 error (ER_DUP_ENTRY).
|
||||
"UNIQUE constraint failed", // SQLite.
|
||||
"duplicate key value violates unique constraint", // PostgreSQL.
|
||||
}
|
||||
)
|
||||
if _, ok := err.(*sqlgraph.ConstraintError); ok {
|
||||
return &ConstraintError{msg, err}, true
|
||||
}
|
||||
for i := range errors {
|
||||
if strings.Contains(msg, errors[i]) {
|
||||
return &ConstraintError{msg, err}, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// rollback calls to tx.Rollback and wraps the given error with the rollback error if occurred.
|
||||
func rollback(tx dialect.Tx, err error) error {
|
||||
if rerr := tx.Rollback(); rerr != nil {
|
||||
err = fmt.Errorf("%s: %v", err.Error(), rerr)
|
||||
}
|
||||
if err, ok := isSQLConstraintError(err); ok {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
13
src/db/ent/enttest/BUILD.bazel
Normal file
13
src/db/ent/enttest/BUILD.bazel
Normal file
|
@ -0,0 +1,13 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "enttest",
|
||||
srcs = ["enttest.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/enttest",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/db/ent",
|
||||
"//src/db/ent/runtime",
|
||||
"@com_github_facebook_ent//dialect/sql/schema",
|
||||
],
|
||||
)
|
78
src/db/ent/enttest/enttest.go
Normal file
78
src/db/ent/enttest/enttest.go
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent"
|
||||
// required by schema hooks.
|
||||
_ "github.com/roleypoly/roleypoly/src/db/ent/runtime"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
type (
|
||||
// TestingT is the interface that is shared between
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...interface{})
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
Option func(*options)
|
||||
|
||||
options struct {
|
||||
opts []ent.Option
|
||||
migrateOpts []schema.MigrateOption
|
||||
}
|
||||
)
|
||||
|
||||
// WithOptions forwards options to client creation.
|
||||
func WithOptions(opts ...ent.Option) Option {
|
||||
return func(o *options) {
|
||||
o.opts = append(o.opts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigrateOptions forwards options to auto migration.
|
||||
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||
return func(o *options) {
|
||||
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(opts []Option) *options {
|
||||
o := &options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// Open calls ent.Open and auto-run migration.
|
||||
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClient calls ent.NewClient and auto-run migration.
|
||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c := ent.NewClient(o.opts...)
|
||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
return c
|
||||
}
|
3
src/db/ent/generate.go
Normal file
3
src/db/ent/generate.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package ent
|
||||
|
||||
//go:generate go run github.com/facebook/ent/cmd/entc generate ./schema
|
145
src/db/ent/guild.go
Normal file
145
src/db/ent/guild.go
Normal file
|
@ -0,0 +1,145 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/schema"
|
||||
)
|
||||
|
||||
// Guild is the model entity for the Guild schema.
|
||||
type Guild struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime time.Time `json:"update_time,omitempty"`
|
||||
// Snowflake holds the value of the "snowflake" field.
|
||||
Snowflake string `json:"snowflake,omitempty"`
|
||||
// Message holds the value of the "message" field.
|
||||
Message string `json:"message,omitempty"`
|
||||
// Categories holds the value of the "categories" field.
|
||||
Categories []schema.Category `json:"categories,omitempty"`
|
||||
// Entitlements holds the value of the "entitlements" field.
|
||||
Entitlements []string `json:"entitlements,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Guild) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullTime{}, // create_time
|
||||
&sql.NullTime{}, // update_time
|
||||
&sql.NullString{}, // snowflake
|
||||
&sql.NullString{}, // message
|
||||
&[]byte{}, // categories
|
||||
&[]byte{}, // entitlements
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Guild fields.
|
||||
func (gu *Guild) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(guild.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
gu.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[0])
|
||||
} else if value.Valid {
|
||||
gu.CreateTime = value.Time
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[1])
|
||||
} else if value.Valid {
|
||||
gu.UpdateTime = value.Time
|
||||
}
|
||||
if value, ok := values[2].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field snowflake", values[2])
|
||||
} else if value.Valid {
|
||||
gu.Snowflake = value.String
|
||||
}
|
||||
if value, ok := values[3].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field message", values[3])
|
||||
} else if value.Valid {
|
||||
gu.Message = value.String
|
||||
}
|
||||
|
||||
if value, ok := values[4].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field categories", values[4])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &gu.Categories); err != nil {
|
||||
return fmt.Errorf("unmarshal field categories: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if value, ok := values[5].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field entitlements", values[5])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &gu.Entitlements); err != nil {
|
||||
return fmt.Errorf("unmarshal field entitlements: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Guild.
|
||||
// Note that, you need to call Guild.Unwrap() before calling this method, if this Guild
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (gu *Guild) Update() *GuildUpdateOne {
|
||||
return (&GuildClient{config: gu.config}).UpdateOne(gu)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (gu *Guild) Unwrap() *Guild {
|
||||
tx, ok := gu.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Guild is not a transactional entity")
|
||||
}
|
||||
gu.config.driver = tx.drv
|
||||
return gu
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (gu *Guild) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Guild(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", gu.ID))
|
||||
builder.WriteString(", create_time=")
|
||||
builder.WriteString(gu.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", update_time=")
|
||||
builder.WriteString(gu.UpdateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", snowflake=")
|
||||
builder.WriteString(gu.Snowflake)
|
||||
builder.WriteString(", message=")
|
||||
builder.WriteString(gu.Message)
|
||||
builder.WriteString(", categories=")
|
||||
builder.WriteString(fmt.Sprintf("%v", gu.Categories))
|
||||
builder.WriteString(", entitlements=")
|
||||
builder.WriteString(fmt.Sprintf("%v", gu.Entitlements))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Guilds is a parsable slice of Guild.
|
||||
type Guilds []*Guild
|
||||
|
||||
func (gu Guilds) config(cfg config) {
|
||||
for _i := range gu {
|
||||
gu[_i].config = cfg
|
||||
}
|
||||
}
|
15
src/db/ent/guild/BUILD.bazel
Normal file
15
src/db/ent/guild/BUILD.bazel
Normal file
|
@ -0,0 +1,15 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "guild",
|
||||
srcs = [
|
||||
"guild.go",
|
||||
"where.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/guild",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/db/ent/predicate",
|
||||
"@com_github_facebook_ent//dialect/sql",
|
||||
],
|
||||
)
|
49
src/db/ent/guild/guild.go
Normal file
49
src/db/ent/guild/guild.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package guild
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the guild type in the database.
|
||||
Label = "guild"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldSnowflake holds the string denoting the snowflake field in the database.
|
||||
FieldSnowflake = "snowflake"
|
||||
// FieldMessage holds the string denoting the message field in the database.
|
||||
FieldMessage = "message"
|
||||
// FieldCategories holds the string denoting the categories field in the database.
|
||||
FieldCategories = "categories"
|
||||
// FieldEntitlements holds the string denoting the entitlements field in the database.
|
||||
FieldEntitlements = "entitlements"
|
||||
|
||||
// Table holds the table name of the guild in the database.
|
||||
Table = "guilds"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for guild fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldSnowflake,
|
||||
FieldMessage,
|
||||
FieldCategories,
|
||||
FieldEntitlements,
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
DefaultCreateTime func() time.Time
|
||||
// DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
DefaultUpdateTime func() time.Time
|
||||
// UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
UpdateDefaultUpdateTime func() time.Time
|
||||
)
|
527
src/db/ent/guild/where.go
Normal file
527
src/db/ent/guild/where.go
Normal file
|
@ -0,0 +1,527 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package guild
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Snowflake applies equality check predicate on the "snowflake" field. It's identical to SnowflakeEQ.
|
||||
func Snowflake(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// Message applies equality check predicate on the "message" field. It's identical to MessageEQ.
|
||||
func Message(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...time.Time) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...time.Time) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v time.Time) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeEQ applies the EQ predicate on the "snowflake" field.
|
||||
func SnowflakeEQ(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeNEQ applies the NEQ predicate on the "snowflake" field.
|
||||
func SnowflakeNEQ(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeIn applies the In predicate on the "snowflake" field.
|
||||
func SnowflakeIn(vs ...string) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldSnowflake), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeNotIn applies the NotIn predicate on the "snowflake" field.
|
||||
func SnowflakeNotIn(vs ...string) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldSnowflake), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeGT applies the GT predicate on the "snowflake" field.
|
||||
func SnowflakeGT(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeGTE applies the GTE predicate on the "snowflake" field.
|
||||
func SnowflakeGTE(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeLT applies the LT predicate on the "snowflake" field.
|
||||
func SnowflakeLT(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeLTE applies the LTE predicate on the "snowflake" field.
|
||||
func SnowflakeLTE(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeContains applies the Contains predicate on the "snowflake" field.
|
||||
func SnowflakeContains(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeHasPrefix applies the HasPrefix predicate on the "snowflake" field.
|
||||
func SnowflakeHasPrefix(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeHasSuffix applies the HasSuffix predicate on the "snowflake" field.
|
||||
func SnowflakeHasSuffix(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeEqualFold applies the EqualFold predicate on the "snowflake" field.
|
||||
func SnowflakeEqualFold(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SnowflakeContainsFold applies the ContainsFold predicate on the "snowflake" field.
|
||||
func SnowflakeContainsFold(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldSnowflake), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageEQ applies the EQ predicate on the "message" field.
|
||||
func MessageEQ(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageNEQ applies the NEQ predicate on the "message" field.
|
||||
func MessageNEQ(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageIn applies the In predicate on the "message" field.
|
||||
func MessageIn(vs ...string) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldMessage), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageNotIn applies the NotIn predicate on the "message" field.
|
||||
func MessageNotIn(vs ...string) predicate.Guild {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldMessage), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageGT applies the GT predicate on the "message" field.
|
||||
func MessageGT(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageGTE applies the GTE predicate on the "message" field.
|
||||
func MessageGTE(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageLT applies the LT predicate on the "message" field.
|
||||
func MessageLT(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageLTE applies the LTE predicate on the "message" field.
|
||||
func MessageLTE(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageContains applies the Contains predicate on the "message" field.
|
||||
func MessageContains(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageHasPrefix applies the HasPrefix predicate on the "message" field.
|
||||
func MessageHasPrefix(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageHasSuffix applies the HasSuffix predicate on the "message" field.
|
||||
func MessageHasSuffix(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageEqualFold applies the EqualFold predicate on the "message" field.
|
||||
func MessageEqualFold(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// MessageContainsFold applies the ContainsFold predicate on the "message" field.
|
||||
func MessageContainsFold(v string) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldMessage), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Guild) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Guild) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Guild) predicate.Guild {
|
||||
return predicate.Guild(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
285
src/db/ent/guild_create.go
Normal file
285
src/db/ent/guild_create.go
Normal file
|
@ -0,0 +1,285 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/schema"
|
||||
)
|
||||
|
||||
// GuildCreate is the builder for creating a Guild entity.
|
||||
type GuildCreate struct {
|
||||
config
|
||||
mutation *GuildMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreateTime sets the create_time field.
|
||||
func (gc *GuildCreate) SetCreateTime(t time.Time) *GuildCreate {
|
||||
gc.mutation.SetCreateTime(t)
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the create_time field if the given value is not nil.
|
||||
func (gc *GuildCreate) SetNillableCreateTime(t *time.Time) *GuildCreate {
|
||||
if t != nil {
|
||||
gc.SetCreateTime(*t)
|
||||
}
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the update_time field.
|
||||
func (gc *GuildCreate) SetUpdateTime(t time.Time) *GuildCreate {
|
||||
gc.mutation.SetUpdateTime(t)
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetNillableUpdateTime sets the update_time field if the given value is not nil.
|
||||
func (gc *GuildCreate) SetNillableUpdateTime(t *time.Time) *GuildCreate {
|
||||
if t != nil {
|
||||
gc.SetUpdateTime(*t)
|
||||
}
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetSnowflake sets the snowflake field.
|
||||
func (gc *GuildCreate) SetSnowflake(s string) *GuildCreate {
|
||||
gc.mutation.SetSnowflake(s)
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetMessage sets the message field.
|
||||
func (gc *GuildCreate) SetMessage(s string) *GuildCreate {
|
||||
gc.mutation.SetMessage(s)
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetCategories sets the categories field.
|
||||
func (gc *GuildCreate) SetCategories(s []schema.Category) *GuildCreate {
|
||||
gc.mutation.SetCategories(s)
|
||||
return gc
|
||||
}
|
||||
|
||||
// SetEntitlements sets the entitlements field.
|
||||
func (gc *GuildCreate) SetEntitlements(s []string) *GuildCreate {
|
||||
gc.mutation.SetEntitlements(s)
|
||||
return gc
|
||||
}
|
||||
|
||||
// Mutation returns the GuildMutation object of the builder.
|
||||
func (gc *GuildCreate) Mutation() *GuildMutation {
|
||||
return gc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Guild in the database.
|
||||
func (gc *GuildCreate) Save(ctx context.Context) (*Guild, error) {
|
||||
if err := gc.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Guild
|
||||
)
|
||||
if len(gc.hooks) == 0 {
|
||||
node, err = gc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
gc.mutation = mutation
|
||||
node, err = gc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(gc.hooks) - 1; i >= 0; i-- {
|
||||
mut = gc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, gc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (gc *GuildCreate) SaveX(ctx context.Context) *Guild {
|
||||
v, err := gc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (gc *GuildCreate) preSave() error {
|
||||
if _, ok := gc.mutation.CreateTime(); !ok {
|
||||
v := guild.DefaultCreateTime()
|
||||
gc.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := gc.mutation.UpdateTime(); !ok {
|
||||
v := guild.DefaultUpdateTime()
|
||||
gc.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := gc.mutation.Snowflake(); !ok {
|
||||
return &ValidationError{Name: "snowflake", err: errors.New("ent: missing required field \"snowflake\"")}
|
||||
}
|
||||
if _, ok := gc.mutation.Message(); !ok {
|
||||
return &ValidationError{Name: "message", err: errors.New("ent: missing required field \"message\"")}
|
||||
}
|
||||
if _, ok := gc.mutation.Categories(); !ok {
|
||||
return &ValidationError{Name: "categories", err: errors.New("ent: missing required field \"categories\"")}
|
||||
}
|
||||
if _, ok := gc.mutation.Entitlements(); !ok {
|
||||
return &ValidationError{Name: "entitlements", err: errors.New("ent: missing required field \"entitlements\"")}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gc *GuildCreate) sqlSave(ctx context.Context) (*Guild, error) {
|
||||
gu, _spec := gc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
gu.ID = int(id)
|
||||
return gu, nil
|
||||
}
|
||||
|
||||
func (gc *GuildCreate) createSpec() (*Guild, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
gu = &Guild{config: gc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: guild.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: guild.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := gc.mutation.CreateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: guild.FieldCreateTime,
|
||||
})
|
||||
gu.CreateTime = value
|
||||
}
|
||||
if value, ok := gc.mutation.UpdateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: guild.FieldUpdateTime,
|
||||
})
|
||||
gu.UpdateTime = value
|
||||
}
|
||||
if value, ok := gc.mutation.Snowflake(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: guild.FieldSnowflake,
|
||||
})
|
||||
gu.Snowflake = value
|
||||
}
|
||||
if value, ok := gc.mutation.Message(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: guild.FieldMessage,
|
||||
})
|
||||
gu.Message = value
|
||||
}
|
||||
if value, ok := gc.mutation.Categories(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldCategories,
|
||||
})
|
||||
gu.Categories = value
|
||||
}
|
||||
if value, ok := gc.mutation.Entitlements(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldEntitlements,
|
||||
})
|
||||
gu.Entitlements = value
|
||||
}
|
||||
return gu, _spec
|
||||
}
|
||||
|
||||
// GuildCreateBulk is the builder for creating a bulk of Guild entities.
|
||||
type GuildCreateBulk struct {
|
||||
config
|
||||
builders []*GuildCreate
|
||||
}
|
||||
|
||||
// Save creates the Guild entities in the database.
|
||||
func (gcb *GuildCreateBulk) Save(ctx context.Context) ([]*Guild, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(gcb.builders))
|
||||
nodes := make([]*Guild, len(gcb.builders))
|
||||
mutators := make([]Mutator, len(gcb.builders))
|
||||
for i := range gcb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := gcb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
if err := builder.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation, ok := m.(*GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, gcb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, gcb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (gcb *GuildCreateBulk) SaveX(ctx context.Context) []*Guild {
|
||||
v, err := gcb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
109
src/db/ent/guild_delete.go
Normal file
109
src/db/ent/guild_delete.go
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// GuildDelete is the builder for deleting a Guild entity.
|
||||
type GuildDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GuildMutation
|
||||
predicates []predicate.Guild
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (gd *GuildDelete) Where(ps ...predicate.Guild) *GuildDelete {
|
||||
gd.predicates = append(gd.predicates, ps...)
|
||||
return gd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (gd *GuildDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(gd.hooks) == 0 {
|
||||
affected, err = gd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
gd.mutation = mutation
|
||||
affected, err = gd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(gd.hooks) - 1; i >= 0; i-- {
|
||||
mut = gd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, gd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gd *GuildDelete) ExecX(ctx context.Context) int {
|
||||
n, err := gd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (gd *GuildDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: guild.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: guild.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := gd.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, gd.driver, _spec)
|
||||
}
|
||||
|
||||
// GuildDeleteOne is the builder for deleting a single Guild entity.
|
||||
type GuildDeleteOne struct {
|
||||
gd *GuildDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (gdo *GuildDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := gdo.gd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{guild.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gdo *GuildDeleteOne) ExecX(ctx context.Context) {
|
||||
gdo.gd.ExecX(ctx)
|
||||
}
|
866
src/db/ent/guild_query.go
Normal file
866
src/db/ent/guild_query.go
Normal file
|
@ -0,0 +1,866 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// GuildQuery is the builder for querying Guild entities.
|
||||
type GuildQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.Guild
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (gq *GuildQuery) Where(ps ...predicate.Guild) *GuildQuery {
|
||||
gq.predicates = append(gq.predicates, ps...)
|
||||
return gq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (gq *GuildQuery) Limit(limit int) *GuildQuery {
|
||||
gq.limit = &limit
|
||||
return gq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (gq *GuildQuery) Offset(offset int) *GuildQuery {
|
||||
gq.offset = &offset
|
||||
return gq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (gq *GuildQuery) Order(o ...OrderFunc) *GuildQuery {
|
||||
gq.order = append(gq.order, o...)
|
||||
return gq
|
||||
}
|
||||
|
||||
// First returns the first Guild entity in the query. Returns *NotFoundError when no guild was found.
|
||||
func (gq *GuildQuery) First(ctx context.Context) (*Guild, error) {
|
||||
gus, err := gq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(gus) == 0 {
|
||||
return nil, &NotFoundError{guild.Label}
|
||||
}
|
||||
return gus[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (gq *GuildQuery) FirstX(ctx context.Context) *Guild {
|
||||
gu, err := gq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return gu
|
||||
}
|
||||
|
||||
// FirstID returns the first Guild id in the query. Returns *NotFoundError when no id was found.
|
||||
func (gq *GuildQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = gq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{guild.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstXID is like FirstID, but panics if an error occurs.
|
||||
func (gq *GuildQuery) FirstXID(ctx context.Context) int {
|
||||
id, err := gq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only Guild entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (gq *GuildQuery) Only(ctx context.Context) (*Guild, error) {
|
||||
gus, err := gq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(gus) {
|
||||
case 1:
|
||||
return gus[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{guild.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{guild.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (gq *GuildQuery) OnlyX(ctx context.Context) *Guild {
|
||||
gu, err := gq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return gu
|
||||
}
|
||||
|
||||
// OnlyID returns the only Guild id in the query, returns an error if not exactly one id was returned.
|
||||
func (gq *GuildQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = gq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = &NotSingularError{guild.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (gq *GuildQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := gq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Guilds.
|
||||
func (gq *GuildQuery) All(ctx context.Context) ([]*Guild, error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return gq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (gq *GuildQuery) AllX(ctx context.Context) []*Guild {
|
||||
gus, err := gq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return gus
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Guild ids.
|
||||
func (gq *GuildQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := gq.Select(guild.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (gq *GuildQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := gq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (gq *GuildQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return gq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (gq *GuildQuery) CountX(ctx context.Context) int {
|
||||
count, err := gq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (gq *GuildQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return gq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (gq *GuildQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := gq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (gq *GuildQuery) Clone() *GuildQuery {
|
||||
return &GuildQuery{
|
||||
config: gq.config,
|
||||
limit: gq.limit,
|
||||
offset: gq.offset,
|
||||
order: append([]OrderFunc{}, gq.order...),
|
||||
unique: append([]string{}, gq.unique...),
|
||||
predicates: append([]predicate.Guild{}, gq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: gq.sql.Clone(),
|
||||
path: gq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy 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 {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Guild.Query().
|
||||
// GroupBy(guild.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (gq *GuildQuery) GroupBy(field string, fields ...string) *GuildGroupBy {
|
||||
group := &GuildGroupBy{config: gq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return gq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Guild.Query().
|
||||
// Select(guild.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (gq *GuildQuery) Select(field string, fields ...string) *GuildSelect {
|
||||
selector := &GuildSelect{config: gq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := gq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return gq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) prepareQuery(ctx context.Context) error {
|
||||
if gq.path != nil {
|
||||
prev, err := gq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) sqlAll(ctx context.Context) ([]*Guild, error) {
|
||||
var (
|
||||
nodes = []*Guild{}
|
||||
_spec = gq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &Guild{config: gq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, gq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := gq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, gq.driver, _spec)
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := gq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: guild.Table,
|
||||
Columns: guild.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: guild.FieldID,
|
||||
},
|
||||
},
|
||||
From: gq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := gq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := gq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := gq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := gq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (gq *GuildQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(gq.driver.Dialect())
|
||||
t1 := builder.Table(guild.Table)
|
||||
selector := builder.Select(t1.Columns(guild.Columns...)...).From(t1)
|
||||
if gq.sql != nil {
|
||||
selector = gq.sql
|
||||
selector.Select(selector.Columns(guild.Columns...)...)
|
||||
}
|
||||
for _, p := range gq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range gq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := gq.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 := gq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// GuildGroupBy is the builder for group-by Guild entities.
|
||||
type GuildGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (ggb *GuildGroupBy) Aggregate(fns ...AggregateFunc) *GuildGroupBy {
|
||||
ggb.fns = append(ggb.fns, fns...)
|
||||
return ggb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (ggb *GuildGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := ggb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ggb.sql = query
|
||||
return ggb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := ggb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(ggb.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := ggb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := ggb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = ggb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := ggb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(ggb.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := ggb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := ggb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = ggb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := ggb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(ggb.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := ggb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := ggb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = ggb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := ggb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(ggb.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := ggb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := ggb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (ggb *GuildGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = ggb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (ggb *GuildGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := ggb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (ggb *GuildGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := ggb.sqlQuery().Query()
|
||||
if err := ggb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (ggb *GuildGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := ggb.sql
|
||||
columns := make([]string, 0, len(ggb.fields)+len(ggb.fns))
|
||||
columns = append(columns, ggb.fields...)
|
||||
for _, fn := range ggb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(ggb.fields...)
|
||||
}
|
||||
|
||||
// GuildSelect is the builder for select fields of Guild entities.
|
||||
type GuildSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (gs *GuildSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := gs.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gs.sql = query
|
||||
return gs.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (gs *GuildSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := gs.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(gs.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := gs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (gs *GuildSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := gs.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = gs.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (gs *GuildSelect) StringX(ctx context.Context) string {
|
||||
v, err := gs.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(gs.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := gs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (gs *GuildSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := gs.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = gs.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (gs *GuildSelect) IntX(ctx context.Context) int {
|
||||
v, err := gs.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(gs.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := gs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (gs *GuildSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := gs.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = gs.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (gs *GuildSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := gs.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(gs.fields) > 1 {
|
||||
return nil, errors.New("ent: GuildSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := gs.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (gs *GuildSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := gs.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (gs *GuildSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = gs.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{guild.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: GuildSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (gs *GuildSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := gs.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (gs *GuildSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := gs.sqlQuery().Query()
|
||||
if err := gs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (gs *GuildSelect) sqlQuery() sql.Querier {
|
||||
selector := gs.sql
|
||||
selector.Select(selector.Columns(gs.fields...)...)
|
||||
return selector
|
||||
}
|
307
src/db/ent/guild_update.go
Normal file
307
src/db/ent/guild_update.go
Normal file
|
@ -0,0 +1,307 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/schema"
|
||||
)
|
||||
|
||||
// GuildUpdate is the builder for updating Guild entities.
|
||||
type GuildUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GuildMutation
|
||||
predicates []predicate.Guild
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (gu *GuildUpdate) Where(ps ...predicate.Guild) *GuildUpdate {
|
||||
gu.predicates = append(gu.predicates, ps...)
|
||||
return gu
|
||||
}
|
||||
|
||||
// SetMessage sets the message field.
|
||||
func (gu *GuildUpdate) SetMessage(s string) *GuildUpdate {
|
||||
gu.mutation.SetMessage(s)
|
||||
return gu
|
||||
}
|
||||
|
||||
// SetCategories sets the categories field.
|
||||
func (gu *GuildUpdate) SetCategories(s []schema.Category) *GuildUpdate {
|
||||
gu.mutation.SetCategories(s)
|
||||
return gu
|
||||
}
|
||||
|
||||
// SetEntitlements sets the entitlements field.
|
||||
func (gu *GuildUpdate) SetEntitlements(s []string) *GuildUpdate {
|
||||
gu.mutation.SetEntitlements(s)
|
||||
return gu
|
||||
}
|
||||
|
||||
// Mutation returns the GuildMutation object of the builder.
|
||||
func (gu *GuildUpdate) Mutation() *GuildMutation {
|
||||
return gu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (gu *GuildUpdate) Save(ctx context.Context) (int, error) {
|
||||
if _, ok := gu.mutation.UpdateTime(); !ok {
|
||||
v := guild.UpdateDefaultUpdateTime()
|
||||
gu.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(gu.hooks) == 0 {
|
||||
affected, err = gu.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
gu.mutation = mutation
|
||||
affected, err = gu.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(gu.hooks) - 1; i >= 0; i-- {
|
||||
mut = gu.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, gu.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (gu *GuildUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := gu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (gu *GuildUpdate) Exec(ctx context.Context) error {
|
||||
_, err := gu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (gu *GuildUpdate) ExecX(ctx context.Context) {
|
||||
if err := gu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (gu *GuildUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: guild.Table,
|
||||
Columns: guild.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: guild.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := gu.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := gu.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: guild.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
if value, ok := gu.mutation.Message(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: guild.FieldMessage,
|
||||
})
|
||||
}
|
||||
if value, ok := gu.mutation.Categories(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldCategories,
|
||||
})
|
||||
}
|
||||
if value, ok := gu.mutation.Entitlements(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldEntitlements,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{guild.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// GuildUpdateOne is the builder for updating a single Guild entity.
|
||||
type GuildUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *GuildMutation
|
||||
}
|
||||
|
||||
// SetMessage sets the message field.
|
||||
func (guo *GuildUpdateOne) SetMessage(s string) *GuildUpdateOne {
|
||||
guo.mutation.SetMessage(s)
|
||||
return guo
|
||||
}
|
||||
|
||||
// SetCategories sets the categories field.
|
||||
func (guo *GuildUpdateOne) SetCategories(s []schema.Category) *GuildUpdateOne {
|
||||
guo.mutation.SetCategories(s)
|
||||
return guo
|
||||
}
|
||||
|
||||
// SetEntitlements sets the entitlements field.
|
||||
func (guo *GuildUpdateOne) SetEntitlements(s []string) *GuildUpdateOne {
|
||||
guo.mutation.SetEntitlements(s)
|
||||
return guo
|
||||
}
|
||||
|
||||
// Mutation returns the GuildMutation object of the builder.
|
||||
func (guo *GuildUpdateOne) Mutation() *GuildMutation {
|
||||
return guo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (guo *GuildUpdateOne) Save(ctx context.Context) (*Guild, error) {
|
||||
if _, ok := guo.mutation.UpdateTime(); !ok {
|
||||
v := guild.UpdateDefaultUpdateTime()
|
||||
guo.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Guild
|
||||
)
|
||||
if len(guo.hooks) == 0 {
|
||||
node, err = guo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
guo.mutation = mutation
|
||||
node, err = guo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(guo.hooks) - 1; i >= 0; i-- {
|
||||
mut = guo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, guo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (guo *GuildUpdateOne) SaveX(ctx context.Context) *Guild {
|
||||
gu, err := guo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return gu
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (guo *GuildUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := guo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (guo *GuildUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := guo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (guo *GuildUpdateOne) sqlSave(ctx context.Context) (gu *Guild, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: guild.Table,
|
||||
Columns: guild.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: guild.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := guo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Guild.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := guo.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: guild.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
if value, ok := guo.mutation.Message(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: guild.FieldMessage,
|
||||
})
|
||||
}
|
||||
if value, ok := guo.mutation.Categories(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldCategories,
|
||||
})
|
||||
}
|
||||
if value, ok := guo.mutation.Entitlements(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeJSON,
|
||||
Value: value,
|
||||
Column: guild.FieldEntitlements,
|
||||
})
|
||||
}
|
||||
gu = &Guild{config: guo.config}
|
||||
_spec.Assign = gu.assignValues
|
||||
_spec.ScanValues = gu.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{guild.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return gu, nil
|
||||
}
|
9
src/db/ent/hook/BUILD.bazel
Normal file
9
src/db/ent/hook/BUILD.bazel
Normal file
|
@ -0,0 +1,9 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "hook",
|
||||
srcs = ["hook.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/hook",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//src/db/ent"],
|
||||
)
|
225
src/db/ent/hook/hook.go
Normal file
225
src/db/ent/hook/hook.go
Normal file
|
@ -0,0 +1,225 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent"
|
||||
)
|
||||
|
||||
// The ChallengeFunc type is an adapter to allow the use of ordinary
|
||||
// function as Challenge mutator.
|
||||
type ChallengeFunc func(context.Context, *ent.ChallengeMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ChallengeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.ChallengeMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChallengeMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// The GuildFunc type is an adapter to allow the use of ordinary
|
||||
// function as Guild mutator.
|
||||
type GuildFunc func(context.Context, *ent.GuildMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f GuildFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.GuildMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GuildMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// The SessionFunc type is an adapter to allow the use of ordinary
|
||||
// function as Session mutator.
|
||||
type SessionFunc func(context.Context, *ent.SessionMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
mv, ok := m.(*ent.SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SessionMutation", m)
|
||||
}
|
||||
return f(ctx, mv)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op ent.Op) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// Hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
//
|
||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, ent.Delete|ent.Create)
|
||||
//
|
||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||
//
|
||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []ent.Hook {
|
||||
// return []ent.Hook{
|
||||
// Reject(ent.Delete|ent.Update),
|
||||
// }
|
||||
// }
|
||||
//
|
||||
func Reject(op ent.Op) ent.Hook {
|
||||
hk := func(ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(_ context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
return nil, fmt.Errorf("%s operation is not allowed", m.Op())
|
||||
})
|
||||
}
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []ent.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...ent.Hook) Chain {
|
||||
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() ent.Hook {
|
||||
return func(mutator ent.Mutator) ent.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
16
src/db/ent/migrate/BUILD.bazel
Normal file
16
src/db/ent/migrate/BUILD.bazel
Normal file
|
@ -0,0 +1,16 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "migrate",
|
||||
srcs = [
|
||||
"migrate.go",
|
||||
"schema.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/migrate",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@com_github_facebook_ent//dialect",
|
||||
"@com_github_facebook_ent//dialect/sql/schema",
|
||||
"@com_github_facebook_ent//schema/field",
|
||||
],
|
||||
)
|
70
src/db/ent/migrate/migrate.go
Normal file
70
src/db/ent/migrate/migrate.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithFixture sets the foreign-key renaming option to the migration when upgrading
|
||||
// ent from v0.1.0 (issue-#285). Defaults to true.
|
||||
WithFixture = schema.WithFixture
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
universalID bool
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %v", err)
|
||||
}
|
||||
return migrate.Create(ctx, Tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
//
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
drv := &schema.WriteDriver{
|
||||
Writer: w,
|
||||
Driver: s.drv,
|
||||
}
|
||||
migrate, err := schema.NewMigrate(drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %v", err)
|
||||
}
|
||||
return migrate.Create(ctx, Tables...)
|
||||
}
|
72
src/db/ent/migrate/schema.go
Normal file
72
src/db/ent/migrate/schema.go
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql/schema"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// ChallengesColumns holds the columns for the "challenges" table.
|
||||
ChallengesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeTime},
|
||||
{Name: "update_time", Type: field.TypeTime},
|
||||
{Name: "challenge_id", Type: field.TypeString, Unique: true, Size: 2147483647},
|
||||
{Name: "user_id", Type: field.TypeString, Unique: true, Size: 2147483647},
|
||||
{Name: "human", Type: field.TypeString, Unique: true},
|
||||
{Name: "magic", Type: field.TypeString, Unique: true},
|
||||
{Name: "expires_at", Type: field.TypeTime},
|
||||
}
|
||||
// ChallengesTable holds the schema information for the "challenges" table.
|
||||
ChallengesTable = &schema.Table{
|
||||
Name: "challenges",
|
||||
Columns: ChallengesColumns,
|
||||
PrimaryKey: []*schema.Column{ChallengesColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// GuildsColumns holds the columns for the "guilds" table.
|
||||
GuildsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeTime},
|
||||
{Name: "update_time", Type: field.TypeTime},
|
||||
{Name: "snowflake", Type: field.TypeString, Unique: true, Size: 2147483647},
|
||||
{Name: "message", Type: field.TypeString, Size: 2147483647},
|
||||
{Name: "categories", Type: field.TypeJSON},
|
||||
{Name: "entitlements", Type: field.TypeJSON},
|
||||
}
|
||||
// GuildsTable holds the schema information for the "guilds" table.
|
||||
GuildsTable = &schema.Table{
|
||||
Name: "guilds",
|
||||
Columns: GuildsColumns,
|
||||
PrimaryKey: []*schema.Column{GuildsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// SessionsColumns holds the columns for the "sessions" table.
|
||||
SessionsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeTime},
|
||||
{Name: "update_time", Type: field.TypeTime},
|
||||
{Name: "session_id", Type: field.TypeString, Unique: true, Size: 2147483647},
|
||||
{Name: "user_id", Type: field.TypeString, Unique: true, Size: 2147483647},
|
||||
{Name: "source", Type: field.TypeEnum, Enums: []string{"oauth", "dm"}},
|
||||
{Name: "expires_at", Type: field.TypeTime},
|
||||
}
|
||||
// SessionsTable holds the schema information for the "sessions" table.
|
||||
SessionsTable = &schema.Table{
|
||||
Name: "sessions",
|
||||
Columns: SessionsColumns,
|
||||
PrimaryKey: []*schema.Column{SessionsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
ChallengesTable,
|
||||
GuildsTable,
|
||||
SessionsTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
1790
src/db/ent/mutation.go
Normal file
1790
src/db/ent/mutation.go
Normal file
File diff suppressed because it is too large
Load diff
9
src/db/ent/predicate/BUILD.bazel
Normal file
9
src/db/ent/predicate/BUILD.bazel
Normal file
|
@ -0,0 +1,9 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "predicate",
|
||||
srcs = ["predicate.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/predicate",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@com_github_facebook_ent//dialect/sql"],
|
||||
)
|
16
src/db/ent/predicate/predicate.go
Normal file
16
src/db/ent/predicate/predicate.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Challenge is the predicate function for challenge builders.
|
||||
type Challenge func(*sql.Selector)
|
||||
|
||||
// Guild is the predicate function for guild builders.
|
||||
type Guild func(*sql.Selector)
|
||||
|
||||
// Session is the predicate function for session builders.
|
||||
type Session func(*sql.Selector)
|
9
src/db/ent/privacy/BUILD.bazel
Normal file
9
src/db/ent/privacy/BUILD.bazel
Normal file
|
@ -0,0 +1,9 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "privacy",
|
||||
srcs = ["privacy.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/privacy",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//src/db/ent"],
|
||||
)
|
283
src/db/ent/privacy/privacy.go
Normal file
283
src/db/ent/privacy/privacy.go
Normal file
|
@ -0,0 +1,283 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package privacy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent"
|
||||
)
|
||||
|
||||
var (
|
||||
// Allow may be returned by rules to indicate that the policy
|
||||
// evaluation should terminate with an allow decision.
|
||||
Allow = errors.New("ent/privacy: allow rule")
|
||||
|
||||
// Deny may be returned by rules to indicate that the policy
|
||||
// evaluation should terminate with an deny decision.
|
||||
Deny = errors.New("ent/privacy: deny rule")
|
||||
|
||||
// Skip may be returned by rules to indicate that the policy
|
||||
// evaluation should continue to the next rule.
|
||||
Skip = errors.New("ent/privacy: skip rule")
|
||||
)
|
||||
|
||||
// Allowf returns an formatted wrapped Allow decision.
|
||||
func Allowf(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format+": %w", append(a, Allow)...)
|
||||
}
|
||||
|
||||
// Denyf returns an formatted wrapped Deny decision.
|
||||
func Denyf(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format+": %w", append(a, Deny)...)
|
||||
}
|
||||
|
||||
// Skipf returns an formatted wrapped Skip decision.
|
||||
func Skipf(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format+": %w", append(a, Skip)...)
|
||||
}
|
||||
|
||||
type decisionCtxKey struct{}
|
||||
|
||||
// DecisionContext creates a decision context.
|
||||
func DecisionContext(parent context.Context, decision error) context.Context {
|
||||
if decision == nil || errors.Is(decision, Skip) {
|
||||
return parent
|
||||
}
|
||||
return context.WithValue(parent, decisionCtxKey{}, decision)
|
||||
}
|
||||
|
||||
func decisionFromContext(ctx context.Context) (error, bool) {
|
||||
decision, ok := ctx.Value(decisionCtxKey{}).(error)
|
||||
if ok && errors.Is(decision, Allow) {
|
||||
decision = nil
|
||||
}
|
||||
return decision, ok
|
||||
}
|
||||
|
||||
type (
|
||||
// QueryPolicy combines multiple query rules into a single policy.
|
||||
QueryPolicy []QueryRule
|
||||
|
||||
// QueryRule defines the interface deciding whether a
|
||||
// query is allowed and optionally modify it.
|
||||
QueryRule interface {
|
||||
EvalQuery(context.Context, ent.Query) error
|
||||
}
|
||||
)
|
||||
|
||||
// EvalQuery evaluates a query against a query policy.
|
||||
func (policy QueryPolicy) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
if decision, ok := decisionFromContext(ctx); ok {
|
||||
return decision
|
||||
}
|
||||
for _, rule := range policy {
|
||||
switch decision := rule.EvalQuery(ctx, q); {
|
||||
case decision == nil || errors.Is(decision, Skip):
|
||||
case errors.Is(decision, Allow):
|
||||
return nil
|
||||
default:
|
||||
return decision
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// QueryRuleFunc type is an adapter to allow the use of
|
||||
// ordinary functions as query rules.
|
||||
type QueryRuleFunc func(context.Context, ent.Query) error
|
||||
|
||||
// Eval returns f(ctx, q).
|
||||
func (f QueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
return f(ctx, q)
|
||||
}
|
||||
|
||||
type (
|
||||
// MutationPolicy combines multiple mutation rules into a single policy.
|
||||
MutationPolicy []MutationRule
|
||||
|
||||
// MutationRule defines the interface deciding whether a
|
||||
// mutation is allowed and optionally modify it.
|
||||
MutationRule interface {
|
||||
EvalMutation(context.Context, ent.Mutation) error
|
||||
}
|
||||
)
|
||||
|
||||
// EvalMutation evaluates a mutation against a mutation policy.
|
||||
func (policy MutationPolicy) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
if decision, ok := decisionFromContext(ctx); ok {
|
||||
return decision
|
||||
}
|
||||
for _, rule := range policy {
|
||||
switch decision := rule.EvalMutation(ctx, m); {
|
||||
case decision == nil || errors.Is(decision, Skip):
|
||||
case errors.Is(decision, Allow):
|
||||
return nil
|
||||
default:
|
||||
return decision
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MutationRuleFunc type is an adapter to allow the use of
|
||||
// ordinary functions as mutation rules.
|
||||
type MutationRuleFunc func(context.Context, ent.Mutation) error
|
||||
|
||||
// EvalMutation returns f(ctx, m).
|
||||
func (f MutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
return f(ctx, m)
|
||||
}
|
||||
|
||||
// Policy groups query and mutation policies.
|
||||
type Policy struct {
|
||||
Query QueryPolicy
|
||||
Mutation MutationPolicy
|
||||
}
|
||||
|
||||
// EvalQuery forwards evaluation to query policy.
|
||||
func (policy Policy) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
return policy.Query.EvalQuery(ctx, q)
|
||||
}
|
||||
|
||||
// EvalMutation forwards evaluation to mutation policy.
|
||||
func (policy Policy) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
return policy.Mutation.EvalMutation(ctx, m)
|
||||
}
|
||||
|
||||
// QueryMutationRule is the interface that groups query and mutation rules.
|
||||
type QueryMutationRule interface {
|
||||
QueryRule
|
||||
MutationRule
|
||||
}
|
||||
|
||||
// AlwaysAllowRule returns a rule that returns an allow decision.
|
||||
func AlwaysAllowRule() QueryMutationRule {
|
||||
return fixedDecision{Allow}
|
||||
}
|
||||
|
||||
// AlwaysDenyRule returns a rule that returns a deny decision.
|
||||
func AlwaysDenyRule() QueryMutationRule {
|
||||
return fixedDecision{Deny}
|
||||
}
|
||||
|
||||
type fixedDecision struct {
|
||||
decision error
|
||||
}
|
||||
|
||||
func (f fixedDecision) EvalQuery(context.Context, ent.Query) error {
|
||||
return f.decision
|
||||
}
|
||||
|
||||
func (f fixedDecision) EvalMutation(context.Context, ent.Mutation) error {
|
||||
return f.decision
|
||||
}
|
||||
|
||||
type contextDecision struct {
|
||||
eval func(context.Context) error
|
||||
}
|
||||
|
||||
// ContextQueryMutationRule creates a query/mutation rule from a context eval func.
|
||||
func ContextQueryMutationRule(eval func(context.Context) error) QueryMutationRule {
|
||||
return contextDecision{eval}
|
||||
}
|
||||
|
||||
func (c contextDecision) EvalQuery(ctx context.Context, _ ent.Query) error {
|
||||
return c.eval(ctx)
|
||||
}
|
||||
|
||||
func (c contextDecision) EvalMutation(ctx context.Context, _ ent.Mutation) error {
|
||||
return c.eval(ctx)
|
||||
}
|
||||
|
||||
// OnMutationOperation evaluates the given rule only on a given mutation operation.
|
||||
func OnMutationOperation(rule MutationRule, op ent.Op) MutationRule {
|
||||
return MutationRuleFunc(func(ctx context.Context, m ent.Mutation) error {
|
||||
if m.Op().Is(op) {
|
||||
return rule.EvalMutation(ctx, m)
|
||||
}
|
||||
return Skip
|
||||
})
|
||||
}
|
||||
|
||||
// DenyMutationOperationRule returns a rule denying specified mutation operation.
|
||||
func DenyMutationOperationRule(op ent.Op) MutationRule {
|
||||
rule := MutationRuleFunc(func(_ context.Context, m ent.Mutation) error {
|
||||
return Denyf("ent/privacy: operation %s is not allowed", m.Op())
|
||||
})
|
||||
return OnMutationOperation(rule, op)
|
||||
}
|
||||
|
||||
// The ChallengeQueryRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a query rule.
|
||||
type ChallengeQueryRuleFunc func(context.Context, *ent.ChallengeQuery) error
|
||||
|
||||
// EvalQuery return f(ctx, q).
|
||||
func (f ChallengeQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
if q, ok := q.(*ent.ChallengeQuery); ok {
|
||||
return f(ctx, q)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ChallengeQuery", q)
|
||||
}
|
||||
|
||||
// The ChallengeMutationRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a mutation rule.
|
||||
type ChallengeMutationRuleFunc func(context.Context, *ent.ChallengeMutation) error
|
||||
|
||||
// EvalMutation calls f(ctx, m).
|
||||
func (f ChallengeMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
if m, ok := m.(*ent.ChallengeMutation); ok {
|
||||
return f(ctx, m)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ChallengeMutation", m)
|
||||
}
|
||||
|
||||
// The GuildQueryRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a query rule.
|
||||
type GuildQueryRuleFunc func(context.Context, *ent.GuildQuery) error
|
||||
|
||||
// EvalQuery return f(ctx, q).
|
||||
func (f GuildQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
if q, ok := q.(*ent.GuildQuery); ok {
|
||||
return f(ctx, q)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected query type %T, expect *ent.GuildQuery", q)
|
||||
}
|
||||
|
||||
// The GuildMutationRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a mutation rule.
|
||||
type GuildMutationRuleFunc func(context.Context, *ent.GuildMutation) error
|
||||
|
||||
// EvalMutation calls f(ctx, m).
|
||||
func (f GuildMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
if m, ok := m.(*ent.GuildMutation); ok {
|
||||
return f(ctx, m)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.GuildMutation", m)
|
||||
}
|
||||
|
||||
// The SessionQueryRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a query rule.
|
||||
type SessionQueryRuleFunc func(context.Context, *ent.SessionQuery) error
|
||||
|
||||
// EvalQuery return f(ctx, q).
|
||||
func (f SessionQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
|
||||
if q, ok := q.(*ent.SessionQuery); ok {
|
||||
return f(ctx, q)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected query type %T, expect *ent.SessionQuery", q)
|
||||
}
|
||||
|
||||
// The SessionMutationRuleFunc type is an adapter to allow the use of ordinary
|
||||
// functions as a mutation rule.
|
||||
type SessionMutationRuleFunc func(context.Context, *ent.SessionMutation) error
|
||||
|
||||
// EvalMutation calls f(ctx, m).
|
||||
func (f SessionMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
|
||||
if m, ok := m.(*ent.SessionMutation); ok {
|
||||
return f(ctx, m)
|
||||
}
|
||||
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.SessionMutation", m)
|
||||
}
|
68
src/db/ent/runtime.go
Normal file
68
src/db/ent/runtime.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/challenge"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/guild"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/schema"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// The init function reads all schema descriptors with runtime
|
||||
// code (default values, validators or hooks) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
challengeMixin := schema.Challenge{}.Mixin()
|
||||
challengeMixinFields0 := challengeMixin[0].Fields()
|
||||
challengeFields := schema.Challenge{}.Fields()
|
||||
_ = challengeFields
|
||||
// challengeDescCreateTime is the schema descriptor for create_time field.
|
||||
challengeDescCreateTime := challengeMixinFields0[0].Descriptor()
|
||||
// challenge.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
challenge.DefaultCreateTime = challengeDescCreateTime.Default.(func() time.Time)
|
||||
// challengeDescUpdateTime is the schema descriptor for update_time field.
|
||||
challengeDescUpdateTime := challengeMixinFields0[1].Descriptor()
|
||||
// challenge.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
challenge.DefaultUpdateTime = challengeDescUpdateTime.Default.(func() time.Time)
|
||||
// challenge.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
challenge.UpdateDefaultUpdateTime = challengeDescUpdateTime.UpdateDefault.(func() time.Time)
|
||||
// challengeDescExpiresAt is the schema descriptor for expires_at field.
|
||||
challengeDescExpiresAt := challengeFields[4].Descriptor()
|
||||
// challenge.DefaultExpiresAt holds the default value on creation for the expires_at field.
|
||||
challenge.DefaultExpiresAt = challengeDescExpiresAt.Default.(func() time.Time)
|
||||
guildMixin := schema.Guild{}.Mixin()
|
||||
guildMixinFields0 := guildMixin[0].Fields()
|
||||
guildFields := schema.Guild{}.Fields()
|
||||
_ = guildFields
|
||||
// guildDescCreateTime is the schema descriptor for create_time field.
|
||||
guildDescCreateTime := guildMixinFields0[0].Descriptor()
|
||||
// guild.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
guild.DefaultCreateTime = guildDescCreateTime.Default.(func() time.Time)
|
||||
// guildDescUpdateTime is the schema descriptor for update_time field.
|
||||
guildDescUpdateTime := guildMixinFields0[1].Descriptor()
|
||||
// guild.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
guild.DefaultUpdateTime = guildDescUpdateTime.Default.(func() time.Time)
|
||||
// guild.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
guild.UpdateDefaultUpdateTime = guildDescUpdateTime.UpdateDefault.(func() time.Time)
|
||||
sessionMixin := schema.Session{}.Mixin()
|
||||
sessionMixinFields0 := sessionMixin[0].Fields()
|
||||
sessionFields := schema.Session{}.Fields()
|
||||
_ = sessionFields
|
||||
// sessionDescCreateTime is the schema descriptor for create_time field.
|
||||
sessionDescCreateTime := sessionMixinFields0[0].Descriptor()
|
||||
// session.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
session.DefaultCreateTime = sessionDescCreateTime.Default.(func() time.Time)
|
||||
// sessionDescUpdateTime is the schema descriptor for update_time field.
|
||||
sessionDescUpdateTime := sessionMixinFields0[1].Descriptor()
|
||||
// session.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
session.DefaultUpdateTime = sessionDescUpdateTime.Default.(func() time.Time)
|
||||
// session.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
session.UpdateDefaultUpdateTime = sessionDescUpdateTime.UpdateDefault.(func() time.Time)
|
||||
// sessionDescExpiresAt is the schema descriptor for expires_at field.
|
||||
sessionDescExpiresAt := sessionFields[3].Descriptor()
|
||||
// session.DefaultExpiresAt holds the default value on creation for the expires_at field.
|
||||
session.DefaultExpiresAt = sessionDescExpiresAt.Default.(func() time.Time)
|
||||
}
|
8
src/db/ent/runtime/BUILD.bazel
Normal file
8
src/db/ent/runtime/BUILD.bazel
Normal file
|
@ -0,0 +1,8 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "runtime",
|
||||
srcs = ["runtime.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/runtime",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
10
src/db/ent/runtime/runtime.go
Normal file
10
src/db/ent/runtime/runtime.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in github.com/roleypoly/roleypoly/src/db/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.4.2" // Version of ent codegen.
|
||||
Sum = "h1:JzU5dYJH9XdjfIKgOiPPK3szkqLqcdPWgVder4Ogows=" // Sum of ent codegen.
|
||||
)
|
17
src/db/ent/schema/BUILD.bazel
Normal file
17
src/db/ent/schema/BUILD.bazel
Normal file
|
@ -0,0 +1,17 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "schema",
|
||||
srcs = [
|
||||
"challenge.go",
|
||||
"guild.go",
|
||||
"session.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/schema",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@com_github_facebook_ent//:ent",
|
||||
"@com_github_facebook_ent//schema/field",
|
||||
"@com_github_facebook_ent//schema/mixin",
|
||||
],
|
||||
)
|
46
src/db/ent/schema/challenge.go
Normal file
46
src/db/ent/schema/challenge.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/facebook/ent/schema/mixin"
|
||||
)
|
||||
|
||||
// Challenge holds the schema definition for the Challenge entity.
|
||||
type Challenge struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Challenge.
|
||||
func (Challenge) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Text("challenge_id").
|
||||
Immutable().Unique(),
|
||||
|
||||
field.Text("user_id").
|
||||
Immutable().Unique(),
|
||||
|
||||
field.String("human").Immutable().Unique(),
|
||||
field.String("magic").Immutable().Unique(),
|
||||
|
||||
field.Time("expires_at").
|
||||
Immutable().
|
||||
Default(func() time.Time {
|
||||
return time.Now().Add(5 * time.Minute)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Challenge.
|
||||
func (Challenge) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Mixin of the Challenge.
|
||||
func (Challenge) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixin.Time{},
|
||||
}
|
||||
}
|
44
src/db/ent/schema/guild.go
Normal file
44
src/db/ent/schema/guild.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/facebook/ent/schema/mixin"
|
||||
)
|
||||
|
||||
// Guild holds the schema definition for the Guild entity.
|
||||
type Guild struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
ID string
|
||||
Name string
|
||||
Hidden bool
|
||||
Type string
|
||||
Position int
|
||||
Roles []string
|
||||
}
|
||||
|
||||
// Fields of the Guild.
|
||||
func (Guild) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Text("snowflake").
|
||||
Immutable().Unique(),
|
||||
field.Text("message"),
|
||||
field.JSON("categories", []Category{}),
|
||||
field.Strings("entitlements"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Guild.
|
||||
func (Guild) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Mixin of the Guild.
|
||||
func (Guild) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixin.Time{},
|
||||
}
|
||||
}
|
47
src/db/ent/schema/session.go
Normal file
47
src/db/ent/schema/session.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/facebook/ent/schema/mixin"
|
||||
)
|
||||
|
||||
// Session holds the schema definition for the Session entity.
|
||||
type Session struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Session.
|
||||
func (Session) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Text("session_id").
|
||||
Immutable().Unique(),
|
||||
|
||||
field.Text("user_id").
|
||||
Immutable().Unique(),
|
||||
|
||||
field.Enum("source").
|
||||
Values("oauth", "dm").
|
||||
Immutable(),
|
||||
|
||||
field.Time("expires_at").
|
||||
Immutable().
|
||||
Default(func() time.Time {
|
||||
return time.Now().Add(6 * time.Hour)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Session.
|
||||
func (Session) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Mixin of the Session.
|
||||
func (Session) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixin.Time{},
|
||||
}
|
||||
}
|
137
src/db/ent/session.go
Normal file
137
src/db/ent/session.go
Normal file
|
@ -0,0 +1,137 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// Session is the model entity for the Session schema.
|
||||
type Session struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime time.Time `json:"update_time,omitempty"`
|
||||
// SessionID holds the value of the "session_id" field.
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
// UserID holds the value of the "user_id" field.
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
// Source holds the value of the "source" field.
|
||||
Source session.Source `json:"source,omitempty"`
|
||||
// ExpiresAt holds the value of the "expires_at" field.
|
||||
ExpiresAt time.Time `json:"expires_at,omitempty"`
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Session) scanValues() []interface{} {
|
||||
return []interface{}{
|
||||
&sql.NullInt64{}, // id
|
||||
&sql.NullTime{}, // create_time
|
||||
&sql.NullTime{}, // update_time
|
||||
&sql.NullString{}, // session_id
|
||||
&sql.NullString{}, // user_id
|
||||
&sql.NullString{}, // source
|
||||
&sql.NullTime{}, // expires_at
|
||||
}
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Session fields.
|
||||
func (s *Session) assignValues(values ...interface{}) error {
|
||||
if m, n := len(values), len(session.Columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
s.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[0])
|
||||
} else if value.Valid {
|
||||
s.CreateTime = value.Time
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[1])
|
||||
} else if value.Valid {
|
||||
s.UpdateTime = value.Time
|
||||
}
|
||||
if value, ok := values[2].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field session_id", values[2])
|
||||
} else if value.Valid {
|
||||
s.SessionID = value.String
|
||||
}
|
||||
if value, ok := values[3].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_id", values[3])
|
||||
} else if value.Valid {
|
||||
s.UserID = value.String
|
||||
}
|
||||
if value, ok := values[4].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field source", values[4])
|
||||
} else if value.Valid {
|
||||
s.Source = session.Source(value.String)
|
||||
}
|
||||
if value, ok := values[5].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field expires_at", values[5])
|
||||
} else if value.Valid {
|
||||
s.ExpiresAt = value.Time
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Session.
|
||||
// Note that, you need to call Session.Unwrap() before calling this method, if this Session
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (s *Session) Update() *SessionUpdateOne {
|
||||
return (&SessionClient{config: s.config}).UpdateOne(s)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
|
||||
// so that all next queries will be executed through the driver which created the transaction.
|
||||
func (s *Session) Unwrap() *Session {
|
||||
tx, ok := s.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Session is not a transactional entity")
|
||||
}
|
||||
s.config.driver = tx.drv
|
||||
return s
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (s *Session) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Session(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v", s.ID))
|
||||
builder.WriteString(", create_time=")
|
||||
builder.WriteString(s.CreateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", update_time=")
|
||||
builder.WriteString(s.UpdateTime.Format(time.ANSIC))
|
||||
builder.WriteString(", session_id=")
|
||||
builder.WriteString(s.SessionID)
|
||||
builder.WriteString(", user_id=")
|
||||
builder.WriteString(s.UserID)
|
||||
builder.WriteString(", source=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Source))
|
||||
builder.WriteString(", expires_at=")
|
||||
builder.WriteString(s.ExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Sessions is a parsable slice of Session.
|
||||
type Sessions []*Session
|
||||
|
||||
func (s Sessions) config(cfg config) {
|
||||
for _i := range s {
|
||||
s[_i].config = cfg
|
||||
}
|
||||
}
|
15
src/db/ent/session/BUILD.bazel
Normal file
15
src/db/ent/session/BUILD.bazel
Normal file
|
@ -0,0 +1,15 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "session",
|
||||
srcs = [
|
||||
"session.go",
|
||||
"where.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/db/ent/session",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/db/ent/predicate",
|
||||
"@com_github_facebook_ent//dialect/sql",
|
||||
],
|
||||
)
|
75
src/db/ent/session/session.go
Normal file
75
src/db/ent/session/session.go
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the session type in the database.
|
||||
Label = "session"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldSessionID holds the string denoting the session_id field in the database.
|
||||
FieldSessionID = "session_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldSource holds the string denoting the source field in the database.
|
||||
FieldSource = "source"
|
||||
// FieldExpiresAt holds the string denoting the expires_at field in the database.
|
||||
FieldExpiresAt = "expires_at"
|
||||
|
||||
// Table holds the table name of the session in the database.
|
||||
Table = "sessions"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for session fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldSessionID,
|
||||
FieldUserID,
|
||||
FieldSource,
|
||||
FieldExpiresAt,
|
||||
}
|
||||
|
||||
var (
|
||||
// DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
DefaultCreateTime func() time.Time
|
||||
// DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
DefaultUpdateTime func() time.Time
|
||||
// UpdateDefaultUpdateTime holds the default value on update for the update_time field.
|
||||
UpdateDefaultUpdateTime func() time.Time
|
||||
// DefaultExpiresAt holds the default value on creation for the expires_at field.
|
||||
DefaultExpiresAt func() time.Time
|
||||
)
|
||||
|
||||
// Source defines the type for the source enum field.
|
||||
type Source string
|
||||
|
||||
// Source values.
|
||||
const (
|
||||
SourceOauth Source = "oauth"
|
||||
SourceDm Source = "dm"
|
||||
)
|
||||
|
||||
func (s Source) String() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// SourceValidator is a validator for the "source" field enum values. It is called by the builders before save.
|
||||
func SourceValidator(s Source) error {
|
||||
switch s {
|
||||
case SourceOauth, SourceDm:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("session: invalid enum value for source field: %q", s)
|
||||
}
|
||||
}
|
658
src/db/ent/session/where.go
Normal file
658
src/db/ent/session/where.go
Normal file
|
@ -0,0 +1,658 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their identifier.
|
||||
func ID(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(ids) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
v := make([]interface{}, len(ids))
|
||||
for i := range v {
|
||||
v[i] = ids[i]
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldID), id))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionID applies equality check predicate on the "session_id" field. It's identical to SessionIDEQ.
|
||||
func SessionID(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||
func UserID(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
|
||||
func ExpiresAt(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldCreateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldCreateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldUpdateTime), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldUpdateTime), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDEQ applies the EQ predicate on the "session_id" field.
|
||||
func SessionIDEQ(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDNEQ applies the NEQ predicate on the "session_id" field.
|
||||
func SessionIDNEQ(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDIn applies the In predicate on the "session_id" field.
|
||||
func SessionIDIn(vs ...string) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldSessionID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDNotIn applies the NotIn predicate on the "session_id" field.
|
||||
func SessionIDNotIn(vs ...string) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldSessionID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDGT applies the GT predicate on the "session_id" field.
|
||||
func SessionIDGT(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDGTE applies the GTE predicate on the "session_id" field.
|
||||
func SessionIDGTE(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDLT applies the LT predicate on the "session_id" field.
|
||||
func SessionIDLT(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDLTE applies the LTE predicate on the "session_id" field.
|
||||
func SessionIDLTE(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDContains applies the Contains predicate on the "session_id" field.
|
||||
func SessionIDContains(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDHasPrefix applies the HasPrefix predicate on the "session_id" field.
|
||||
func SessionIDHasPrefix(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDHasSuffix applies the HasSuffix predicate on the "session_id" field.
|
||||
func SessionIDHasSuffix(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDEqualFold applies the EqualFold predicate on the "session_id" field.
|
||||
func SessionIDEqualFold(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SessionIDContainsFold applies the ContainsFold predicate on the "session_id" field.
|
||||
func SessionIDContainsFold(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldSessionID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||
func UserIDEQ(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||
func UserIDNEQ(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDIn applies the In predicate on the "user_id" field.
|
||||
func UserIDIn(vs ...string) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldUserID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||
func UserIDNotIn(vs ...string) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldUserID), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDGT applies the GT predicate on the "user_id" field.
|
||||
func UserIDGT(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDGTE applies the GTE predicate on the "user_id" field.
|
||||
func UserIDGTE(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDLT applies the LT predicate on the "user_id" field.
|
||||
func UserIDLT(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDLTE applies the LTE predicate on the "user_id" field.
|
||||
func UserIDLTE(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDContains applies the Contains predicate on the "user_id" field.
|
||||
func UserIDContains(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.Contains(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
|
||||
func UserIDHasPrefix(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.HasPrefix(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
|
||||
func UserIDHasSuffix(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.HasSuffix(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
|
||||
func UserIDEqualFold(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EqualFold(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
|
||||
func UserIDContainsFold(v string) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.ContainsFold(s.C(FieldUserID), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SourceEQ applies the EQ predicate on the "source" field.
|
||||
func SourceEQ(v Source) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldSource), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SourceNEQ applies the NEQ predicate on the "source" field.
|
||||
func SourceNEQ(v Source) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldSource), v))
|
||||
})
|
||||
}
|
||||
|
||||
// SourceIn applies the In predicate on the "source" field.
|
||||
func SourceIn(vs ...Source) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldSource), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// SourceNotIn applies the NotIn predicate on the "source" field.
|
||||
func SourceNotIn(vs ...Source) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldSource), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
|
||||
func ExpiresAtEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.EQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
|
||||
func ExpiresAtNEQ(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.NEQ(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtIn applies the In predicate on the "expires_at" field.
|
||||
func ExpiresAtIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.In(s.C(FieldExpiresAt), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
|
||||
func ExpiresAtNotIn(vs ...time.Time) predicate.Session {
|
||||
v := make([]interface{}, len(vs))
|
||||
for i := range v {
|
||||
v[i] = vs[i]
|
||||
}
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
// if not arguments were provided, append the FALSE constants,
|
||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
||||
if len(v) == 0 {
|
||||
s.Where(sql.False())
|
||||
return
|
||||
}
|
||||
s.Where(sql.NotIn(s.C(FieldExpiresAt), v...))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtGT applies the GT predicate on the "expires_at" field.
|
||||
func ExpiresAtGT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GT(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
|
||||
func ExpiresAtGTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.GTE(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtLT applies the LT predicate on the "expires_at" field.
|
||||
func ExpiresAtLT(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LT(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
|
||||
func ExpiresAtLTE(v time.Time) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s.Where(sql.LTE(s.C(FieldExpiresAt), v))
|
||||
})
|
||||
}
|
||||
|
||||
// And groups list of predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Session) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Or groups list of predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Session) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Session) predicate.Session {
|
||||
return predicate.Session(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
}
|
298
src/db/ent/session_create.go
Normal file
298
src/db/ent/session_create.go
Normal file
|
@ -0,0 +1,298 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// SessionCreate is the builder for creating a Session entity.
|
||||
type SessionCreate struct {
|
||||
config
|
||||
mutation *SessionMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreateTime sets the create_time field.
|
||||
func (sc *SessionCreate) SetCreateTime(t time.Time) *SessionCreate {
|
||||
sc.mutation.SetCreateTime(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the create_time field if the given value is not nil.
|
||||
func (sc *SessionCreate) SetNillableCreateTime(t *time.Time) *SessionCreate {
|
||||
if t != nil {
|
||||
sc.SetCreateTime(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the update_time field.
|
||||
func (sc *SessionCreate) SetUpdateTime(t time.Time) *SessionCreate {
|
||||
sc.mutation.SetUpdateTime(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableUpdateTime sets the update_time field if the given value is not nil.
|
||||
func (sc *SessionCreate) SetNillableUpdateTime(t *time.Time) *SessionCreate {
|
||||
if t != nil {
|
||||
sc.SetUpdateTime(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetSessionID sets the session_id field.
|
||||
func (sc *SessionCreate) SetSessionID(s string) *SessionCreate {
|
||||
sc.mutation.SetSessionID(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetUserID sets the user_id field.
|
||||
func (sc *SessionCreate) SetUserID(s string) *SessionCreate {
|
||||
sc.mutation.SetUserID(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetSource sets the source field.
|
||||
func (sc *SessionCreate) SetSource(s session.Source) *SessionCreate {
|
||||
sc.mutation.SetSource(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the expires_at field.
|
||||
func (sc *SessionCreate) SetExpiresAt(t time.Time) *SessionCreate {
|
||||
sc.mutation.SetExpiresAt(t)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetNillableExpiresAt sets the expires_at field if the given value is not nil.
|
||||
func (sc *SessionCreate) SetNillableExpiresAt(t *time.Time) *SessionCreate {
|
||||
if t != nil {
|
||||
sc.SetExpiresAt(*t)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
// Mutation returns the SessionMutation object of the builder.
|
||||
func (sc *SessionCreate) Mutation() *SessionMutation {
|
||||
return sc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Session in the database.
|
||||
func (sc *SessionCreate) Save(ctx context.Context) (*Session, error) {
|
||||
if err := sc.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Session
|
||||
)
|
||||
if len(sc.hooks) == 0 {
|
||||
node, err = sc.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
sc.mutation = mutation
|
||||
node, err = sc.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(sc.hooks) - 1; i >= 0; i-- {
|
||||
mut = sc.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, sc.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SessionCreate) SaveX(ctx context.Context) *Session {
|
||||
v, err := sc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (sc *SessionCreate) preSave() error {
|
||||
if _, ok := sc.mutation.CreateTime(); !ok {
|
||||
v := session.DefaultCreateTime()
|
||||
sc.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := sc.mutation.UpdateTime(); !ok {
|
||||
v := session.DefaultUpdateTime()
|
||||
sc.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := sc.mutation.SessionID(); !ok {
|
||||
return &ValidationError{Name: "session_id", err: errors.New("ent: missing required field \"session_id\"")}
|
||||
}
|
||||
if _, ok := sc.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New("ent: missing required field \"user_id\"")}
|
||||
}
|
||||
if _, ok := sc.mutation.Source(); !ok {
|
||||
return &ValidationError{Name: "source", err: errors.New("ent: missing required field \"source\"")}
|
||||
}
|
||||
if v, ok := sc.mutation.Source(); ok {
|
||||
if err := session.SourceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "source", err: fmt.Errorf("ent: validator failed for field \"source\": %w", err)}
|
||||
}
|
||||
}
|
||||
if _, ok := sc.mutation.ExpiresAt(); !ok {
|
||||
v := session.DefaultExpiresAt()
|
||||
sc.mutation.SetExpiresAt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SessionCreate) sqlSave(ctx context.Context) (*Session, error) {
|
||||
s, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
s.ID = int(id)
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (sc *SessionCreate) createSpec() (*Session, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
s = &Session{config: sc.config}
|
||||
_spec = &sqlgraph.CreateSpec{
|
||||
Table: session.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: session.FieldID,
|
||||
},
|
||||
}
|
||||
)
|
||||
if value, ok := sc.mutation.CreateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: session.FieldCreateTime,
|
||||
})
|
||||
s.CreateTime = value
|
||||
}
|
||||
if value, ok := sc.mutation.UpdateTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: session.FieldUpdateTime,
|
||||
})
|
||||
s.UpdateTime = value
|
||||
}
|
||||
if value, ok := sc.mutation.SessionID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: session.FieldSessionID,
|
||||
})
|
||||
s.SessionID = value
|
||||
}
|
||||
if value, ok := sc.mutation.UserID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: session.FieldUserID,
|
||||
})
|
||||
s.UserID = value
|
||||
}
|
||||
if value, ok := sc.mutation.Source(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: session.FieldSource,
|
||||
})
|
||||
s.Source = value
|
||||
}
|
||||
if value, ok := sc.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: session.FieldExpiresAt,
|
||||
})
|
||||
s.ExpiresAt = value
|
||||
}
|
||||
return s, _spec
|
||||
}
|
||||
|
||||
// SessionCreateBulk is the builder for creating a bulk of Session entities.
|
||||
type SessionCreateBulk struct {
|
||||
config
|
||||
builders []*SessionCreate
|
||||
}
|
||||
|
||||
// Save creates the Session entities in the database.
|
||||
func (scb *SessionCreateBulk) Save(ctx context.Context) ([]*Session, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Session, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
if err := builder.preSave(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation, ok := m.(*SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
builder.mutation = mutation
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
var err error
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
|
||||
} else {
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, scb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
}
|
||||
}
|
||||
mutation.done = true
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (scb *SessionCreateBulk) SaveX(ctx context.Context) []*Session {
|
||||
v, err := scb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
109
src/db/ent/session_delete.go
Normal file
109
src/db/ent/session_delete.go
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// SessionDelete is the builder for deleting a Session entity.
|
||||
type SessionDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SessionMutation
|
||||
predicates []predicate.Session
|
||||
}
|
||||
|
||||
// Where adds a new predicate to the delete builder.
|
||||
func (sd *SessionDelete) Where(ps ...predicate.Session) *SessionDelete {
|
||||
sd.predicates = append(sd.predicates, ps...)
|
||||
return sd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (sd *SessionDelete) Exec(ctx context.Context) (int, error) {
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(sd.hooks) == 0 {
|
||||
affected, err = sd.sqlExec(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
sd.mutation = mutation
|
||||
affected, err = sd.sqlExec(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(sd.hooks) - 1; i >= 0; i-- {
|
||||
mut = sd.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, sd.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sd *SessionDelete) ExecX(ctx context.Context) int {
|
||||
n, err := sd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (sd *SessionDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := &sqlgraph.DeleteSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: session.Table,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: session.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := sd.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
||||
}
|
||||
|
||||
// SessionDeleteOne is the builder for deleting a single Session entity.
|
||||
type SessionDeleteOne struct {
|
||||
sd *SessionDelete
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (sdo *SessionDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := sdo.sd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{session.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sdo *SessionDeleteOne) ExecX(ctx context.Context) {
|
||||
sdo.sd.ExecX(ctx)
|
||||
}
|
866
src/db/ent/session_query.go
Normal file
866
src/db/ent/session_query.go
Normal file
|
@ -0,0 +1,866 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// SessionQuery is the builder for querying Session entities.
|
||||
type SessionQuery struct {
|
||||
config
|
||||
limit *int
|
||||
offset *int
|
||||
order []OrderFunc
|
||||
unique []string
|
||||
predicates []predicate.Session
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (sq *SessionQuery) Where(ps ...predicate.Session) *SessionQuery {
|
||||
sq.predicates = append(sq.predicates, ps...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// Limit adds a limit step to the query.
|
||||
func (sq *SessionQuery) Limit(limit int) *SessionQuery {
|
||||
sq.limit = &limit
|
||||
return sq
|
||||
}
|
||||
|
||||
// Offset adds an offset step to the query.
|
||||
func (sq *SessionQuery) Offset(offset int) *SessionQuery {
|
||||
sq.offset = &offset
|
||||
return sq
|
||||
}
|
||||
|
||||
// Order adds an order step to the query.
|
||||
func (sq *SessionQuery) Order(o ...OrderFunc) *SessionQuery {
|
||||
sq.order = append(sq.order, o...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// First returns the first Session entity in the query. Returns *NotFoundError when no session was found.
|
||||
func (sq *SessionQuery) First(ctx context.Context) (*Session, error) {
|
||||
sSlice, err := sq.Limit(1).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(sSlice) == 0 {
|
||||
return nil, &NotFoundError{session.Label}
|
||||
}
|
||||
return sSlice[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (sq *SessionQuery) FirstX(ctx context.Context) *Session {
|
||||
s, err := sq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// FirstID returns the first Session id in the query. Returns *NotFoundError when no id was found.
|
||||
func (sq *SessionQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(1).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{session.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstXID is like FirstID, but panics if an error occurs.
|
||||
func (sq *SessionQuery) FirstXID(ctx context.Context) int {
|
||||
id, err := sq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns the only Session entity in the query, returns an error if not exactly one entity was returned.
|
||||
func (sq *SessionQuery) Only(ctx context.Context) (*Session, error) {
|
||||
sSlice, err := sq.Limit(2).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(sSlice) {
|
||||
case 1:
|
||||
return sSlice[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{session.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{session.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (sq *SessionQuery) OnlyX(ctx context.Context) *Session {
|
||||
s, err := sq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// OnlyID returns the only Session id in the query, returns an error if not exactly one id was returned.
|
||||
func (sq *SessionQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(2).IDs(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = &NotSingularError{session.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (sq *SessionQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := sq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Sessions.
|
||||
func (sq *SessionQuery) All(ctx context.Context) ([]*Session, error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sq.sqlAll(ctx)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (sq *SessionQuery) AllX(ctx context.Context) []*Session {
|
||||
sSlice, err := sq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return sSlice
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Session ids.
|
||||
func (sq *SessionQuery) IDs(ctx context.Context) ([]int, error) {
|
||||
var ids []int
|
||||
if err := sq.Select(session.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (sq *SessionQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := sq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (sq *SessionQuery) Count(ctx context.Context) (int, error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return sq.sqlCount(ctx)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (sq *SessionQuery) CountX(ctx context.Context) int {
|
||||
count, err := sq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (sq *SessionQuery) Exist(ctx context.Context) (bool, error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return sq.sqlExist(ctx)
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (sq *SessionQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := sq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (sq *SessionQuery) Clone() *SessionQuery {
|
||||
return &SessionQuery{
|
||||
config: sq.config,
|
||||
limit: sq.limit,
|
||||
offset: sq.offset,
|
||||
order: append([]OrderFunc{}, sq.order...),
|
||||
unique: append([]string{}, sq.unique...),
|
||||
predicates: append([]predicate.Session{}, sq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sq.sql.Clone(),
|
||||
path: sq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupBy 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 {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Session.Query().
|
||||
// GroupBy(session.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (sq *SessionQuery) GroupBy(field string, fields ...string) *SessionGroupBy {
|
||||
group := &SessionGroupBy{config: sq.config}
|
||||
group.fields = append([]string{field}, fields...)
|
||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sq.sqlQuery(), nil
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// Select one or more fields from the given query.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreateTime time.Time `json:"create_time,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Session.Query().
|
||||
// Select(session.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
//
|
||||
func (sq *SessionQuery) Select(field string, fields ...string) *SessionSelect {
|
||||
selector := &SessionSelect{config: sq.config}
|
||||
selector.fields = append([]string{field}, fields...)
|
||||
selector.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sq.sqlQuery(), nil
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) prepareQuery(ctx context.Context) error {
|
||||
if sq.path != nil {
|
||||
prev, err := sq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) sqlAll(ctx context.Context) ([]*Session, error) {
|
||||
var (
|
||||
nodes = []*Session{}
|
||||
_spec = sq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func() []interface{} {
|
||||
node := &Session{config: sq.config}
|
||||
nodes = append(nodes, node)
|
||||
values := node.scanValues()
|
||||
return values
|
||||
}
|
||||
_spec.Assign = func(values ...interface{}) error {
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
||||
}
|
||||
node := nodes[len(nodes)-1]
|
||||
return node.assignValues(values...)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := sq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("ent: check existence: %v", err)
|
||||
}
|
||||
return n > 0, nil
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := &sqlgraph.QuerySpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: session.Table,
|
||||
Columns: session.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: session.FieldID,
|
||||
},
|
||||
},
|
||||
From: sq.sql,
|
||||
Unique: true,
|
||||
}
|
||||
if ps := sq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := sq.limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := sq.offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := sq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (sq *SessionQuery) sqlQuery() *sql.Selector {
|
||||
builder := sql.Dialect(sq.driver.Dialect())
|
||||
t1 := builder.Table(session.Table)
|
||||
selector := builder.Select(t1.Columns(session.Columns...)...).From(t1)
|
||||
if sq.sql != nil {
|
||||
selector = sq.sql
|
||||
selector.Select(selector.Columns(session.Columns...)...)
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range sq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := sq.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 := sq.limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// SessionGroupBy is the builder for group-by Session entities.
|
||||
type SessionGroupBy struct {
|
||||
config
|
||||
fields []string
|
||||
fns []AggregateFunc
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (sgb *SessionGroupBy) Aggregate(fns ...AggregateFunc) *SessionGroupBy {
|
||||
sgb.fns = append(sgb.fns, fns...)
|
||||
return sgb
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scan the result into the given value.
|
||||
func (sgb *SessionGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := sgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sgb.sql = query
|
||||
return sgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := sgb.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(sgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionGroupBy.Strings is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := sgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) StringsX(ctx context.Context) []string {
|
||||
v, err := sgb.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = sgb.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionGroupBy.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) StringX(ctx context.Context) string {
|
||||
v, err := sgb.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(sgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionGroupBy.Ints is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := sgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) IntsX(ctx context.Context) []int {
|
||||
v, err := sgb.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = sgb.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionGroupBy.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) IntX(ctx context.Context) int {
|
||||
v, err := sgb.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(sgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionGroupBy.Float64s is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := sgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := sgb.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = sgb.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionGroupBy.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) Float64X(ctx context.Context) float64 {
|
||||
v, err := sgb.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(sgb.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionGroupBy.Bools is not achievable when grouping more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := sgb.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) BoolsX(ctx context.Context) []bool {
|
||||
v, err := sgb.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
|
||||
func (sgb *SessionGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = sgb.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionGroupBy.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (sgb *SessionGroupBy) BoolX(ctx context.Context) bool {
|
||||
v, err := sgb.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (sgb *SessionGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := sgb.sqlQuery().Query()
|
||||
if err := sgb.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (sgb *SessionGroupBy) sqlQuery() *sql.Selector {
|
||||
selector := sgb.sql
|
||||
columns := make([]string, 0, len(sgb.fields)+len(sgb.fns))
|
||||
columns = append(columns, sgb.fields...)
|
||||
for _, fn := range sgb.fns {
|
||||
columns = append(columns, fn(selector))
|
||||
}
|
||||
return selector.Select(columns...).GroupBy(sgb.fields...)
|
||||
}
|
||||
|
||||
// SessionSelect is the builder for select fields of Session entities.
|
||||
type SessionSelect struct {
|
||||
config
|
||||
fields []string
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scan the result into the given value.
|
||||
func (ss *SessionSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
query, err := ss.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ss.sql = query
|
||||
return ss.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (ss *SessionSelect) ScanX(ctx context.Context, v interface{}) {
|
||||
if err := ss.Scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(ss.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionSelect.Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := ss.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (ss *SessionSelect) StringsX(ctx context.Context) []string {
|
||||
v, err := ss.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = ss.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionSelect.Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (ss *SessionSelect) StringX(ctx context.Context) string {
|
||||
v, err := ss.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(ss.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionSelect.Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := ss.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (ss *SessionSelect) IntsX(ctx context.Context) []int {
|
||||
v, err := ss.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = ss.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionSelect.Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (ss *SessionSelect) IntX(ctx context.Context) int {
|
||||
v, err := ss.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(ss.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionSelect.Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := ss.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (ss *SessionSelect) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := ss.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = ss.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionSelect.Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (ss *SessionSelect) Float64X(ctx context.Context) float64 {
|
||||
v, err := ss.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(ss.fields) > 1 {
|
||||
return nil, errors.New("ent: SessionSelect.Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := ss.Scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (ss *SessionSelect) BoolsX(ctx context.Context) []bool {
|
||||
v, err := ss.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from selector. It is only allowed when selecting one field.
|
||||
func (ss *SessionSelect) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = ss.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{session.Label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: SessionSelect.Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (ss *SessionSelect) BoolX(ctx context.Context) bool {
|
||||
v, err := ss.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (ss *SessionSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
rows := &sql.Rows{}
|
||||
query, args := ss.sqlQuery().Query()
|
||||
if err := ss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
func (ss *SessionSelect) sqlQuery() sql.Querier {
|
||||
selector := ss.sql
|
||||
selector.Select(selector.Columns(ss.fields...)...)
|
||||
return selector
|
||||
}
|
228
src/db/ent/session_update.go
Normal file
228
src/db/ent/session_update.go
Normal file
|
@ -0,0 +1,228 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/dialect/sql/sqlgraph"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/predicate"
|
||||
"github.com/roleypoly/roleypoly/src/db/ent/session"
|
||||
)
|
||||
|
||||
// SessionUpdate is the builder for updating Session entities.
|
||||
type SessionUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SessionMutation
|
||||
predicates []predicate.Session
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the builder.
|
||||
func (su *SessionUpdate) Where(ps ...predicate.Session) *SessionUpdate {
|
||||
su.predicates = append(su.predicates, ps...)
|
||||
return su
|
||||
}
|
||||
|
||||
// Mutation returns the SessionMutation object of the builder.
|
||||
func (su *SessionUpdate) Mutation() *SessionMutation {
|
||||
return su.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of rows/vertices matched by this operation.
|
||||
func (su *SessionUpdate) Save(ctx context.Context) (int, error) {
|
||||
if _, ok := su.mutation.UpdateTime(); !ok {
|
||||
v := session.UpdateDefaultUpdateTime()
|
||||
su.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
affected int
|
||||
)
|
||||
if len(su.hooks) == 0 {
|
||||
affected, err = su.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
su.mutation = mutation
|
||||
affected, err = su.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return affected, err
|
||||
})
|
||||
for i := len(su.hooks) - 1; i >= 0; i-- {
|
||||
mut = su.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, su.mutation); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SessionUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SessionUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SessionUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (su *SessionUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: session.Table,
|
||||
Columns: session.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: session.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
if ps := su.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: session.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{session.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// SessionUpdateOne is the builder for updating a single Session entity.
|
||||
type SessionUpdateOne struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SessionMutation
|
||||
}
|
||||
|
||||
// Mutation returns the SessionMutation object of the builder.
|
||||
func (suo *SessionUpdateOne) Mutation() *SessionMutation {
|
||||
return suo.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated entity.
|
||||
func (suo *SessionUpdateOne) Save(ctx context.Context) (*Session, error) {
|
||||
if _, ok := suo.mutation.UpdateTime(); !ok {
|
||||
v := session.UpdateDefaultUpdateTime()
|
||||
suo.mutation.SetUpdateTime(v)
|
||||
}
|
||||
var (
|
||||
err error
|
||||
node *Session
|
||||
)
|
||||
if len(suo.hooks) == 0 {
|
||||
node, err = suo.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SessionMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
suo.mutation = mutation
|
||||
node, err = suo.sqlSave(ctx)
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(suo.hooks) - 1; i >= 0; i-- {
|
||||
mut = suo.hooks[i](mut)
|
||||
}
|
||||
if _, err := mut.Mutate(ctx, suo.mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return node, err
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SessionUpdateOne) SaveX(ctx context.Context) *Session {
|
||||
s, err := suo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SessionUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SessionUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (suo *SessionUpdateOne) sqlSave(ctx context.Context) (s *Session, err error) {
|
||||
_spec := &sqlgraph.UpdateSpec{
|
||||
Node: &sqlgraph.NodeSpec{
|
||||
Table: session.Table,
|
||||
Columns: session.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: session.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
id, ok := suo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing Session.ID for update")}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if value, ok := suo.mutation.UpdateTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: session.FieldUpdateTime,
|
||||
})
|
||||
}
|
||||
s = &Session{config: suo.config}
|
||||
_spec.Assign = s.assignValues
|
||||
_spec.ScanValues = s.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{session.Label}
|
||||
} else if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return s, nil
|
||||
}
|
216
src/db/ent/tx.go
Normal file
216
src/db/ent/tx.go
Normal file
|
@ -0,0 +1,216 @@
|
|||
// Code generated by entc, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/facebook/ent/dialect"
|
||||
)
|
||||
|
||||
// Tx is a transactional client that is created by calling Client.Tx().
|
||||
type Tx struct {
|
||||
config
|
||||
// Challenge is the client for interacting with the Challenge builders.
|
||||
Challenge *ChallengeClient
|
||||
// Guild is the client for interacting with the Guild builders.
|
||||
Guild *GuildClient
|
||||
// Session is the client for interacting with the Session builders.
|
||||
Session *SessionClient
|
||||
|
||||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
|
||||
// completion callbacks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Committer method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Committer. If f is a function with the appropriate
|
||||
// signature, CommitFunc(f) is a Committer that calls f.
|
||||
CommitFunc func(context.Context, *Tx) error
|
||||
|
||||
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Commit(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
CommitHook func(Committer) Committer
|
||||
)
|
||||
|
||||
// Commit calls f(ctx, m).
|
||||
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Commit commits the transaction.
|
||||
func (tx *Tx) Commit() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), tx.onCommit...)
|
||||
tx.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Commit(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onCommit = append(tx.onCommit, f)
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollbacker method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Rollbacker. If f is a function with the appropriate
|
||||
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||
RollbackFunc func(context.Context, *Tx) error
|
||||
|
||||
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Rollback(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
RollbackHook func(Rollbacker) Rollbacker
|
||||
)
|
||||
|
||||
// Rollback calls f(ctx, m).
|
||||
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Rollback rollbacks the transaction.
|
||||
func (tx *Tx) Rollback() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), tx.onRollback...)
|
||||
tx.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Rollback(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onRollback = append(tx.onRollback, f)
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
func (tx *Tx) Client() *Client {
|
||||
tx.clientOnce.Do(func() {
|
||||
tx.client = &Client{config: tx.config}
|
||||
tx.client.init()
|
||||
})
|
||||
return tx.client
|
||||
}
|
||||
|
||||
func (tx *Tx) init() {
|
||||
tx.Challenge = NewChallengeClient(tx.config)
|
||||
tx.Guild = NewGuildClient(tx.config)
|
||||
tx.Session = NewSessionClient(tx.config)
|
||||
}
|
||||
|
||||
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||
// The idea is to support transactions without adding any extra code to the builders.
|
||||
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||
// of them in order to commit or rollback the transaction.
|
||||
//
|
||||
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||
// applies a query, for example: Challenge.QueryXXX(), the query will be executed
|
||||
// through the driver which created this transaction.
|
||||
//
|
||||
// Note that txDriver is not goroutine safe.
|
||||
type txDriver struct {
|
||||
// the driver we started the transaction from.
|
||||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||
tx, err := drv.Tx(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &txDriver{tx: tx, drv: drv}, nil
|
||||
}
|
||||
|
||||
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||
// from the internal builders. Should be called only by the internal builders.
|
||||
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||
|
||||
// Dialect returns the dialect of the driver we started the transaction from.
|
||||
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||
|
||||
// Close is a nop close.
|
||||
func (*txDriver) Close() error { return nil }
|
||||
|
||||
// Commit is a nop commit for the internal builders.
|
||||
// User must call `Tx.Commit` in order to commit the transaction.
|
||||
func (*txDriver) Commit() error { return nil }
|
||||
|
||||
// Rollback is a nop rollback for the internal builders.
|
||||
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
var _ dialect.Driver = (*txDriver)(nil)
|
4
src/discord-bot/.gitignore
vendored
Normal file
4
src/discord-bot/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
.env
|
||||
vendor
|
||||
discord
|
||||
discord.exe
|
28
src/discord-bot/BUILD.bazel
Normal file
28
src/discord-bot/BUILD.bazel
Normal file
|
@ -0,0 +1,28 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
|
||||
|
||||
go_library(
|
||||
name = "discord-bot_lib",
|
||||
srcs = ["discordbot.go"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/discord-bot",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//src/common/version",
|
||||
"@com_github_bwmarrin_discordgo//:discordgo",
|
||||
"@com_github_joho_godotenv//autoload",
|
||||
"@com_github_lampjaw_discordclient//:discordclient",
|
||||
"@io_k8s_klog//:klog",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "discord-bot_bin",
|
||||
embed = [":discord-bot_lib"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
go_image(
|
||||
name = "discord-bot",
|
||||
embed = [":discord-bot_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
0
src/discord-bot/README.md
Normal file
0
src/discord-bot/README.md
Normal file
53
src/discord-bot/discordbot.go
Normal file
53
src/discord-bot/discordbot.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/lampjaw/discordclient"
|
||||
"github.com/roleypoly/roleypoly/src/common/version"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.Info(version.StartupInfo("discord-bot"))
|
||||
|
||||
botToken := os.Getenv("DISCORD_BOT_TOKEN")
|
||||
botClientID := os.Getenv("DISCORD_CLIENT_ID")
|
||||
rootUsers := strings.Split(os.Getenv("ROOT_USERS"), ",")
|
||||
|
||||
discordClient := discordclient.NewDiscordClient(botToken, rootUsers[0], botClientID)
|
||||
discordClient.GatewayIntents = discordgo.IntentsNone
|
||||
|
||||
messageChannel, err := discordClient.Listen(-1)
|
||||
if err != nil {
|
||||
klog.Fatal(err)
|
||||
}
|
||||
|
||||
defer awaitExit()
|
||||
|
||||
go processMessages(messageChannel)
|
||||
}
|
||||
|
||||
func processMessages(messageChannel <-chan discordclient.Message) {
|
||||
for {
|
||||
message := <-messageChannel
|
||||
klog.Infoln("message: ", message.Message())
|
||||
}
|
||||
}
|
||||
|
||||
func awaitExit() {
|
||||
syscallExit := make(chan os.Signal, 1)
|
||||
signal.Notify(
|
||||
syscallExit,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
os.Interrupt,
|
||||
os.Kill,
|
||||
)
|
||||
<-syscallExit
|
||||
}
|
16
src/gripkit/BUILD.bazel
Normal file
16
src/gripkit/BUILD.bazel
Normal file
|
@ -0,0 +1,16 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "gripkit",
|
||||
srcs = [
|
||||
"gripkit.go",
|
||||
"options.go",
|
||||
],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/gripkit",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"@com_github_improbable_eng_grpc_web//go/grpcweb",
|
||||
"@io_k8s_klog//:klog",
|
||||
"@org_golang_google_grpc//:go_default_library",
|
||||
],
|
||||
)
|
103
src/gripkit/gripkit.go
Normal file
103
src/gripkit/gripkit.go
Normal file
|
@ -0,0 +1,103 @@
|
|||
// Package gripkit provides wrappers and helpers for
|
||||
package gripkit // import "github.com/roleypoly/gripkit"
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/improbable-eng/grpc-web/go/grpcweb"
|
||||
"google.golang.org/grpc"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
type Gripkit struct {
|
||||
Server *grpc.Server
|
||||
httpHandler *func(w http.ResponseWriter, r *http.Request)
|
||||
options *options
|
||||
grpcWebServer *grpcweb.WrappedGrpcServer
|
||||
ready bool
|
||||
}
|
||||
|
||||
func Create(options ...Option) *Gripkit {
|
||||
gkOptions := evaluateOptions(options...)
|
||||
grpcServer := grpc.NewServer(gkOptions.grpcOptions...)
|
||||
|
||||
var grpcWrapper *grpcweb.WrappedGrpcServer
|
||||
if gkOptions.wrapGrpcWeb {
|
||||
grpcWrapper = grpcweb.WrapServer(grpcServer, gkOptions.grpcWebOptions...)
|
||||
}
|
||||
|
||||
gk := &Gripkit{
|
||||
Server: grpcServer,
|
||||
grpcWebServer: grpcWrapper,
|
||||
options: gkOptions,
|
||||
ready: false,
|
||||
}
|
||||
|
||||
if gk.options.healthz != nil {
|
||||
if gk.options.healthz.UseDefault {
|
||||
if gk.options.healthz.Addr == "" {
|
||||
gk.options.healthz.Addr = ":10456"
|
||||
}
|
||||
|
||||
gk.options.healthz.Handler = gk.defaultHealthHandler
|
||||
}
|
||||
|
||||
go gk.startHealthzServer()
|
||||
}
|
||||
|
||||
return gk
|
||||
}
|
||||
|
||||
func (gk *Gripkit) Serve() error {
|
||||
handler := gk.Server.ServeHTTP
|
||||
if gk.options.wrapGrpcWeb {
|
||||
handler = gk.grpcWebServer.ServeHTTP
|
||||
}
|
||||
|
||||
httpHandler := http.HandlerFunc(handler)
|
||||
|
||||
if gk.options.wrapDebug {
|
||||
httpHandler = http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
source := "gRPC native"
|
||||
if req.Header.Get("X-Grpc-Web") == "1" {
|
||||
source = "gRPC web"
|
||||
}
|
||||
klog.Infoln("gRPC debug: url:", req.URL, "source:", source)
|
||||
handler(resp, req)
|
||||
})
|
||||
}
|
||||
|
||||
if gk.options.httpOptions.TLSCertPath == "" || gk.options.httpOptions.TLSKeyPath == "" {
|
||||
return http.ListenAndServe(
|
||||
gk.options.httpOptions.Addr,
|
||||
httpHandler,
|
||||
)
|
||||
}
|
||||
|
||||
gk.ready = true
|
||||
|
||||
return http.ListenAndServeTLS(
|
||||
gk.options.httpOptions.Addr,
|
||||
gk.options.httpOptions.TLSCertPath,
|
||||
gk.options.httpOptions.TLSKeyPath,
|
||||
httpHandler,
|
||||
)
|
||||
}
|
||||
|
||||
func (gk *Gripkit) startHealthzServer() {
|
||||
klog.Infoln("Starting /healthz server on", gk.options.healthz.Addr)
|
||||
err := http.ListenAndServe(gk.options.healthz.Addr, gk.options.healthz.Handler)
|
||||
if err != nil {
|
||||
klog.Errorln("/healthz server failed to start", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (gk *Gripkit) defaultHealthHandler(rw http.ResponseWriter, r *http.Request) {
|
||||
if gk.ready {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
rw.Write([]byte(`OK`))
|
||||
} else {
|
||||
rw.WriteHeader(http.StatusServiceUnavailable)
|
||||
rw.Write([]byte(`Not Ready`))
|
||||
}
|
||||
}
|
103
src/gripkit/options.go
Normal file
103
src/gripkit/options.go
Normal file
|
@ -0,0 +1,103 @@
|
|||
package gripkit
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/improbable-eng/grpc-web/go/grpcweb"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type HTTPOptions struct {
|
||||
TLSCertPath string
|
||||
TLSKeyPath string
|
||||
Addr string
|
||||
}
|
||||
|
||||
type HealthzOptions struct {
|
||||
UseDefault bool
|
||||
Handler http.HandlerFunc
|
||||
|
||||
// Optional IP:Port string, defaults to :10456
|
||||
Addr string
|
||||
}
|
||||
|
||||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
wrapGrpcWeb bool
|
||||
grpcWebOptions []grpcweb.Option
|
||||
httpOptions HTTPOptions
|
||||
grpcOptions []grpc.ServerOption
|
||||
wrapDebug bool
|
||||
healthz *HealthzOptions
|
||||
}
|
||||
|
||||
var (
|
||||
defaultOptions = &options{
|
||||
wrapGrpcWeb: false,
|
||||
grpcWebOptions: []grpcweb.Option{},
|
||||
grpcOptions: []grpc.ServerOption{},
|
||||
wrapDebug: false,
|
||||
httpOptions: HTTPOptions{
|
||||
Addr: ":8080",
|
||||
TLSKeyPath: "",
|
||||
TLSCertPath: "",
|
||||
},
|
||||
healthz: &HealthzOptions{
|
||||
UseDefault: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func evaluateOptions(optionList ...Option) *options {
|
||||
evaluatedOptions := defaultOptions
|
||||
|
||||
for _, optionFunc := range optionList {
|
||||
if optionFunc != nil {
|
||||
optionFunc(evaluatedOptions)
|
||||
}
|
||||
}
|
||||
|
||||
return evaluatedOptions
|
||||
}
|
||||
|
||||
func WithDebug() Option {
|
||||
return func(o *options) {
|
||||
o.wrapDebug = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithGrpcWeb(opts ...grpcweb.Option) Option {
|
||||
return func(o *options) {
|
||||
o.wrapGrpcWeb = true
|
||||
o.grpcWebOptions = opts
|
||||
}
|
||||
}
|
||||
|
||||
func WithOptions(opts ...grpc.ServerOption) Option {
|
||||
return func(o *options) {
|
||||
o.grpcOptions = opts
|
||||
}
|
||||
}
|
||||
|
||||
func WithHTTPOptions(opts HTTPOptions) Option {
|
||||
return func(o *options) {
|
||||
o.httpOptions = opts
|
||||
}
|
||||
}
|
||||
|
||||
// WithHealthz adds a custom /healthz handler to the gRPC HTTP server. Pass nil to disable.
|
||||
func WithHealthz(hzOpts *HealthzOptions) Option {
|
||||
return func(o *options) {
|
||||
if hzOpts == nil {
|
||||
o.healthz = nil
|
||||
return
|
||||
}
|
||||
|
||||
if hzOpts.Addr != "" {
|
||||
o.healthz.Addr = hzOpts.Addr
|
||||
}
|
||||
|
||||
o.healthz.Handler = hzOpts.Handler
|
||||
}
|
||||
}
|
11
src/jstest/BUILD.bazel
Normal file
11
src/jstest/BUILD.bazel
Normal file
|
@ -0,0 +1,11 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
ts_library(
|
||||
name = "jstest",
|
||||
srcs = glob(["*.ts"]),
|
||||
deps = [
|
||||
# "//path/to/other:library"
|
||||
],
|
||||
)
|
1
src/jstest/index.ts
Normal file
1
src/jstest/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const aaa = "aa";
|
94
standards/cicd.md
Normal file
94
standards/cicd.md
Normal file
|
@ -0,0 +1,94 @@
|
|||
# CI/CD Standards and Practices for Roleypoly
|
||||
|
||||
This document outlines the standards for CI/CD for Roleypoly. All Roleypoly repos must follow this document, and serves as a checklist for onboarding new services.
|
||||
|
||||
## Checklist
|
||||
|
||||
- **CI**
|
||||
- [ ] [Branching Strategy](#branching-strategy)
|
||||
- [ ] [Code Testing](#code-testing)
|
||||
- [ ] [Code Style](#code-style)
|
||||
- [ ] [Docker Build](#docker-build)
|
||||
- [ ] [Docker Tagging](#docker-tagging)
|
||||
- [ ] [Container Structure Testing](#container-structure-testing)
|
||||
- [ ] [Deployment Trigger](#deployment-trigger)
|
||||
- [ ] [Dependabot](#dependabot)
|
||||
- **CD**
|
||||
- [ ] [Deployment Runner & Config](#deployment-runner-and-config)
|
||||
- [ ] [Terraform & Kubernetes](#terraform-and-kubernetes)
|
||||
|
||||
## Definitions
|
||||
|
||||
|
||||
### Branching Strategy
|
||||
|
||||
Branches should be named as follows:
|
||||
|
||||
- `master` is production code.
|
||||
- `develop` is actively developed code and is automatically deployed to staging.
|
||||
- `feat/` is any feature, branched from `develop`.
|
||||
- `fix/` is any fix targeted for next release, branched from `develop`.
|
||||
- `hotfix/` is any fix targeted for current release, branched from `master`.
|
||||
- `ci/` is any CI-focussed branch
|
||||
- `chore/` is any other work not mentioned above.
|
||||
|
||||
### Code Testing
|
||||
|
||||
Code should be tested where able. Discord interfaces can be very difficult to test properly, and are exempt; but code can preferrably be structured in a way that's able to both use Discord and test shims if possible.
|
||||
|
||||
Visual UI code must have a Storybook mock of it. Storybooks of `develop` branch are available at https://ui.roleypoly.com via Vercel/Now.
|
||||
|
||||
|
||||
### Code Style
|
||||
|
||||
Go code must follow `go fmt` rules.
|
||||
|
||||
JS/TS code must follow `prettier` rules as defined in https://github.com/roleypoly/ui/blob/develop/.prettierrc.js
|
||||
Styles must follow `stylelint` rules as defined in https://github.com/roleypoly/ui/blob/develop/.stylelintrc
|
||||
|
||||
Failing these rules should fail PR checks and builds.
|
||||
|
||||
|
||||
### Docker Build
|
||||
|
||||
Services will be packaged and deployed with Docker. A GitHub Action for using buildkit/buildx is available at [roleypoly/actions/dxt](https://github.com/roleypoly/actions/blob/master/dxt/action.yml)
|
||||
|
||||
Please follow best practices when creating Dockerfiles. Output images must be as small as genuinely possible.
|
||||
|
||||
|
||||
### Docker Tagging
|
||||
|
||||
Docker tags must always be the current commit hash, as well as the following mapping:
|
||||
|
||||
- `master` => `latest`
|
||||
- `develop` => `next`
|
||||
- `ci/testing.*` => `scratch`
|
||||
|
||||
Services may define other mappings on top of this.
|
||||
|
||||
A GitHub Action is available for retagging images at [roleypoly/actions/retag](https://github.com/roleypoly/actions/blob/master/retag/action.yml) accompanied with a `.retag.yml` ([example](https://github.com/roleypoly/auth/blob/develop/.retag.json))
|
||||
|
||||
|
||||
### Container Structure Testing
|
||||
|
||||
All Docker containers must be validated with a [Container Structure Test](https://github.com/GoogleContainerTools/container-structure-test). These are meant to define desired states to ensure it builds to the original specifications. One of these tests does not need to be deeply perfect, just a loose indictator of success and required parts.
|
||||
|
||||
|
||||
### Deployment Trigger
|
||||
|
||||
All services must utilize the GitOps automation workflow trigger provided by the GitHub Action [roleypoly/actions/deploy](https://github.com/roleypoly/actions/blob/master/deploy/action.yml). This will automatically ensure infrastructure is in the new desired state.
|
||||
|
||||
|
||||
### Dependabot
|
||||
|
||||
All services may optionally use Dependabot. Please define its configuration in code. Automerging is preferred, but please make sure tests will catch potential issues. Broken staging is better than broken production 😁
|
||||
|
||||
|
||||
### Deployment Runner and Config
|
||||
|
||||
[roleypoly/devops](https://github.com/roleypoly/devops) defines an action that gets triggered by [roleypoly/actions/deploy](https://github.com/roleypoly/actions/blob/master/deploy/action.yml) that updates `terraform/app/tags.auto.tfvars.json`. Please add your service to that file alongside any other Kubernetes configurations it needs.
|
||||
|
||||
|
||||
### Terraform & Kubernetes
|
||||
|
||||
[roleypoly/devops](https://github.com/roleypoly/devops) defines the Kubernetes cluster as well as the app cluster itself, too. Please adjust the cluster as necessary. Changes are not automatically applied, except for app staging; please contact core maintainers for help.
|
25
tsconfig.json
Normal file
25
tsconfig.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
"importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||
"paths": {
|
||||
"roleypoly/*": ["*"]
|
||||
}
|
||||
}
|
||||
}
|
174
yarn.lock
Normal file
174
yarn.lock
Normal file
|
@ -0,0 +1,174 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@bazel/typescript@^2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-2.2.0.tgz#f2d3dce8715d574fe3146f19fdb8479abcc4d608"
|
||||
integrity sha512-Thf8pXntBzE3EvJtyiTBNsfIf1QnYmGPQmUSGLcKUuuFoplUVYShMRHaxBoPZmYsnD/x+BFLgUKIzlXiEQpGqQ==
|
||||
dependencies:
|
||||
protobufjs "6.8.8"
|
||||
semver "5.6.0"
|
||||
source-map-support "0.5.9"
|
||||
tsutils "2.27.2"
|
||||
|
||||
"@improbable-eng/grpc-web@0.13.0":
|
||||
version "0.13.0"
|
||||
resolved "https://registry.yarnpkg.com/@improbable-eng/grpc-web/-/grpc-web-0.13.0.tgz#289e6fc4dafc00b1af8e2b93b970e6892299014d"
|
||||
integrity sha512-vaxxT+Qwb7GPqDQrBV4vAAfH0HywgOLw6xGIKXd9Q8hcV63CQhmS3p4+pZ9/wVvt4Ph3ZDK9fdC983b9aGMUFg==
|
||||
dependencies:
|
||||
browser-headers "^0.4.0"
|
||||
|
||||
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
|
||||
integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78=
|
||||
|
||||
"@protobufjs/base64@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735"
|
||||
integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==
|
||||
|
||||
"@protobufjs/codegen@^2.0.4":
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb"
|
||||
integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==
|
||||
|
||||
"@protobufjs/eventemitter@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70"
|
||||
integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A=
|
||||
|
||||
"@protobufjs/fetch@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45"
|
||||
integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=
|
||||
dependencies:
|
||||
"@protobufjs/aspromise" "^1.1.1"
|
||||
"@protobufjs/inquire" "^1.1.0"
|
||||
|
||||
"@protobufjs/float@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1"
|
||||
integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=
|
||||
|
||||
"@protobufjs/inquire@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089"
|
||||
integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=
|
||||
|
||||
"@protobufjs/path@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d"
|
||||
integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=
|
||||
|
||||
"@protobufjs/pool@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54"
|
||||
integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=
|
||||
|
||||
"@protobufjs/utf8@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
|
||||
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
|
||||
|
||||
"@roleypoly/ts-protoc-gen@^1.0.1-promises.1":
|
||||
version "1.0.1-promises.1"
|
||||
resolved "https://registry.yarnpkg.com/@roleypoly/ts-protoc-gen/-/ts-protoc-gen-1.0.1-promises.1.tgz#6102bb3539d3100957ad54df474bce8ea915aa45"
|
||||
integrity sha512-I9OLiFRusAFH3uYG186BzheXNiEMKr9HpLUD1/Q4/gYNH+LwJhDAdBrHSXoi/beTq/MLomtjPxvjfOzl46996g==
|
||||
dependencies:
|
||||
google-protobuf "^3.6.1"
|
||||
|
||||
"@types/google-protobuf@3.7.3":
|
||||
version "3.7.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/google-protobuf/-/google-protobuf-3.7.3.tgz#429512e541bbd777f2c867692e6335ee08d1f6d4"
|
||||
integrity sha512-FRwj40euE2bYkG+0X5w2nEA8yAzgJRcEa7RBd0Gsdkb9/tPM2pctVVAvnOUTbcXo2VmIHPo0Ae94Gl9vRHfKzg==
|
||||
|
||||
"@types/long@^4.0.0":
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"
|
||||
integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==
|
||||
|
||||
"@types/node@^10.1.0":
|
||||
version "10.17.32"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.32.tgz#4ef6ff8b842ea0eb3fcbc4331489f4ae64036fa8"
|
||||
integrity sha512-EUq+cjH/3KCzQHikGnNbWAGe548IFLSm93Vl8xA7EuYEEATiyOVDyEVuGkowL7c9V69FF/RiZSAOCFPApMs/ig==
|
||||
|
||||
browser-headers@^0.4.0:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/browser-headers/-/browser-headers-0.4.1.tgz#4308a7ad3b240f4203dbb45acedb38dc2d65dd02"
|
||||
integrity sha512-CA9hsySZVo9371qEHjHZtYxV2cFtVj5Wj/ZHi8ooEsrtm4vOnl9Y9HmyYWk9q+05d7K3rdoAE0j3MVEFVvtQtg==
|
||||
|
||||
buffer-from@^1.0.0:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
|
||||
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
|
||||
|
||||
google-protobuf@3.13.0, google-protobuf@^3.6.1:
|
||||
version "3.13.0"
|
||||
resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.13.0.tgz#909c5983d75dd6101ed57c79e0528d000cdc3251"
|
||||
integrity sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw==
|
||||
|
||||
long@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
|
||||
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
|
||||
|
||||
prettier@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6"
|
||||
integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==
|
||||
|
||||
protobufjs@6.8.8:
|
||||
version "6.8.8"
|
||||
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c"
|
||||
integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==
|
||||
dependencies:
|
||||
"@protobufjs/aspromise" "^1.1.2"
|
||||
"@protobufjs/base64" "^1.1.2"
|
||||
"@protobufjs/codegen" "^2.0.4"
|
||||
"@protobufjs/eventemitter" "^1.1.0"
|
||||
"@protobufjs/fetch" "^1.1.0"
|
||||
"@protobufjs/float" "^1.0.2"
|
||||
"@protobufjs/inquire" "^1.1.0"
|
||||
"@protobufjs/path" "^1.1.2"
|
||||
"@protobufjs/pool" "^1.1.0"
|
||||
"@protobufjs/utf8" "^1.1.0"
|
||||
"@types/long" "^4.0.0"
|
||||
"@types/node" "^10.1.0"
|
||||
long "^4.0.0"
|
||||
|
||||
semver@5.6.0:
|
||||
version "5.6.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
|
||||
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
|
||||
|
||||
source-map-support@0.5.9:
|
||||
version "0.5.9"
|
||||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
|
||||
integrity sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==
|
||||
dependencies:
|
||||
buffer-from "^1.0.0"
|
||||
source-map "^0.6.0"
|
||||
|
||||
source-map@^0.6.0:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
tslib@^1.8.1:
|
||||
version "1.13.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043"
|
||||
integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==
|
||||
|
||||
tsutils@2.27.2:
|
||||
version "2.27.2"
|
||||
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7"
|
||||
integrity sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg==
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
typescript@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"
|
||||
integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==
|
Loading…
Add table
Reference in a new issue