diff --git a/go.mod b/go.mod index ff3ca733..f146b202 100644 --- a/go.mod +++ b/go.mod @@ -71,7 +71,7 @@ require ( github.com/vmihailenco/msgpack/v5 v5.0.0-beta.9 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/zclconf/go-cty v1.8.0 // indirect - golang.org/x/crypto v0.9.0 // indirect + golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect diff --git a/go.sum b/go.sum index 42e3e37a..472aac2c 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJu github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20221230185412-738e83a70c30 h1:m9O6OTJ627iFnN2JIWfdqlZCzneRO6EEBsHXI25P8ws= golang.org/x/exp v0.0.0-20221230185412-738e83a70c30/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= @@ -203,8 +203,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= 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.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/internal/calibre/model.go b/internal/calibre/model.go index abd743aa..b70dfff2 100644 --- a/internal/calibre/model.go +++ b/internal/calibre/model.go @@ -1,6 +1,9 @@ package calibre -import "time" +import ( + "path" + "time" +) type Author struct { ID int64 `json:"id"` @@ -34,6 +37,10 @@ type Book struct { Series []Series `json:"series,omitempty" gorm:"many2many:books_series_link;foreignKey:id;joinForeignKey:book;References:ID;JoinReferences:series"` } +func (b *Book) FullPath(c Calibre) string { + return path.Join(c.LibraryPath(), b.Path) +} + type Identifier struct { ID int64 `json:"id"` BookID int64 `json:"bookId" gorm:"column:book"` diff --git a/internal/calibre/store.go b/internal/calibre/store.go index 213dcec4..749d61ff 100644 --- a/internal/calibre/store.go +++ b/internal/calibre/store.go @@ -2,6 +2,7 @@ package calibre import ( "context" + "path" gormLogger "github.com/mpalmer/gorm-zerolog" "github.com/rs/zerolog" @@ -11,6 +12,8 @@ import ( ) type Calibre interface { + LibraryPath() string + GetAuthor(ctx context.Context, id int64) (*Author, error) GetAuthors(ctx context.Context) ([]*Author, error) GetAuthorBooks(ctx context.Context, id int64) ([]*Book, error) @@ -40,16 +43,32 @@ type Calibre interface { } type CalibreSQLite struct { - db *gorm.DB + libraryPath string + db *gorm.DB } -func NewCalibreSQLite(dbPath string) (*CalibreSQLite, error) { +func NewCalibreSQLite(libraryPath string) (*CalibreSQLite, error) { + dbPath := path.Join(libraryPath, "metadata.db") db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{}) if err != nil { return nil, err } - return &CalibreSQLite{db: db}, nil + ret := &CalibreSQLite{ + libraryPath: libraryPath, + db: db, + } + return ret, nil +} + +func (c *CalibreSQLite) Clone() *CalibreSQLite { + return &CalibreSQLite{ + libraryPath: c.libraryPath, + db: c.db.Session(&gorm.Session{}), + } +} +func (c *CalibreSQLite) LibraryPath() string { + return c.libraryPath } func (c *CalibreSQLite) Close() error { @@ -60,14 +79,14 @@ func (c *CalibreSQLite) Close() error { return db.Close() } -func (c *CalibreSQLite) WithLogger(logger *zerolog.Logger) Calibre { - return &CalibreSQLite{ - db: c.db.Session( - &gorm.Session{ - Logger: gormLogger.Logger{}, - }, - ), - } +func (c *CalibreSQLite) WithLogger(logger *zerolog.Logger) *CalibreSQLite { + ret := c.Clone() + ret.db = ret.db.Session( + &gorm.Session{ + Logger: gormLogger.Logger{}, + }, + ) + return ret } func (c *CalibreSQLite) WithPagination(page, pageSize int) Calibre { diff --git a/internal/calibre/store_test.go b/internal/calibre/store_test.go index 96948ab2..4271ec68 100644 --- a/internal/calibre/store_test.go +++ b/internal/calibre/store_test.go @@ -8,6 +8,8 @@ import ( "github.com/stretchr/testify/require" ) +const TestDB = "test_fixtures/models_only" + func TestGetAuthor(t *testing.T) { tests := []struct { name string @@ -44,7 +46,7 @@ func TestGetAuthor(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -63,7 +65,7 @@ func TestGetAuthors(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -106,7 +108,7 @@ func TestGetAuthorBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -161,7 +163,7 @@ func TestGetAuthorSeries(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -309,7 +311,7 @@ func TestGetBook(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -357,7 +359,7 @@ func TestGetBookByIdentifier(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -377,7 +379,7 @@ func TestGetBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -435,7 +437,7 @@ func TestGetBooks_WithPagination(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -492,7 +494,7 @@ func TestGetTag(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -511,7 +513,7 @@ func TestGetTags(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -554,7 +556,7 @@ func TestGetTagBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -610,7 +612,7 @@ func TestGetPublisher(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -629,7 +631,7 @@ func TestGetPublishers(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -677,7 +679,7 @@ func TestGetPublisherBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -740,7 +742,7 @@ func TestGetLanguage(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -759,7 +761,7 @@ func TestGetLanguages(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -792,7 +794,7 @@ func TestGetLanguageBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -837,7 +839,7 @@ func TestGetSeries(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -856,7 +858,7 @@ func TestGetSeriesList(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } @@ -895,7 +897,7 @@ func TestGetSeriesBooks(t *testing.T) { t.Parallel() require := require.New(t) - db, err := NewCalibreSQLite("test_fixtures/metadata.db") + db, err := NewCalibreSQLite(TestDB) if err != nil { t.Fatal(err) } diff --git a/internal/calibre/tasks/import.go b/internal/calibre/tasks/import.go index d51832e3..751fb957 100644 --- a/internal/calibre/tasks/import.go +++ b/internal/calibre/tasks/import.go @@ -2,120 +2,33 @@ package tasks import ( "context" + "errors" "fmt" + "io/fs" "lybbrio/internal/calibre" "lybbrio/internal/ent" + "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/schema/filetype" "lybbrio/internal/ent/schema/ksuid" - "lybbrio/internal/task" + "lybbrio/internal/scheduler" + "os" + "path/filepath" + "slices" "strings" "github.com/rs/zerolog/log" ) -type importOutputCtxKey string - -const importOutputKey importOutputCtxKey = "importOutput" - -type importContext struct { - visitedAuthors map[int64]ksuid.ID - visitedTags map[int64]ksuid.ID - visitedPublishers map[int64]ksuid.ID - visitedLanguages map[int64]ksuid.ID - visitedSeries map[int64]ksuid.ID - failedBooks []string -} - -func newImportContext() *importContext { - return &importContext{ - visitedAuthors: make(map[int64]ksuid.ID), - visitedTags: make(map[int64]ksuid.ID), - visitedPublishers: make(map[int64]ksuid.ID), - visitedLanguages: make(map[int64]ksuid.ID), - visitedSeries: make(map[int64]ksuid.ID), - } -} - -func (c *importContext) String() string { - var ret strings.Builder - if len(c.failedBooks) > 0 { - ret.WriteString("Failed Books:\n") - for _, book := range c.failedBooks { - ret.WriteString(fmt.Sprintf("\t%s\n", book)) - } - } - return ret.String() -} - -func (c *importContext) AddFailedBook(book string) { - c.failedBooks = append(c.failedBooks, book) -} - -func (c *importContext) AuthorVisited(id int64) (ksuid.ID, bool) { - ret, ok := c.visitedAuthors[id] - return ret, ok -} - -func (c *importContext) AddAuthorVisited(id int64, ksuid ksuid.ID) { - c.visitedAuthors[id] = ksuid -} - -func (c *importContext) TagVisited(id int64) (ksuid.ID, bool) { - ret, ok := c.visitedTags[id] - return ret, ok -} - -func (c *importContext) AddTagVisited(id int64, ksuid ksuid.ID) { - c.visitedTags[id] = ksuid -} - -func (c *importContext) PublisherVisited(id int64) (ksuid.ID, bool) { - ret, ok := c.visitedPublishers[id] - return ret, ok -} - -func (c *importContext) AddPublisherVisited(id int64, ksuid ksuid.ID) { - c.visitedPublishers[id] = ksuid -} - -func (c *importContext) LanguageVisited(id int64) (ksuid.ID, bool) { - ret, ok := c.visitedLanguages[id] - return ret, ok -} - -func (c *importContext) AddLanguageVisited(id int64, ksuid ksuid.ID) { - c.visitedLanguages[id] = ksuid -} - -func (c *importContext) SeriesVisited(id int64) (ksuid.ID, bool) { - ret, ok := c.visitedSeries[id] - return ret, ok -} - -func (c *importContext) AddSeriesVisited(id int64, ksuid ksuid.ID) { - c.visitedSeries[id] = ksuid -} - -func importContextFrom(ctx context.Context) *importContext { - output := ctx.Value(importOutputKey) - if output == nil { - return nil - } - return output.(*importContext) -} - -func importContextTo(ctx context.Context, output *importContext) context.Context { - return context.WithValue(ctx, importOutputKey, output) -} - -func ImportTask(cal calibre.Calibre, client *ent.Client) task.TaskFunc { - return func(ctx context.Context, task *ent.Task, cb task.ProgressCallback) (string, error) { +func ImportTask(cal calibre.Calibre, client *ent.Client) scheduler.TaskFunc { + return func(ctx context.Context, task *ent.Task, cb scheduler.ProgressCallback) (string, error) { log := log.Ctx(ctx) log.Info().Interface("task", task.ID.String()).Msg("ImportTask") ic := newImportContext() ctx = importContextTo(ctx, ic) - err := ImportBooks(cal, client, ctx, cb) + err := importBooks(ctx, cal, client, cb) if err != nil { return "", err } @@ -124,112 +37,129 @@ func ImportTask(cal calibre.Calibre, client *ent.Client) task.TaskFunc { } } -func ImportBooks(cal calibre.Calibre, client *ent.Client, ctx context.Context, cb task.ProgressCallback) error { - books, err := cal.GetBooks(ctx) +func importBooks(ctx context.Context, cal calibre.Calibre, client *ent.Client, cb scheduler.ProgressCallback) error { + calibreBooks, err := cal.GetBooks(ctx) if err != nil { return err } - total := len(books) - for idx, book := range books { - ic := importContextFrom(ctx) - - bookCreate := client.Book.Create(). - SetTitle(book.Title). - SetSort(book.Sort). - SetCalibreID(book.ID). - SetIsbn(book.ISBN). - SetPath(book.Path). - SetDescription(book.Comments.Text) - if book.PubDate != nil { - bookCreate.SetPublishedDate(*book.PubDate) + ic := importContextFrom(ctx) + total := len(calibreBooks) + for idx, calBook := range calibreBooks { + err := importBook(ctx, cal, client, *calBook) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to import book") } - if book.SeriesIndex != nil { - bookCreate.SetSeriesIndex(*book.SeriesIndex) + if err := cb(float64(idx+1) / (float64(total))); err != nil { + ic.AddFailedBook(calBook.Title) + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to update progress") } + } - entBook, err := bookCreate. - Save(ctx) - if err != nil { - if ent.IsConstraintError(err) { - log.Debug().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Book already exists") - } else { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create book") - ic.AddFailedBook(book.Title) - } - if err := cb(float64(idx+1) / (float64(total))); err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to update progress") + return nil +} + +func importBook(ctx context.Context, cal calibre.Calibre, client *ent.Client, calBook calibre.Book) error { + + bookCreate := client.Book.Create(). + SetTitle(calBook.Title). + SetSort(calBook.Sort). + SetCalibreID(calBook.ID). + SetIsbn(calBook.ISBN). + SetPath(calBook.Path). + SetDescription(calBook.Comments.Text) + if calBook.PubDate != nil { + bookCreate.SetPublishedDate(*calBook.PubDate) + } + if calBook.SeriesIndex != nil { + bookCreate.SetSeriesIndex(*calBook.SeriesIndex) + } + + var entBook *ent.Book + var err error + entBook, err = bookCreate. + Save(ctx) + if err != nil { + if ent.IsConstraintError(err) { + log.Debug().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Book already exists") + entBook, err = client.Book.Query(). + Where(book.CalibreIDEQ(int64(calBook.ID))). + Only(ctx) + if err != nil { + return fmt.Errorf("failed to query existing book: %w", err) } - continue + } else { + return fmt.Errorf("failed to create book: %w", err) } + } - err = createOrAttachAuthors(client, ctx, entBook, book.Authors) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create authors") - } + err = createOrAttachAuthors(ctx, client, entBook, calBook.Authors) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create authors") + } - err = createIdentifiers(ctx, client, entBook, book.Identifiers) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create identifiers") - } + err = createIdentifiers(ctx, client, entBook, calBook.Identifiers) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create identifiers") + } - err = createOrAttachTags(ctx, client, entBook, book.Tags) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create tags") - } + err = createOrAttachTags(ctx, client, entBook, calBook.Tags) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create tags") + } - err = createOrAttachPublishers(ctx, client, entBook, book.Publisher) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create publishers") - } + err = createOrAttachPublishers(ctx, client, entBook, calBook.Publisher) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create publishers") + } - err = createOrAttachLanguages(ctx, client, entBook, book.Languages) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create languages") - } + err = createOrAttachLanguages(ctx, client, entBook, calBook.Languages) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create languages") + } - err = createOrAttachSeriesList(ctx, client, entBook, book.Series) - if err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to create series") - } - if err := cb(float64(idx+1) / (float64(total))); err != nil { - log.Warn().Err(err). - Str("book", book.Title). - Int64("bookID", book.ID). - Msg("Failed to update progress") - } + err = createOrAttachSeriesList(ctx, client, entBook, calBook.Series) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed to create series") } + err = registerBookFiles(ctx, cal, client, entBook, calBook) + if err != nil { + log.Warn().Err(err). + Str("book", calBook.Title). + Int64("bookID", calBook.ID). + Msg("Failed register book files") + } return nil } -func createOrAttachAuthors(client *ent.Client, ctx context.Context, book *ent.Book, authors []calibre.Author) error { +func createOrAttachAuthors(ctx context.Context, client *ent.Client, book *ent.Book, authors []calibre.Author) error { log := log.Ctx(ctx).With().Str("book", book.Title).Str("bookID", book.ID.String()).Logger() for _, a := range authors { err := createOrAttachAuthor(ctx, client, book, a) @@ -429,6 +359,61 @@ func createOrAttachSeries(ctx context.Context, client *ent.Client, book *ent.Boo return nil } +func registerBookFiles(ctx context.Context, cal calibre.Calibre, client *ent.Client, book *ent.Book, calBook calibre.Book) error { + log := log.Ctx(ctx).With().Str("book", calBook.Title).Str("bookID", book.ID.String()).Logger() + path := calBook.FullPath(cal) + log.Trace().Str("path", path).Msg("Registering book files") + files, err := os.ReadDir(calBook.FullPath(cal)) + if err != nil { + return fmt.Errorf("failed to read book directory: %w", err) + } + for _, file := range files { + if file.IsDir() { + continue + } + path := filepath.Join(calBook.FullPath(cal), file.Name()) + err := registerBookFile(ctx, client, book.ID, path, file) + if err != nil { + if inner := errors.Unwrap(err); ent.IsConstraintError(inner) { + continue + } + log.Warn().Err(err). + Str("file", file.Name()). + Msg("Failed to register file") + } + } + return nil +} + +func registerBookFile(ctx context.Context, client *ent.Client, bookID ksuid.ID, path string, file fs.DirEntry) error { + ext := strings.ToLower(filepath.Ext(file.Name())) + nameWithoutExt := strings.TrimSuffix(file.Name(), ext) + if slices.Contains(ignorableFilenames, nameWithoutExt) { + return nil + } + + filetype := filetype.FromExtension(ext) + if filetype == 0 { + return errors.New("unknown file type") + } + info, err := file.Info() + if err != nil { + return fmt.Errorf("failed to get file info: %w", err) + } + size := info.Size() + _, err = client.BookFile.Create(). + SetName(file.Name()). + SetPath(path). + SetSize(size). + SetFormat(bookfile.Format(filetype.String())). + SetBookID(bookID). + Save(ctx) + if err != nil { + return fmt.Errorf("failed to create book file: %w", err) + } + return nil +} + // TODO: This really should be as simple as a bulk upsert, but this is blocked by https://github.com/ent/ent/issues/3868 // Example of how to do bulk upserts post https://github.com/ent/ent/issues/3868 // func createOrAttachTags(client *ent.Client, ctx context.Context, book *ent.Book, tags []calibre.Tag) error { diff --git a/internal/calibre/tasks/import_context.go b/internal/calibre/tasks/import_context.go new file mode 100644 index 00000000..26972a48 --- /dev/null +++ b/internal/calibre/tasks/import_context.go @@ -0,0 +1,108 @@ +package tasks + +import ( + "context" + "fmt" + "lybbrio/internal/ent/schema/ksuid" + "strings" +) + +type importOutputCtxKey string + +const importOutputKey importOutputCtxKey = "importOutput" + +var ignorableFilenames []string = []string{ + "cover", + "metadata", +} + +type importContext struct { + visitedAuthors map[int64]ksuid.ID + visitedTags map[int64]ksuid.ID + visitedPublishers map[int64]ksuid.ID + visitedLanguages map[int64]ksuid.ID + visitedSeries map[int64]ksuid.ID + failedBooks []string +} + +func newImportContext() *importContext { + return &importContext{ + visitedAuthors: make(map[int64]ksuid.ID), + visitedTags: make(map[int64]ksuid.ID), + visitedPublishers: make(map[int64]ksuid.ID), + visitedLanguages: make(map[int64]ksuid.ID), + visitedSeries: make(map[int64]ksuid.ID), + } +} + +func (c *importContext) String() string { + var ret strings.Builder + if len(c.failedBooks) > 0 { + ret.WriteString("Failed Books:\n") + for _, book := range c.failedBooks { + ret.WriteString(fmt.Sprintf("\t%s\n", book)) + } + } + return ret.String() +} + +func (c *importContext) AddFailedBook(book string) { + c.failedBooks = append(c.failedBooks, book) +} + +func (c *importContext) AuthorVisited(id int64) (ksuid.ID, bool) { + ret, ok := c.visitedAuthors[id] + return ret, ok +} + +func (c *importContext) AddAuthorVisited(id int64, ksuid ksuid.ID) { + c.visitedAuthors[id] = ksuid +} + +func (c *importContext) TagVisited(id int64) (ksuid.ID, bool) { + ret, ok := c.visitedTags[id] + return ret, ok +} + +func (c *importContext) AddTagVisited(id int64, ksuid ksuid.ID) { + c.visitedTags[id] = ksuid +} + +func (c *importContext) PublisherVisited(id int64) (ksuid.ID, bool) { + ret, ok := c.visitedPublishers[id] + return ret, ok +} + +func (c *importContext) AddPublisherVisited(id int64, ksuid ksuid.ID) { + c.visitedPublishers[id] = ksuid +} + +func (c *importContext) LanguageVisited(id int64) (ksuid.ID, bool) { + ret, ok := c.visitedLanguages[id] + return ret, ok +} + +func (c *importContext) AddLanguageVisited(id int64, ksuid ksuid.ID) { + c.visitedLanguages[id] = ksuid +} + +func (c *importContext) SeriesVisited(id int64) (ksuid.ID, bool) { + ret, ok := c.visitedSeries[id] + return ret, ok +} + +func (c *importContext) AddSeriesVisited(id int64, ksuid ksuid.ID) { + c.visitedSeries[id] = ksuid +} + +func importContextFrom(ctx context.Context) *importContext { + output := ctx.Value(importOutputKey) + if output == nil { + return nil + } + return output.(*importContext) +} + +func importContextTo(ctx context.Context, output *importContext) context.Context { + return context.WithValue(ctx, importOutputKey, output) +} diff --git a/internal/calibre/tasks/import_context_test.go b/internal/calibre/tasks/import_context_test.go new file mode 100644 index 00000000..d56df5cc --- /dev/null +++ b/internal/calibre/tasks/import_context_test.go @@ -0,0 +1,112 @@ +package tasks + +import ( + "context" + "testing" + + "lybbrio/internal/ent/schema/ksuid" + + "github.com/stretchr/testify/require" +) + +func Test_AddFailedBook(t *testing.T) { + require := require.New(t) + c := newImportContext() + c.AddFailedBook("test") + require.Equal([]string{"test"}, c.failedBooks) +} + +func Test_AuthorVisited(t *testing.T) { + require := require.New(t) + c := newImportContext() + expected := ksuid.MustNew("aut") + c.AddAuthorVisited(1, expected) + kid, ok := c.AuthorVisited(1) + require.True(ok) + require.Equal(expected, kid) + + _, ok = c.AuthorVisited(2) + require.False(ok) +} + +func Test_TagVisited(t *testing.T) { + require := require.New(t) + c := newImportContext() + expected := ksuid.MustNew("tag") + c.AddTagVisited(1, expected) + kid, ok := c.TagVisited(1) + require.True(ok) + require.Equal(expected, kid) + + _, ok = c.TagVisited(2) + require.False(ok) +} + +func Test_PublisherVisited(t *testing.T) { + require := require.New(t) + c := newImportContext() + expected := ksuid.MustNew("pub") + c.AddPublisherVisited(1, expected) + kid, ok := c.PublisherVisited(1) + require.True(ok) + require.Equal(expected, kid) + + _, ok = c.PublisherVisited(2) + require.False(ok) +} + +func Test_LanguageVisited(t *testing.T) { + require := require.New(t) + c := newImportContext() + expected := ksuid.MustNew("lan") + c.AddLanguageVisited(1, expected) + kid, ok := c.LanguageVisited(1) + require.True(ok) + require.Equal(expected, kid) + + _, ok = c.LanguageVisited(2) + require.False(ok) +} + +func Test_SeriesVisited(t *testing.T) { + require := require.New(t) + c := newImportContext() + expected := ksuid.MustNew("ser") + c.AddSeriesVisited(1, expected) + kid, ok := c.SeriesVisited(1) + require.True(ok) + require.Equal(expected, kid) + + _, ok = c.SeriesVisited(2) + require.False(ok) +} + +func Test_ImportContext(t *testing.T) { + require := require.New(t) + ic := newImportContext() + ctx := context.Background() + ctx = importContextTo(ctx, ic) + require.NotNil(ctx) + + ic2 := importContextFrom(ctx) + require.NotNil(ic2) + require.Equal(ic, ic2) +} + +func Test_ImportContext_ReturnsNilWhenNotAttached(t *testing.T) { + require := require.New(t) + ctx := context.Background() + ic := importContextFrom(ctx) + require.Nil(ic) +} + +func Test_ImportContext_String(t *testing.T) { + require := require.New(t) + ic := newImportContext() + require.Empty(ic.String()) + ic.AddFailedBook("test") + ic.AddFailedBook("test2") + + require.Contains(ic.String(), "test") + require.Contains(ic.String(), "test2") +} diff --git a/internal/calibre/tasks/tasks.go b/internal/calibre/tasks/tasks.go index 5d827225..99357fda 100644 --- a/internal/calibre/tasks/tasks.go +++ b/internal/calibre/tasks/tasks.go @@ -4,11 +4,11 @@ import ( "lybbrio/internal/calibre" "lybbrio/internal/ent" "lybbrio/internal/ent/schema/task_enums" - "lybbrio/internal/task" + "lybbrio/internal/scheduler" ) -func TaskMap(cal calibre.Calibre, client *ent.Client) task.TaskMap { - return task.TaskMap{ +func TaskMap(cal calibre.Calibre, client *ent.Client) scheduler.TaskMap { + return scheduler.TaskMap{ task_enums.TypeCalibreImport: ImportTask(cal, client), } } diff --git a/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/Twenty Thousand Leagues under t - Jules Verne.epub b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/Twenty Thousand Leagues under t - Jules Verne.epub new file mode 100644 index 00000000..bac1fc7f Binary files /dev/null and b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/Twenty Thousand Leagues under t - Jules Verne.epub differ diff --git a/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/cover.jpg b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/cover.jpg new file mode 100644 index 00000000..5a27e242 Binary files /dev/null and b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/cover.jpg differ diff --git a/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/metadata.opf b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/metadata.opf new file mode 100644 index 00000000..cb13df01 --- /dev/null +++ b/internal/calibre/test_fixtures/importable/Jules Verne/Twenty Thousand Leagues under the Se (2)/metadata.opf @@ -0,0 +1,23 @@ + + + + 2 + ddd74199-4e97-4e61-aa75-5a26c754b4e9 + Twenty Thousand Leagues under the Sea + Jules Verne + calibre (7.2.0) [https://calibre-ebook.com] + 1994-09-01T08:00:00+00:00 + http://www.gutenberg.org/164 + eng + Science fiction + Submarines (Ships) -- Fiction + Sea stories + Adventure stories + Underwater exploration -- Fiction + + + + + + + diff --git a/internal/calibre/test_fixtures/importable/metadata.db b/internal/calibre/test_fixtures/importable/metadata.db new file mode 100644 index 00000000..d2e36e9e Binary files /dev/null and b/internal/calibre/test_fixtures/importable/metadata.db differ diff --git a/internal/calibre/test_fixtures/metadata.db b/internal/calibre/test_fixtures/models_only/metadata.db similarity index 100% rename from internal/calibre/test_fixtures/metadata.db rename to internal/calibre/test_fixtures/models_only/metadata.db diff --git a/internal/commands/root.go b/internal/commands/root.go index 283fffb6..4ed0d6c0 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -30,7 +30,7 @@ import ( "lybbrio/internal/graph" "lybbrio/internal/metrics" "lybbrio/internal/middleware" - "lybbrio/internal/task" + "lybbrio/internal/scheduler" "lybbrio/internal/viewer" ) @@ -147,8 +147,8 @@ func rootRun(_ *cobra.Command, _ []string) { } // Calibre - cal, error := calibre.NewCalibreSQLite(conf.CalibreDBPath) - cal = cal.WithLogger(&log.Logger).(*calibre.CalibreSQLite) + cal, error := calibre.NewCalibreSQLite(conf.CalibreLibraryPath) + cal = cal.WithLogger(&log.Logger) if error != nil { log.Fatal().Err(error).Msg("Failed to initialize Calibre") @@ -168,9 +168,9 @@ func rootRun(_ *cobra.Command, _ []string) { // Task Scheduler schedulerVC := viewer.NewSystemAdminContext(schedulerCtx) - workerPool := task.NewWorkerPool( + workerPool := scheduler.NewWorkerPool( client, - &task.WorkerPoolConfig{ + &scheduler.WorkerPoolConfig{ Ctx: schedulerVC, NumWorkers: conf.Task.Workers, QueueLength: conf.Task.QueueLength, @@ -178,9 +178,9 @@ func rootRun(_ *cobra.Command, _ []string) { ) workerPool.Start() - scheduler := task.NewScheduler( + scheduler := scheduler.NewScheduler( client, - &task.SchedulerConfig{ + &scheduler.SchedulerConfig{ Ctx: schedulerVC, WorkQueue: workerPool.WorkQueue(), Cadence: conf.Task.Cadence, diff --git a/internal/config/config.go b/internal/config/config.go index 5909171b..d7b32f90 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -28,7 +28,7 @@ var defaultSettings = map[string]interface{}{ "interface": "127.0.0.1", "go-collector": true, "process-collector": true, - "calibre-db-path": "database/metadata.db", + "calibre-library-path": "./books/", "db": map[string]interface{}{ "driver": "sqlite3", "dsn": "file:database/app.db?cache=shared&_fk=1", @@ -55,7 +55,7 @@ func RegisterFlags(flagSet *flag.FlagSet) { flagSet.Bool("process-collector", false, "Enable process prometheus collector") flagSet.Int("port", 8080, "Port to Listen On") flagSet.String("interface", "127.0.0.1", "Interface") - flagSet.String("calibre-db-path", "/database/metadata.db", "Path to Calibre database") + flagSet.String("calibre-library-path", "./books/", "Path to Calibre database") flagSet.String("db.driver", "sqlite3", "Database driver") flagSet.String("db.dsn", "file:database/app.db?cache=shared&_fk=1", "Database DSN") flagSet.Int("db.max-idle-conns", 10, "Database max idle connections") @@ -97,7 +97,7 @@ type Config struct { GoCollector bool `koanf:"go-collector"` ProcessCollector bool `koanf:"process-collector"` - CalibreDBPath string `koanf:"calibre-db-path" validate:"required"` + CalibreLibraryPath string `koanf:"calibre-library-path" validate:"required"` DB DatabaseConfig `koanf:"db"` Task TaskConfig `koanf:"task"` @@ -191,7 +191,7 @@ func (c Config) Translates() map[string]string { "ProcessCollector": "process-collector", "Port": "port", "Interface": "interface", - "CalibreDBPath": "calibre-db-path", + "CalibreLibraryPath": "calibre-library-path", } } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index da04f36c..4fb7d822 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -29,7 +29,7 @@ func Test_LoadConfig_Defaults(t *testing.T) { require.Equal(defaultSettings["interface"], config.Interface) require.Equal(defaultSettings["go-collector"], config.GoCollector) require.Equal(defaultSettings["process-collector"], config.ProcessCollector) - require.Equal(defaultSettings["calibre-db-path"], config.CalibreDBPath) + require.Equal(defaultSettings["calibre-library-path"], config.CalibreLibraryPath) db := defaultSettings["db"].(map[string]interface{}) require.Equal(db["driver"], config.DB.Driver) @@ -67,7 +67,7 @@ func Test_LoadConfig_Flags(t *testing.T) { flags.Set("process-collector", "false") flags.Set("port", "7070") flags.Set("interface", "192.0.2.1") // "TEST-NET" in RFC 5737 - flags.Set("calibre-db-path", "/tmp/calibre.db") + flags.Set("calibre-library-path", "/tmp/") flags.Set("db.driver", "postgres") flags.Set("db.dsn", "postgres://user:pass@localhost:5432/dbname?sslmode=disable") flags.Set("db.max-idle-conns", "20") @@ -90,7 +90,7 @@ func Test_LoadConfig_Flags(t *testing.T) { require.False(config.GoCollector) require.False(config.ProcessCollector) require.Equal(7070, config.Port) - require.Equal("/tmp/calibre.db", config.CalibreDBPath) + require.Equal("/tmp/", config.CalibreLibraryPath) require.Equal("postgres", config.DB.Driver) require.Equal("postgres://user:pass@localhost:5432/dbname?sslmode=disable", config.DB.DSN) require.Equal(20, config.DB.MaxIdleConns) @@ -116,7 +116,7 @@ func Test_LoadConfig_Env(t *testing.T) { t.Setenv("PROCESS_COLLECTOR", "false") t.Setenv("PORT", "7070") t.Setenv("INTERFACE", "192.0.2.1") // "TEST-NET" in RFC 5737 - t.Setenv("CALIBRE_DB_PATH", "/tmp/calibre.db") + t.Setenv("CALIBRE_LIBRARY_PATH", "/tmp/") t.Setenv("DB__DRIVER", "postgres") t.Setenv("DB__DSN", "postgres://user:pass@localhost:5432/dbname?sslmode=disable") t.Setenv("DB__MAX_IDLE_CONNS", "20") @@ -139,7 +139,7 @@ func Test_LoadConfig_Env(t *testing.T) { require.False(config.GoCollector) require.False(config.ProcessCollector) require.Equal(7070, config.Port) - require.Equal("/tmp/calibre.db", config.CalibreDBPath) + require.Equal("/tmp/", config.CalibreLibraryPath) require.Equal("postgres", config.DB.Driver) require.Equal("postgres://user:pass@localhost:5432/dbname?sslmode=disable", config.DB.DSN) require.Equal(20, config.DB.MaxIdleConns) @@ -194,7 +194,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "sqlite3", DSN: "file::memory:?cache=shared"}, Task: TaskConfig{Workers: 10, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", @@ -214,7 +214,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "sqlite3", DSN: "file::memory:?cache=shared"}, Task: TaskConfig{Workers: 10, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", @@ -234,7 +234,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "sqlite3", DSN: "file::memory:?cache=shared"}, Task: TaskConfig{Workers: 10, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", @@ -254,7 +254,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "invalid", DSN: "file::memory:?cache=shared"}, Task: TaskConfig{Workers: 10, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", @@ -274,7 +274,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "invalid", DSN: ""}, Task: TaskConfig{Workers: 10, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", @@ -294,7 +294,7 @@ func Test_Validate(t *testing.T) { Interface: "192.0.2.1", // "TEST-NET" in RFC 5737 GoCollector: false, ProcessCollector: false, - CalibreDBPath: "/tmp/calibre.db", + CalibreLibraryPath: "/tmp/", DB: DatabaseConfig{Driver: "invalid", DSN: ""}, Task: TaskConfig{Workers: -1, QueueLength: 100, Cadence: 5 * time.Second}, JWTSecret: "asdf", diff --git a/internal/ent/author.go b/internal/ent/author.go index 03244595..9f604fe5 100644 --- a/internal/ent/author.go +++ b/internal/ent/author.go @@ -7,6 +7,7 @@ import ( "lybbrio/internal/ent/author" "lybbrio/internal/ent/schema/ksuid" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -17,6 +18,10 @@ type Author struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Name holds the value of the "name" field. @@ -62,6 +67,8 @@ func (*Author) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case author.FieldID, author.FieldName, author.FieldSort, author.FieldLink: values[i] = new(sql.NullString) + case author.FieldCreateTime, author.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -83,6 +90,18 @@ func (a *Author) assignValues(columns []string, values []any) error { } else if value.Valid { a.ID = ksuid.ID(value.String) } + case author.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + a.CreateTime = value.Time + } + case author.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + a.UpdateTime = value.Time + } case author.FieldCalibreID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[i]) @@ -148,6 +167,12 @@ func (a *Author) String() string { var builder strings.Builder builder.WriteString("Author(") builder.WriteString(fmt.Sprintf("id=%v, ", a.ID)) + builder.WriteString("create_time=") + builder.WriteString(a.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(a.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", a.CalibreID)) builder.WriteString(", ") diff --git a/internal/ent/author/author.go b/internal/ent/author/author.go index 4fdf28fc..4cbcfd7f 100644 --- a/internal/ent/author/author.go +++ b/internal/ent/author/author.go @@ -4,6 +4,7 @@ package author import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "author" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldName holds the string denoting the name field in the database. @@ -37,6 +42,8 @@ const ( // Columns holds all SQL columns for author fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldName, FieldSort, @@ -67,6 +74,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error // DefaultID holds the default value on creation for the "id" field. @@ -81,6 +94,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() diff --git a/internal/ent/author/where.go b/internal/ent/author/where.go index bbd61638..82a6cf49 100644 --- a/internal/ent/author/where.go +++ b/internal/ent/author/where.go @@ -5,6 +5,7 @@ package author import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Author { return predicate.Author(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Author { + return predicate.Author(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Author { + return predicate.Author(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Author { return predicate.Author(sql.FieldEQ(FieldCalibreID, v)) @@ -75,6 +86,86 @@ func Link(v string) predicate.Author { return predicate.Author(sql.FieldEQ(FieldLink, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Author { + return predicate.Author(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Author { + return predicate.Author(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Author { + return predicate.Author(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Author { + return predicate.Author(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Author { + return predicate.Author(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Author { + return predicate.Author(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Author { + return predicate.Author(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Author { + return predicate.Author(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Author { + return predicate.Author(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Author { + return predicate.Author(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Author { + return predicate.Author(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Author { + return predicate.Author(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Author { + return predicate.Author(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Author { + return predicate.Author(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Author { + return predicate.Author(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Author { + return predicate.Author(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Author { return predicate.Author(sql.FieldEQ(FieldCalibreID, v)) diff --git a/internal/ent/author_create.go b/internal/ent/author_create.go index de4902ab..cbb021d7 100644 --- a/internal/ent/author_create.go +++ b/internal/ent/author_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,6 +25,34 @@ type AuthorCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (ac *AuthorCreate) SetCreateTime(t time.Time) *AuthorCreate { + ac.mutation.SetCreateTime(t) + return ac +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (ac *AuthorCreate) SetNillableCreateTime(t *time.Time) *AuthorCreate { + if t != nil { + ac.SetCreateTime(*t) + } + return ac +} + +// SetUpdateTime sets the "update_time" field. +func (ac *AuthorCreate) SetUpdateTime(t time.Time) *AuthorCreate { + ac.mutation.SetUpdateTime(t) + return ac +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (ac *AuthorCreate) SetNillableUpdateTime(t *time.Time) *AuthorCreate { + if t != nil { + ac.SetUpdateTime(*t) + } + return ac +} + // SetCalibreID sets the "calibre_id" field. func (ac *AuthorCreate) SetCalibreID(i int64) *AuthorCreate { ac.mutation.SetCalibreID(i) @@ -130,6 +159,20 @@ func (ac *AuthorCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (ac *AuthorCreate) defaults() error { + if _, ok := ac.mutation.CreateTime(); !ok { + if author.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized author.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := author.DefaultCreateTime() + ac.mutation.SetCreateTime(v) + } + if _, ok := ac.mutation.UpdateTime(); !ok { + if author.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized author.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := author.DefaultUpdateTime() + ac.mutation.SetUpdateTime(v) + } if _, ok := ac.mutation.ID(); !ok { if author.DefaultID == nil { return fmt.Errorf("ent: uninitialized author.DefaultID (forgotten import ent/runtime?)") @@ -142,6 +185,12 @@ func (ac *AuthorCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (ac *AuthorCreate) check() error { + if _, ok := ac.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Author.create_time"`)} + } + if _, ok := ac.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Author.update_time"`)} + } if _, ok := ac.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Author.name"`)} } @@ -189,6 +238,14 @@ func (ac *AuthorCreate) createSpec() (*Author, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := ac.mutation.CreateTime(); ok { + _spec.SetField(author.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := ac.mutation.UpdateTime(); ok { + _spec.SetField(author.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := ac.mutation.CalibreID(); ok { _spec.SetField(author.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -228,7 +285,7 @@ func (ac *AuthorCreate) createSpec() (*Author, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Author.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -237,7 +294,7 @@ func (ac *AuthorCreate) createSpec() (*Author, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.AuthorUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (ac *AuthorCreate) OnConflict(opts ...sql.ConflictOption) *AuthorUpsertOne { @@ -273,6 +330,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *AuthorUpsert) SetUpdateTime(v time.Time) *AuthorUpsert { + u.Set(author.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *AuthorUpsert) UpdateUpdateTime() *AuthorUpsert { + u.SetExcluded(author.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *AuthorUpsert) SetCalibreID(v int64) *AuthorUpsert { u.Set(author.FieldCalibreID, v) @@ -356,6 +425,9 @@ func (u *AuthorUpsertOne) UpdateNewValues() *AuthorUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(author.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(author.FieldCreateTime) + } })) return u } @@ -387,6 +459,20 @@ func (u *AuthorUpsertOne) Update(set func(*AuthorUpsert)) *AuthorUpsertOne { return u } +// SetUpdateTime sets the "update_time" field. +func (u *AuthorUpsertOne) SetUpdateTime(v time.Time) *AuthorUpsertOne { + return u.Update(func(s *AuthorUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *AuthorUpsertOne) UpdateUpdateTime() *AuthorUpsertOne { + return u.Update(func(s *AuthorUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *AuthorUpsertOne) SetCalibreID(v int64) *AuthorUpsertOne { return u.Update(func(s *AuthorUpsert) { @@ -600,7 +686,7 @@ func (acb *AuthorCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.AuthorUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (acb *AuthorCreateBulk) OnConflict(opts ...sql.ConflictOption) *AuthorUpsertBulk { @@ -647,6 +733,9 @@ func (u *AuthorUpsertBulk) UpdateNewValues() *AuthorUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(author.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(author.FieldCreateTime) + } } })) return u @@ -679,6 +768,20 @@ func (u *AuthorUpsertBulk) Update(set func(*AuthorUpsert)) *AuthorUpsertBulk { return u } +// SetUpdateTime sets the "update_time" field. +func (u *AuthorUpsertBulk) SetUpdateTime(v time.Time) *AuthorUpsertBulk { + return u.Update(func(s *AuthorUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *AuthorUpsertBulk) UpdateUpdateTime() *AuthorUpsertBulk { + return u.Update(func(s *AuthorUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *AuthorUpsertBulk) SetCalibreID(v int64) *AuthorUpsertBulk { return u.Update(func(s *AuthorUpsert) { diff --git a/internal/ent/author_query.go b/internal/ent/author_query.go index ae7164f2..1b1bfeaf 100644 --- a/internal/ent/author_query.go +++ b/internal/ent/author_query.go @@ -303,12 +303,12 @@ func (aq *AuthorQuery) WithBooks(opts ...func(*BookQuery)) *AuthorQuery { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Author.Query(). -// GroupBy(author.FieldCalibreID). +// GroupBy(author.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (aq *AuthorQuery) GroupBy(field string, fields ...string) *AuthorGroupBy { @@ -326,11 +326,11 @@ func (aq *AuthorQuery) GroupBy(field string, fields ...string) *AuthorGroupBy { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Author.Query(). -// Select(author.FieldCalibreID). +// Select(author.FieldCreateTime). // Scan(ctx, &v) func (aq *AuthorQuery) Select(fields ...string) *AuthorSelect { aq.ctx.Fields = append(aq.ctx.Fields, fields...) diff --git a/internal/ent/author_update.go b/internal/ent/author_update.go index 093591ff..eceb9efa 100644 --- a/internal/ent/author_update.go +++ b/internal/ent/author_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/book" "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (au *AuthorUpdate) Where(ps ...predicate.Author) *AuthorUpdate { return au } +// SetUpdateTime sets the "update_time" field. +func (au *AuthorUpdate) SetUpdateTime(t time.Time) *AuthorUpdate { + au.mutation.SetUpdateTime(t) + return au +} + // SetCalibreID sets the "calibre_id" field. func (au *AuthorUpdate) SetCalibreID(i int64) *AuthorUpdate { au.mutation.ResetCalibreID() @@ -147,6 +154,9 @@ func (au *AuthorUpdate) RemoveBooks(b ...*Book) *AuthorUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (au *AuthorUpdate) Save(ctx context.Context) (int, error) { + if err := au.defaults(); err != nil { + return 0, err + } return withHooks(ctx, au.sqlSave, au.mutation, au.hooks) } @@ -172,6 +182,18 @@ func (au *AuthorUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (au *AuthorUpdate) defaults() error { + if _, ok := au.mutation.UpdateTime(); !ok { + if author.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized author.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := author.UpdateDefaultUpdateTime() + au.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (au *AuthorUpdate) check() error { if v, ok := au.mutation.Name(); ok { @@ -194,6 +216,9 @@ func (au *AuthorUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := au.mutation.UpdateTime(); ok { + _spec.SetField(author.FieldUpdateTime, field.TypeTime, value) + } if value, ok := au.mutation.CalibreID(); ok { _spec.SetField(author.FieldCalibreID, field.TypeInt64, value) } @@ -280,6 +305,12 @@ type AuthorUpdateOne struct { mutation *AuthorMutation } +// SetUpdateTime sets the "update_time" field. +func (auo *AuthorUpdateOne) SetUpdateTime(t time.Time) *AuthorUpdateOne { + auo.mutation.SetUpdateTime(t) + return auo +} + // SetCalibreID sets the "calibre_id" field. func (auo *AuthorUpdateOne) SetCalibreID(i int64) *AuthorUpdateOne { auo.mutation.ResetCalibreID() @@ -411,6 +442,9 @@ func (auo *AuthorUpdateOne) Select(field string, fields ...string) *AuthorUpdate // Save executes the query and returns the updated Author entity. func (auo *AuthorUpdateOne) Save(ctx context.Context) (*Author, error) { + if err := auo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks) } @@ -436,6 +470,18 @@ func (auo *AuthorUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (auo *AuthorUpdateOne) defaults() error { + if _, ok := auo.mutation.UpdateTime(); !ok { + if author.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized author.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := author.UpdateDefaultUpdateTime() + auo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (auo *AuthorUpdateOne) check() error { if v, ok := auo.mutation.Name(); ok { @@ -475,6 +521,9 @@ func (auo *AuthorUpdateOne) sqlSave(ctx context.Context) (_node *Author, err err } } } + if value, ok := auo.mutation.UpdateTime(); ok { + _spec.SetField(author.FieldUpdateTime, field.TypeTime, value) + } if value, ok := auo.mutation.CalibreID(); ok { _spec.SetField(author.FieldCalibreID, field.TypeInt64, value) } diff --git a/internal/ent/book.go b/internal/ent/book.go index e48370ea..032ee15d 100644 --- a/internal/ent/book.go +++ b/internal/ent/book.go @@ -18,6 +18,10 @@ type Book struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Title holds the value of the "title" field. @@ -56,11 +60,13 @@ type BookEdges struct { Language []*Language `json:"language,omitempty"` // Shelf holds the value of the shelf edge. Shelf []*Shelf `json:"shelf,omitempty"` + // Files holds the value of the files edge. + Files []*BookFile `json:"files,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [7]bool + loadedTypes [8]bool // totalCount holds the count of the edges above. - totalCount [7]map[string]int + totalCount [8]map[string]int namedAuthors map[string][]*Author namedPublisher map[string][]*Publisher @@ -69,6 +75,7 @@ type BookEdges struct { namedTags map[string][]*Tag namedLanguage map[string][]*Language namedShelf map[string][]*Shelf + namedFiles map[string][]*BookFile } // AuthorsOrErr returns the Authors value or an error if the edge @@ -134,6 +141,15 @@ func (e BookEdges) ShelfOrErr() ([]*Shelf, error) { return nil, &NotLoadedError{edge: "shelf"} } +// FilesOrErr returns the Files value or an error if the edge +// was not loaded in eager-loading. +func (e BookEdges) FilesOrErr() ([]*BookFile, error) { + if e.loadedTypes[7] { + return e.Files, nil + } + return nil, &NotLoadedError{edge: "files"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Book) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -145,7 +161,7 @@ func (*Book) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case book.FieldID, book.FieldTitle, book.FieldSort, book.FieldPath, book.FieldIsbn, book.FieldDescription: values[i] = new(sql.NullString) - case book.FieldPublishedDate: + case book.FieldCreateTime, book.FieldUpdateTime, book.FieldPublishedDate: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) @@ -168,6 +184,18 @@ func (b *Book) assignValues(columns []string, values []any) error { } else if value.Valid { b.ID = ksuid.ID(value.String) } + case book.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + b.CreateTime = value.Time + } + case book.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + b.UpdateTime = value.Time + } case book.FieldCalibreID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[i]) @@ -264,6 +292,11 @@ func (b *Book) QueryShelf() *ShelfQuery { return NewBookClient(b.config).QueryShelf(b) } +// QueryFiles queries the "files" edge of the Book entity. +func (b *Book) QueryFiles() *BookFileQuery { + return NewBookClient(b.config).QueryFiles(b) +} + // Update returns a builder for updating this Book. // Note that you need to call Book.Unwrap() before calling this method if this Book // was returned from a transaction, and the transaction was committed or rolled back. @@ -287,6 +320,12 @@ func (b *Book) String() string { var builder strings.Builder builder.WriteString("Book(") builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("create_time=") + builder.WriteString(b.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(b.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", b.CalibreID)) builder.WriteString(", ") @@ -482,5 +521,29 @@ func (b *Book) appendNamedShelf(name string, edges ...*Shelf) { } } +// NamedFiles returns the Files named value or an error if the edge was not +// loaded in eager-loading with this name. +func (b *Book) NamedFiles(name string) ([]*BookFile, error) { + if b.Edges.namedFiles == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := b.Edges.namedFiles[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (b *Book) appendNamedFiles(name string, edges ...*BookFile) { + if b.Edges.namedFiles == nil { + b.Edges.namedFiles = make(map[string][]*BookFile) + } + if len(edges) == 0 { + b.Edges.namedFiles[name] = []*BookFile{} + } else { + b.Edges.namedFiles[name] = append(b.Edges.namedFiles[name], edges...) + } +} + // Books is a parsable slice of Book. type Books []*Book diff --git a/internal/ent/book/book.go b/internal/ent/book/book.go index b54bf06a..8788454d 100644 --- a/internal/ent/book/book.go +++ b/internal/ent/book/book.go @@ -4,6 +4,7 @@ package book import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "book" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldTitle holds the string denoting the title field in the database. @@ -45,6 +50,8 @@ const ( EdgeLanguage = "language" // EdgeShelf holds the string denoting the shelf edge name in mutations. EdgeShelf = "shelf" + // EdgeFiles holds the string denoting the files edge name in mutations. + EdgeFiles = "files" // Table holds the table name of the book in the database. Table = "books" // AuthorsTable is the table that holds the authors relation/edge. The primary key declared below. @@ -84,11 +91,20 @@ const ( // ShelfInverseTable is the table name for the Shelf entity. // It exists in this package in order to avoid circular dependency with the "shelf" package. ShelfInverseTable = "shelves" + // FilesTable is the table that holds the files relation/edge. + FilesTable = "book_files" + // FilesInverseTable is the table name for the BookFile entity. + // It exists in this package in order to avoid circular dependency with the "bookfile" package. + FilesInverseTable = "book_files" + // FilesColumn is the table column denoting the files relation/edge. + FilesColumn = "book_file_book" ) // Columns holds all SQL columns for book fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldTitle, FieldSort, @@ -138,6 +154,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // TitleValidator is a validator for the "title" field. It is called by the builders before save. TitleValidator func(string) error // PathValidator is a validator for the "path" field. It is called by the builders before save. @@ -154,6 +176,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() @@ -291,6 +323,20 @@ func ByShelf(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newShelfStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByFilesCount orders the results by files count. +func ByFilesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newFilesStep(), opts...) + } +} + +// ByFiles orders the results by files terms. +func ByFiles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newFilesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newAuthorsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -340,3 +386,10 @@ func newShelfStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, ShelfTable, ShelfPrimaryKey...), ) } +func newFilesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(FilesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, FilesTable, FilesColumn), + ) +} diff --git a/internal/ent/book/where.go b/internal/ent/book/where.go index 025b4d07..c02ddd1f 100644 --- a/internal/ent/book/where.go +++ b/internal/ent/book/where.go @@ -56,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Book { return predicate.Book(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Book { + return predicate.Book(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Book { + return predicate.Book(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Book { return predicate.Book(sql.FieldEQ(FieldCalibreID, v)) @@ -96,6 +106,86 @@ func SeriesIndex(v float64) predicate.Book { return predicate.Book(sql.FieldEQ(FieldSeriesIndex, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Book { + return predicate.Book(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Book { + return predicate.Book(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Book { + return predicate.Book(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Book { + return predicate.Book(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Book { + return predicate.Book(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Book { + return predicate.Book(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Book { + return predicate.Book(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Book { + return predicate.Book(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Book { + return predicate.Book(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Book { + return predicate.Book(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Book { + return predicate.Book(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Book { + return predicate.Book(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Book { + return predicate.Book(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Book { + return predicate.Book(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Book { + return predicate.Book(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Book { + return predicate.Book(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Book { return predicate.Book(sql.FieldEQ(FieldCalibreID, v)) @@ -752,6 +842,29 @@ func HasShelfWith(preds ...predicate.Shelf) predicate.Book { }) } +// HasFiles applies the HasEdge predicate on the "files" edge. +func HasFiles() predicate.Book { + return predicate.Book(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, FilesTable, FilesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasFilesWith applies the HasEdge predicate on the "files" edge with a given conditions (other predicates). +func HasFilesWith(preds ...predicate.BookFile) predicate.Book { + return predicate.Book(func(s *sql.Selector) { + step := newFilesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Book) predicate.Book { return predicate.Book(sql.AndPredicates(predicates...)) diff --git a/internal/ent/book_create.go b/internal/ent/book_create.go index b5dd3c90..23c3541f 100644 --- a/internal/ent/book_create.go +++ b/internal/ent/book_create.go @@ -8,6 +8,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -31,6 +32,34 @@ type BookCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (bc *BookCreate) SetCreateTime(t time.Time) *BookCreate { + bc.mutation.SetCreateTime(t) + return bc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (bc *BookCreate) SetNillableCreateTime(t *time.Time) *BookCreate { + if t != nil { + bc.SetCreateTime(*t) + } + return bc +} + +// SetUpdateTime sets the "update_time" field. +func (bc *BookCreate) SetUpdateTime(t time.Time) *BookCreate { + bc.mutation.SetUpdateTime(t) + return bc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (bc *BookCreate) SetNillableUpdateTime(t *time.Time) *BookCreate { + if t != nil { + bc.SetUpdateTime(*t) + } + return bc +} + // SetCalibreID sets the "calibre_id" field. func (bc *BookCreate) SetCalibreID(i int64) *BookCreate { bc.mutation.SetCalibreID(i) @@ -238,6 +267,21 @@ func (bc *BookCreate) AddShelf(s ...*Shelf) *BookCreate { return bc.AddShelfIDs(ids...) } +// AddFileIDs adds the "files" edge to the BookFile entity by IDs. +func (bc *BookCreate) AddFileIDs(ids ...ksuid.ID) *BookCreate { + bc.mutation.AddFileIDs(ids...) + return bc +} + +// AddFiles adds the "files" edges to the BookFile entity. +func (bc *BookCreate) AddFiles(b ...*BookFile) *BookCreate { + ids := make([]ksuid.ID, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bc.AddFileIDs(ids...) +} + // Mutation returns the BookMutation object of the builder. func (bc *BookCreate) Mutation() *BookMutation { return bc.mutation @@ -275,6 +319,20 @@ func (bc *BookCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (bc *BookCreate) defaults() error { + if _, ok := bc.mutation.CreateTime(); !ok { + if book.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized book.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := book.DefaultCreateTime() + bc.mutation.SetCreateTime(v) + } + if _, ok := bc.mutation.UpdateTime(); !ok { + if book.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized book.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := book.DefaultUpdateTime() + bc.mutation.SetUpdateTime(v) + } if _, ok := bc.mutation.ID(); !ok { if book.DefaultID == nil { return fmt.Errorf("ent: uninitialized book.DefaultID (forgotten import ent/runtime?)") @@ -287,6 +345,12 @@ func (bc *BookCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (bc *BookCreate) check() error { + if _, ok := bc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Book.create_time"`)} + } + if _, ok := bc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Book.update_time"`)} + } if _, ok := bc.mutation.Title(); !ok { return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Book.title"`)} } @@ -342,6 +406,14 @@ func (bc *BookCreate) createSpec() (*Book, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := bc.mutation.CreateTime(); ok { + _spec.SetField(book.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := bc.mutation.UpdateTime(); ok { + _spec.SetField(book.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := bc.mutation.CalibreID(); ok { _spec.SetField(book.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -486,6 +558,22 @@ func (bc *BookCreate) createSpec() (*Book, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := bc.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } @@ -493,7 +581,7 @@ func (bc *BookCreate) createSpec() (*Book, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Book.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -502,7 +590,7 @@ func (bc *BookCreate) createSpec() (*Book, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.BookUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (bc *BookCreate) OnConflict(opts ...sql.ConflictOption) *BookUpsertOne { @@ -538,6 +626,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *BookUpsert) SetUpdateTime(v time.Time) *BookUpsert { + u.Set(book.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookUpsert) UpdateUpdateTime() *BookUpsert { + u.SetExcluded(book.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *BookUpsert) SetCalibreID(v int64) *BookUpsert { u.Set(book.FieldCalibreID, v) @@ -693,6 +793,9 @@ func (u *BookUpsertOne) UpdateNewValues() *BookUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(book.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(book.FieldCreateTime) + } })) return u } @@ -724,6 +827,20 @@ func (u *BookUpsertOne) Update(set func(*BookUpsert)) *BookUpsertOne { return u } +// SetUpdateTime sets the "update_time" field. +func (u *BookUpsertOne) SetUpdateTime(v time.Time) *BookUpsertOne { + return u.Update(func(s *BookUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookUpsertOne) UpdateUpdateTime() *BookUpsertOne { + return u.Update(func(s *BookUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *BookUpsertOne) SetCalibreID(v int64) *BookUpsertOne { return u.Update(func(s *BookUpsert) { @@ -1021,7 +1138,7 @@ func (bcb *BookCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.BookUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (bcb *BookCreateBulk) OnConflict(opts ...sql.ConflictOption) *BookUpsertBulk { @@ -1068,6 +1185,9 @@ func (u *BookUpsertBulk) UpdateNewValues() *BookUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(book.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(book.FieldCreateTime) + } } })) return u @@ -1100,6 +1220,20 @@ func (u *BookUpsertBulk) Update(set func(*BookUpsert)) *BookUpsertBulk { return u } +// SetUpdateTime sets the "update_time" field. +func (u *BookUpsertBulk) SetUpdateTime(v time.Time) *BookUpsertBulk { + return u.Update(func(s *BookUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookUpsertBulk) UpdateUpdateTime() *BookUpsertBulk { + return u.Update(func(s *BookUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *BookUpsertBulk) SetCalibreID(v int64) *BookUpsertBulk { return u.Update(func(s *BookUpsert) { diff --git a/internal/ent/book_query.go b/internal/ent/book_query.go index 8db6e52b..71242234 100644 --- a/internal/ent/book_query.go +++ b/internal/ent/book_query.go @@ -9,6 +9,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" @@ -38,6 +39,7 @@ type BookQuery struct { withTags *TagQuery withLanguage *LanguageQuery withShelf *ShelfQuery + withFiles *BookFileQuery modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Book) error withNamedAuthors map[string]*AuthorQuery @@ -47,6 +49,7 @@ type BookQuery struct { withNamedTags map[string]*TagQuery withNamedLanguage map[string]*LanguageQuery withNamedShelf map[string]*ShelfQuery + withNamedFiles map[string]*BookFileQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -237,6 +240,28 @@ func (bq *BookQuery) QueryShelf() *ShelfQuery { return query } +// QueryFiles chains the current query on the "files" edge. +func (bq *BookQuery) QueryFiles() *BookFileQuery { + query := (&BookFileClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(book.Table, book.FieldID, selector), + sqlgraph.To(bookfile.Table, bookfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, book.FilesTable, book.FilesColumn), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Book entity from the query. // Returns a *NotFoundError when no Book was found. func (bq *BookQuery) First(ctx context.Context) (*Book, error) { @@ -436,6 +461,7 @@ func (bq *BookQuery) Clone() *BookQuery { withTags: bq.withTags.Clone(), withLanguage: bq.withLanguage.Clone(), withShelf: bq.withShelf.Clone(), + withFiles: bq.withFiles.Clone(), // clone intermediate query. sql: bq.sql.Clone(), path: bq.path, @@ -519,18 +545,29 @@ func (bq *BookQuery) WithShelf(opts ...func(*ShelfQuery)) *BookQuery { return bq } +// WithFiles tells the query-builder to eager-load the nodes that are connected to +// the "files" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BookQuery) WithFiles(opts ...func(*BookFileQuery)) *BookQuery { + query := (&BookFileClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withFiles = query + return bq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Book.Query(). -// GroupBy(book.FieldCalibreID). +// GroupBy(book.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (bq *BookQuery) GroupBy(field string, fields ...string) *BookGroupBy { @@ -548,11 +585,11 @@ func (bq *BookQuery) GroupBy(field string, fields ...string) *BookGroupBy { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Book.Query(). -// Select(book.FieldCalibreID). +// Select(book.FieldCreateTime). // Scan(ctx, &v) func (bq *BookQuery) Select(fields ...string) *BookSelect { bq.ctx.Fields = append(bq.ctx.Fields, fields...) @@ -603,7 +640,7 @@ func (bq *BookQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Book, e var ( nodes = []*Book{} _spec = bq.querySpec() - loadedTypes = [7]bool{ + loadedTypes = [8]bool{ bq.withAuthors != nil, bq.withPublisher != nil, bq.withSeries != nil, @@ -611,6 +648,7 @@ func (bq *BookQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Book, e bq.withTags != nil, bq.withLanguage != nil, bq.withShelf != nil, + bq.withFiles != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -683,6 +721,13 @@ func (bq *BookQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Book, e return nil, err } } + if query := bq.withFiles; query != nil { + if err := bq.loadFiles(ctx, query, nodes, + func(n *Book) { n.Edges.Files = []*BookFile{} }, + func(n *Book, e *BookFile) { n.Edges.Files = append(n.Edges.Files, e) }); err != nil { + return nil, err + } + } for name, query := range bq.withNamedAuthors { if err := bq.loadAuthors(ctx, query, nodes, func(n *Book) { n.appendNamedAuthors(name) }, @@ -732,6 +777,13 @@ func (bq *BookQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Book, e return nil, err } } + for name, query := range bq.withNamedFiles { + if err := bq.loadFiles(ctx, query, nodes, + func(n *Book) { n.appendNamedFiles(name) }, + func(n *Book, e *BookFile) { n.appendNamedFiles(name, e) }); err != nil { + return nil, err + } + } for i := range bq.loadTotal { if err := bq.loadTotal[i](ctx, nodes); err != nil { return nil, err @@ -1137,6 +1189,37 @@ func (bq *BookQuery) loadShelf(ctx context.Context, query *ShelfQuery, nodes []* } return nil } +func (bq *BookQuery) loadFiles(ctx context.Context, query *BookFileQuery, nodes []*Book, init func(*Book), assign func(*Book, *BookFile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[ksuid.ID]*Book) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.BookFile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(book.FilesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.book_file_book + if fk == nil { + return fmt.Errorf(`foreign-key "book_file_book" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "book_file_book" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (bq *BookQuery) sqlCount(ctx context.Context) (int, error) { _spec := bq.querySpec() @@ -1320,6 +1403,20 @@ func (bq *BookQuery) WithNamedShelf(name string, opts ...func(*ShelfQuery)) *Boo return bq } +// WithNamedFiles tells the query-builder to eager-load the nodes that are connected to the "files" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (bq *BookQuery) WithNamedFiles(name string, opts ...func(*BookFileQuery)) *BookQuery { + query := (&BookFileClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + if bq.withNamedFiles == nil { + bq.withNamedFiles = make(map[string]*BookFileQuery) + } + bq.withNamedFiles[name] = query + return bq +} + // BookGroupBy is the group-by builder for Book entities. type BookGroupBy struct { selector diff --git a/internal/ent/book_update.go b/internal/ent/book_update.go index e6ef2db0..3b5af2bf 100644 --- a/internal/ent/book_update.go +++ b/internal/ent/book_update.go @@ -8,6 +8,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" @@ -36,6 +37,12 @@ func (bu *BookUpdate) Where(ps ...predicate.Book) *BookUpdate { return bu } +// SetUpdateTime sets the "update_time" field. +func (bu *BookUpdate) SetUpdateTime(t time.Time) *BookUpdate { + bu.mutation.SetUpdateTime(t) + return bu +} + // SetCalibreID sets the "calibre_id" field. func (bu *BookUpdate) SetCalibreID(i int64) *BookUpdate { bu.mutation.ResetCalibreID() @@ -297,6 +304,21 @@ func (bu *BookUpdate) AddShelf(s ...*Shelf) *BookUpdate { return bu.AddShelfIDs(ids...) } +// AddFileIDs adds the "files" edge to the BookFile entity by IDs. +func (bu *BookUpdate) AddFileIDs(ids ...ksuid.ID) *BookUpdate { + bu.mutation.AddFileIDs(ids...) + return bu +} + +// AddFiles adds the "files" edges to the BookFile entity. +func (bu *BookUpdate) AddFiles(b ...*BookFile) *BookUpdate { + ids := make([]ksuid.ID, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bu.AddFileIDs(ids...) +} + // Mutation returns the BookMutation object of the builder. func (bu *BookUpdate) Mutation() *BookMutation { return bu.mutation @@ -449,8 +471,32 @@ func (bu *BookUpdate) RemoveShelf(s ...*Shelf) *BookUpdate { return bu.RemoveShelfIDs(ids...) } +// ClearFiles clears all "files" edges to the BookFile entity. +func (bu *BookUpdate) ClearFiles() *BookUpdate { + bu.mutation.ClearFiles() + return bu +} + +// RemoveFileIDs removes the "files" edge to BookFile entities by IDs. +func (bu *BookUpdate) RemoveFileIDs(ids ...ksuid.ID) *BookUpdate { + bu.mutation.RemoveFileIDs(ids...) + return bu +} + +// RemoveFiles removes "files" edges to BookFile entities. +func (bu *BookUpdate) RemoveFiles(b ...*BookFile) *BookUpdate { + ids := make([]ksuid.ID, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return bu.RemoveFileIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (bu *BookUpdate) Save(ctx context.Context) (int, error) { + if err := bu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) } @@ -476,6 +522,18 @@ func (bu *BookUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (bu *BookUpdate) defaults() error { + if _, ok := bu.mutation.UpdateTime(); !ok { + if book.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized book.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := book.UpdateDefaultUpdateTime() + bu.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (bu *BookUpdate) check() error { if v, ok := bu.mutation.Title(); ok { @@ -503,6 +561,9 @@ func (bu *BookUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := bu.mutation.UpdateTime(); ok { + _spec.SetField(book.FieldUpdateTime, field.TypeTime, value) + } if value, ok := bu.mutation.CalibreID(); ok { _spec.SetField(book.FieldCalibreID, field.TypeInt64, value) } @@ -863,6 +924,51 @@ func (bu *BookUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if bu.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedFilesIDs(); len(nodes) > 0 && !bu.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{book.Label} @@ -883,6 +989,12 @@ type BookUpdateOne struct { mutation *BookMutation } +// SetUpdateTime sets the "update_time" field. +func (buo *BookUpdateOne) SetUpdateTime(t time.Time) *BookUpdateOne { + buo.mutation.SetUpdateTime(t) + return buo +} + // SetCalibreID sets the "calibre_id" field. func (buo *BookUpdateOne) SetCalibreID(i int64) *BookUpdateOne { buo.mutation.ResetCalibreID() @@ -1144,6 +1256,21 @@ func (buo *BookUpdateOne) AddShelf(s ...*Shelf) *BookUpdateOne { return buo.AddShelfIDs(ids...) } +// AddFileIDs adds the "files" edge to the BookFile entity by IDs. +func (buo *BookUpdateOne) AddFileIDs(ids ...ksuid.ID) *BookUpdateOne { + buo.mutation.AddFileIDs(ids...) + return buo +} + +// AddFiles adds the "files" edges to the BookFile entity. +func (buo *BookUpdateOne) AddFiles(b ...*BookFile) *BookUpdateOne { + ids := make([]ksuid.ID, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return buo.AddFileIDs(ids...) +} + // Mutation returns the BookMutation object of the builder. func (buo *BookUpdateOne) Mutation() *BookMutation { return buo.mutation @@ -1296,6 +1423,27 @@ func (buo *BookUpdateOne) RemoveShelf(s ...*Shelf) *BookUpdateOne { return buo.RemoveShelfIDs(ids...) } +// ClearFiles clears all "files" edges to the BookFile entity. +func (buo *BookUpdateOne) ClearFiles() *BookUpdateOne { + buo.mutation.ClearFiles() + return buo +} + +// RemoveFileIDs removes the "files" edge to BookFile entities by IDs. +func (buo *BookUpdateOne) RemoveFileIDs(ids ...ksuid.ID) *BookUpdateOne { + buo.mutation.RemoveFileIDs(ids...) + return buo +} + +// RemoveFiles removes "files" edges to BookFile entities. +func (buo *BookUpdateOne) RemoveFiles(b ...*BookFile) *BookUpdateOne { + ids := make([]ksuid.ID, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return buo.RemoveFileIDs(ids...) +} + // Where appends a list predicates to the BookUpdate builder. func (buo *BookUpdateOne) Where(ps ...predicate.Book) *BookUpdateOne { buo.mutation.Where(ps...) @@ -1311,6 +1459,9 @@ func (buo *BookUpdateOne) Select(field string, fields ...string) *BookUpdateOne // Save executes the query and returns the updated Book entity. func (buo *BookUpdateOne) Save(ctx context.Context) (*Book, error) { + if err := buo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) } @@ -1336,6 +1487,18 @@ func (buo *BookUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (buo *BookUpdateOne) defaults() error { + if _, ok := buo.mutation.UpdateTime(); !ok { + if book.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized book.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := book.UpdateDefaultUpdateTime() + buo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (buo *BookUpdateOne) check() error { if v, ok := buo.mutation.Title(); ok { @@ -1380,6 +1543,9 @@ func (buo *BookUpdateOne) sqlSave(ctx context.Context) (_node *Book, err error) } } } + if value, ok := buo.mutation.UpdateTime(); ok { + _spec.SetField(book.FieldUpdateTime, field.TypeTime, value) + } if value, ok := buo.mutation.CalibreID(); ok { _spec.SetField(book.FieldCalibreID, field.TypeInt64, value) } @@ -1740,6 +1906,51 @@ func (buo *BookUpdateOne) sqlSave(ctx context.Context) (_node *Book, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if buo.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedFilesIDs(); len(nodes) > 0 && !buo.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _node = &Book{config: buo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/internal/ent/bookfile.go b/internal/ent/bookfile.go new file mode 100644 index 00000000..ffb412d0 --- /dev/null +++ b/internal/ent/bookfile.go @@ -0,0 +1,205 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/schema/ksuid" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// BookFile is the model entity for the BookFile schema. +type BookFile struct { + config `json:"-"` + // ID of the ent. + ID ksuid.ID `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"` + // Name holds the value of the "name" field. + Name string `json:"name,omitempty"` + // Path holds the value of the "path" field. + Path string `json:"path,omitempty"` + // Size in bytes + Size int64 `json:"size,omitempty"` + // Format holds the value of the "format" field. + Format bookfile.Format `json:"format,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the BookFileQuery when eager-loading is set. + Edges BookFileEdges `json:"edges"` + book_file_book *ksuid.ID + selectValues sql.SelectValues +} + +// BookFileEdges holds the relations/edges for other nodes in the graph. +type BookFileEdges struct { + // Book holds the value of the book edge. + Book *Book `json:"book,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool + // totalCount holds the count of the edges above. + totalCount [1]map[string]int +} + +// BookOrErr returns the Book value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e BookFileEdges) BookOrErr() (*Book, error) { + if e.loadedTypes[0] { + if e.Book == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: book.Label} + } + return e.Book, nil + } + return nil, &NotLoadedError{edge: "book"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*BookFile) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case bookfile.FieldSize: + values[i] = new(sql.NullInt64) + case bookfile.FieldID, bookfile.FieldName, bookfile.FieldPath, bookfile.FieldFormat: + values[i] = new(sql.NullString) + case bookfile.FieldCreateTime, bookfile.FieldUpdateTime: + values[i] = new(sql.NullTime) + case bookfile.ForeignKeys[0]: // book_file_book + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the BookFile fields. +func (bf *BookFile) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case bookfile.FieldID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field id", values[i]) + } else if value.Valid { + bf.ID = ksuid.ID(value.String) + } + case bookfile.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + bf.CreateTime = value.Time + } + case bookfile.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + bf.UpdateTime = value.Time + } + case bookfile.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + bf.Name = value.String + } + case bookfile.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + bf.Path = value.String + } + case bookfile.FieldSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + bf.Size = value.Int64 + } + case bookfile.FieldFormat: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field format", values[i]) + } else if value.Valid { + bf.Format = bookfile.Format(value.String) + } + case bookfile.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field book_file_book", values[i]) + } else if value.Valid { + bf.book_file_book = new(ksuid.ID) + *bf.book_file_book = ksuid.ID(value.String) + } + default: + bf.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the BookFile. +// This includes values selected through modifiers, order, etc. +func (bf *BookFile) Value(name string) (ent.Value, error) { + return bf.selectValues.Get(name) +} + +// QueryBook queries the "book" edge of the BookFile entity. +func (bf *BookFile) QueryBook() *BookQuery { + return NewBookFileClient(bf.config).QueryBook(bf) +} + +// Update returns a builder for updating this BookFile. +// Note that you need to call BookFile.Unwrap() before calling this method if this BookFile +// was returned from a transaction, and the transaction was committed or rolled back. +func (bf *BookFile) Update() *BookFileUpdateOne { + return NewBookFileClient(bf.config).UpdateOne(bf) +} + +// Unwrap unwraps the BookFile entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (bf *BookFile) Unwrap() *BookFile { + _tx, ok := bf.config.driver.(*txDriver) + if !ok { + panic("ent: BookFile is not a transactional entity") + } + bf.config.driver = _tx.drv + return bf +} + +// String implements the fmt.Stringer. +func (bf *BookFile) String() string { + var builder strings.Builder + builder.WriteString("BookFile(") + builder.WriteString(fmt.Sprintf("id=%v, ", bf.ID)) + builder.WriteString("create_time=") + builder.WriteString(bf.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(bf.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(bf.Name) + builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(bf.Path) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(fmt.Sprintf("%v", bf.Size)) + builder.WriteString(", ") + builder.WriteString("format=") + builder.WriteString(fmt.Sprintf("%v", bf.Format)) + builder.WriteByte(')') + return builder.String() +} + +// BookFiles is a parsable slice of BookFile. +type BookFiles []*BookFile diff --git a/internal/ent/bookfile/bookfile.go b/internal/ent/bookfile/bookfile.go new file mode 100644 index 00000000..5c1df9cf --- /dev/null +++ b/internal/ent/bookfile/bookfile.go @@ -0,0 +1,201 @@ +// Code generated by ent, DO NOT EDIT. + +package bookfile + +import ( + "fmt" + "io" + "lybbrio/internal/ent/schema/ksuid" + "strconv" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the bookfile type in the database. + Label = "book_file" + // 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" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // FieldFormat holds the string denoting the format field in the database. + FieldFormat = "format" + // EdgeBook holds the string denoting the book edge name in mutations. + EdgeBook = "book" + // Table holds the table name of the bookfile in the database. + Table = "book_files" + // BookTable is the table that holds the book relation/edge. + BookTable = "book_files" + // BookInverseTable is the table name for the Book entity. + // It exists in this package in order to avoid circular dependency with the "book" package. + BookInverseTable = "books" + // BookColumn is the table column denoting the book relation/edge. + BookColumn = "book_file_book" +) + +// Columns holds all SQL columns for bookfile fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldPath, + FieldSize, + FieldFormat, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "book_files" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "book_file_book", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "lybbrio/internal/ent/runtime" +var ( + Hooks [1]ent.Hook + Policy ent.Policy + // 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 + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // PathValidator is a validator for the "path" field. It is called by the builders before save. + PathValidator func(string) error + // SizeValidator is a validator for the "size" field. It is called by the builders before save. + SizeValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() ksuid.ID +) + +// Format defines the type for the "format" enum field. +type Format string + +// Format values. +const ( + FormatAZW3 Format = "AZW3" + FormatEPUB Format = "EPUB" + FormatKEPUB Format = "KEPUB" + FormatPDF Format = "PDF" + FormatCBC Format = "CBC" + FormatCBR Format = "CBR" + FormatCB7 Format = "CB7" + FormatCBZ Format = "CBZ" + FormatCBT Format = "CBT" +) + +func (f Format) String() string { + return string(f) +} + +// FormatValidator is a validator for the "format" field enum values. It is called by the builders before save. +func FormatValidator(f Format) error { + switch f { + case FormatAZW3, FormatEPUB, FormatKEPUB, FormatPDF, FormatCBC, FormatCBR, FormatCB7, FormatCBZ, FormatCBT: + return nil + default: + return fmt.Errorf("bookfile: invalid enum value for format field: %q", f) + } +} + +// OrderOption defines the ordering options for the BookFile queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// ByFormat orders the results by the format field. +func ByFormat(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFormat, opts...).ToFunc() +} + +// ByBookField orders the results by book field. +func ByBookField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newBookStep(), sql.OrderByField(field, opts...)) + } +} +func newBookStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(BookInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, BookTable, BookColumn), + ) +} + +// MarshalGQL implements graphql.Marshaler interface. +func (e Format) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(e.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (e *Format) UnmarshalGQL(val interface{}) error { + str, ok := val.(string) + if !ok { + return fmt.Errorf("enum %T must be a string", val) + } + *e = Format(str) + if err := FormatValidator(*e); err != nil { + return fmt.Errorf("%s is not a valid Format", str) + } + return nil +} diff --git a/internal/ent/bookfile/where.go b/internal/ent/bookfile/where.go new file mode 100644 index 00000000..f0d3a71d --- /dev/null +++ b/internal/ent/bookfile/where.go @@ -0,0 +1,390 @@ +// Code generated by ent, DO NOT EDIT. + +package bookfile + +import ( + "lybbrio/internal/ent/predicate" + "lybbrio/internal/ent/schema/ksuid" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id ksuid.ID) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldName, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldPath, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldSize, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldContainsFold(FieldName, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.BookFile { + return predicate.BookFile(sql.FieldContainsFold(FieldPath, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...int64) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...int64) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v int64) predicate.BookFile { + return predicate.BookFile(sql.FieldLTE(FieldSize, v)) +} + +// FormatEQ applies the EQ predicate on the "format" field. +func FormatEQ(v Format) predicate.BookFile { + return predicate.BookFile(sql.FieldEQ(FieldFormat, v)) +} + +// FormatNEQ applies the NEQ predicate on the "format" field. +func FormatNEQ(v Format) predicate.BookFile { + return predicate.BookFile(sql.FieldNEQ(FieldFormat, v)) +} + +// FormatIn applies the In predicate on the "format" field. +func FormatIn(vs ...Format) predicate.BookFile { + return predicate.BookFile(sql.FieldIn(FieldFormat, vs...)) +} + +// FormatNotIn applies the NotIn predicate on the "format" field. +func FormatNotIn(vs ...Format) predicate.BookFile { + return predicate.BookFile(sql.FieldNotIn(FieldFormat, vs...)) +} + +// HasBook applies the HasEdge predicate on the "book" edge. +func HasBook() predicate.BookFile { + return predicate.BookFile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, BookTable, BookColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasBookWith applies the HasEdge predicate on the "book" edge with a given conditions (other predicates). +func HasBookWith(preds ...predicate.Book) predicate.BookFile { + return predicate.BookFile(func(s *sql.Selector) { + step := newBookStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.BookFile) predicate.BookFile { + return predicate.BookFile(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.BookFile) predicate.BookFile { + return predicate.BookFile(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.BookFile) predicate.BookFile { + return predicate.BookFile(sql.NotPredicates(p)) +} diff --git a/internal/ent/bookfile_create.go b/internal/ent/bookfile_create.go new file mode 100644 index 00000000..9a3aeb98 --- /dev/null +++ b/internal/ent/bookfile_create.go @@ -0,0 +1,848 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/schema/ksuid" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BookFileCreate is the builder for creating a BookFile entity. +type BookFileCreate struct { + config + mutation *BookFileMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreateTime sets the "create_time" field. +func (bfc *BookFileCreate) SetCreateTime(t time.Time) *BookFileCreate { + bfc.mutation.SetCreateTime(t) + return bfc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (bfc *BookFileCreate) SetNillableCreateTime(t *time.Time) *BookFileCreate { + if t != nil { + bfc.SetCreateTime(*t) + } + return bfc +} + +// SetUpdateTime sets the "update_time" field. +func (bfc *BookFileCreate) SetUpdateTime(t time.Time) *BookFileCreate { + bfc.mutation.SetUpdateTime(t) + return bfc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (bfc *BookFileCreate) SetNillableUpdateTime(t *time.Time) *BookFileCreate { + if t != nil { + bfc.SetUpdateTime(*t) + } + return bfc +} + +// SetName sets the "name" field. +func (bfc *BookFileCreate) SetName(s string) *BookFileCreate { + bfc.mutation.SetName(s) + return bfc +} + +// SetPath sets the "path" field. +func (bfc *BookFileCreate) SetPath(s string) *BookFileCreate { + bfc.mutation.SetPath(s) + return bfc +} + +// SetSize sets the "size" field. +func (bfc *BookFileCreate) SetSize(i int64) *BookFileCreate { + bfc.mutation.SetSize(i) + return bfc +} + +// SetFormat sets the "format" field. +func (bfc *BookFileCreate) SetFormat(b bookfile.Format) *BookFileCreate { + bfc.mutation.SetFormat(b) + return bfc +} + +// SetID sets the "id" field. +func (bfc *BookFileCreate) SetID(k ksuid.ID) *BookFileCreate { + bfc.mutation.SetID(k) + return bfc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (bfc *BookFileCreate) SetNillableID(k *ksuid.ID) *BookFileCreate { + if k != nil { + bfc.SetID(*k) + } + return bfc +} + +// SetBookID sets the "book" edge to the Book entity by ID. +func (bfc *BookFileCreate) SetBookID(id ksuid.ID) *BookFileCreate { + bfc.mutation.SetBookID(id) + return bfc +} + +// SetBook sets the "book" edge to the Book entity. +func (bfc *BookFileCreate) SetBook(b *Book) *BookFileCreate { + return bfc.SetBookID(b.ID) +} + +// Mutation returns the BookFileMutation object of the builder. +func (bfc *BookFileCreate) Mutation() *BookFileMutation { + return bfc.mutation +} + +// Save creates the BookFile in the database. +func (bfc *BookFileCreate) Save(ctx context.Context) (*BookFile, error) { + if err := bfc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, bfc.sqlSave, bfc.mutation, bfc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bfc *BookFileCreate) SaveX(ctx context.Context) *BookFile { + v, err := bfc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bfc *BookFileCreate) Exec(ctx context.Context) error { + _, err := bfc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfc *BookFileCreate) ExecX(ctx context.Context) { + if err := bfc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bfc *BookFileCreate) defaults() error { + if _, ok := bfc.mutation.CreateTime(); !ok { + if bookfile.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized bookfile.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := bookfile.DefaultCreateTime() + bfc.mutation.SetCreateTime(v) + } + if _, ok := bfc.mutation.UpdateTime(); !ok { + if bookfile.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized bookfile.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := bookfile.DefaultUpdateTime() + bfc.mutation.SetUpdateTime(v) + } + if _, ok := bfc.mutation.ID(); !ok { + if bookfile.DefaultID == nil { + return fmt.Errorf("ent: uninitialized bookfile.DefaultID (forgotten import ent/runtime?)") + } + v := bookfile.DefaultID() + bfc.mutation.SetID(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (bfc *BookFileCreate) check() error { + if _, ok := bfc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "BookFile.create_time"`)} + } + if _, ok := bfc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "BookFile.update_time"`)} + } + if _, ok := bfc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "BookFile.name"`)} + } + if v, ok := bfc.mutation.Name(); ok { + if err := bookfile.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "BookFile.name": %w`, err)} + } + } + if _, ok := bfc.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "BookFile.path"`)} + } + if v, ok := bfc.mutation.Path(); ok { + if err := bookfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "BookFile.path": %w`, err)} + } + } + if _, ok := bfc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "BookFile.size"`)} + } + if v, ok := bfc.mutation.Size(); ok { + if err := bookfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "BookFile.size": %w`, err)} + } + } + if _, ok := bfc.mutation.Format(); !ok { + return &ValidationError{Name: "format", err: errors.New(`ent: missing required field "BookFile.format"`)} + } + if v, ok := bfc.mutation.Format(); ok { + if err := bookfile.FormatValidator(v); err != nil { + return &ValidationError{Name: "format", err: fmt.Errorf(`ent: validator failed for field "BookFile.format": %w`, err)} + } + } + if _, ok := bfc.mutation.BookID(); !ok { + return &ValidationError{Name: "book", err: errors.New(`ent: missing required edge "BookFile.book"`)} + } + return nil +} + +func (bfc *BookFileCreate) sqlSave(ctx context.Context) (*BookFile, error) { + if err := bfc.check(); err != nil { + return nil, err + } + _node, _spec := bfc.createSpec() + if err := sqlgraph.CreateNode(ctx, bfc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != nil { + if id, ok := _spec.ID.Value.(ksuid.ID); ok { + _node.ID = id + } else { + return nil, fmt.Errorf("unexpected BookFile.ID type: %T", _spec.ID.Value) + } + } + bfc.mutation.id = &_node.ID + bfc.mutation.done = true + return _node, nil +} + +func (bfc *BookFileCreate) createSpec() (*BookFile, *sqlgraph.CreateSpec) { + var ( + _node = &BookFile{config: bfc.config} + _spec = sqlgraph.NewCreateSpec(bookfile.Table, sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString)) + ) + _spec.OnConflict = bfc.conflict + if id, ok := bfc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := bfc.mutation.CreateTime(); ok { + _spec.SetField(bookfile.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := bfc.mutation.UpdateTime(); ok { + _spec.SetField(bookfile.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := bfc.mutation.Name(); ok { + _spec.SetField(bookfile.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := bfc.mutation.Path(); ok { + _spec.SetField(bookfile.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := bfc.mutation.Size(); ok { + _spec.SetField(bookfile.FieldSize, field.TypeInt64, value) + _node.Size = value + } + if value, ok := bfc.mutation.Format(); ok { + _spec.SetField(bookfile.FieldFormat, field.TypeEnum, value) + _node.Format = value + } + if nodes := bfc.mutation.BookIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(book.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.book_file_book = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.BookFile.Create(). +// SetCreateTime(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BookFileUpsert) { +// SetCreateTime(v+v). +// }). +// Exec(ctx) +func (bfc *BookFileCreate) OnConflict(opts ...sql.ConflictOption) *BookFileUpsertOne { + bfc.conflict = opts + return &BookFileUpsertOne{ + create: bfc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bfc *BookFileCreate) OnConflictColumns(columns ...string) *BookFileUpsertOne { + bfc.conflict = append(bfc.conflict, sql.ConflictColumns(columns...)) + return &BookFileUpsertOne{ + create: bfc, + } +} + +type ( + // BookFileUpsertOne is the builder for "upsert"-ing + // one BookFile node. + BookFileUpsertOne struct { + create *BookFileCreate + } + + // BookFileUpsert is the "OnConflict" setter. + BookFileUpsert struct { + *sql.UpdateSet + } +) + +// SetUpdateTime sets the "update_time" field. +func (u *BookFileUpsert) SetUpdateTime(v time.Time) *BookFileUpsert { + u.Set(bookfile.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookFileUpsert) UpdateUpdateTime() *BookFileUpsert { + u.SetExcluded(bookfile.FieldUpdateTime) + return u +} + +// SetName sets the "name" field. +func (u *BookFileUpsert) SetName(v string) *BookFileUpsert { + u.Set(bookfile.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *BookFileUpsert) UpdateName() *BookFileUpsert { + u.SetExcluded(bookfile.FieldName) + return u +} + +// SetPath sets the "path" field. +func (u *BookFileUpsert) SetPath(v string) *BookFileUpsert { + u.Set(bookfile.FieldPath, v) + return u +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *BookFileUpsert) UpdatePath() *BookFileUpsert { + u.SetExcluded(bookfile.FieldPath) + return u +} + +// SetSize sets the "size" field. +func (u *BookFileUpsert) SetSize(v int64) *BookFileUpsert { + u.Set(bookfile.FieldSize, v) + return u +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *BookFileUpsert) UpdateSize() *BookFileUpsert { + u.SetExcluded(bookfile.FieldSize) + return u +} + +// AddSize adds v to the "size" field. +func (u *BookFileUpsert) AddSize(v int64) *BookFileUpsert { + u.Add(bookfile.FieldSize, v) + return u +} + +// SetFormat sets the "format" field. +func (u *BookFileUpsert) SetFormat(v bookfile.Format) *BookFileUpsert { + u.Set(bookfile.FieldFormat, v) + return u +} + +// UpdateFormat sets the "format" field to the value that was provided on create. +func (u *BookFileUpsert) UpdateFormat() *BookFileUpsert { + u.SetExcluded(bookfile.FieldFormat) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(bookfile.FieldID) +// }), +// ). +// Exec(ctx) +func (u *BookFileUpsertOne) UpdateNewValues() *BookFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.ID(); exists { + s.SetIgnore(bookfile.FieldID) + } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(bookfile.FieldCreateTime) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BookFileUpsertOne) Ignore() *BookFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BookFileUpsertOne) DoNothing() *BookFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BookFileCreate.OnConflict +// documentation for more info. +func (u *BookFileUpsertOne) Update(set func(*BookFileUpsert)) *BookFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BookFileUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdateTime sets the "update_time" field. +func (u *BookFileUpsertOne) SetUpdateTime(v time.Time) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookFileUpsertOne) UpdateUpdateTime() *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.UpdateUpdateTime() + }) +} + +// SetName sets the "name" field. +func (u *BookFileUpsertOne) SetName(v string) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *BookFileUpsertOne) UpdateName() *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.UpdateName() + }) +} + +// SetPath sets the "path" field. +func (u *BookFileUpsertOne) SetPath(v string) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *BookFileUpsertOne) UpdatePath() *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.UpdatePath() + }) +} + +// SetSize sets the "size" field. +func (u *BookFileUpsertOne) SetSize(v int64) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *BookFileUpsertOne) AddSize(v int64) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *BookFileUpsertOne) UpdateSize() *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.UpdateSize() + }) +} + +// SetFormat sets the "format" field. +func (u *BookFileUpsertOne) SetFormat(v bookfile.Format) *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.SetFormat(v) + }) +} + +// UpdateFormat sets the "format" field to the value that was provided on create. +func (u *BookFileUpsertOne) UpdateFormat() *BookFileUpsertOne { + return u.Update(func(s *BookFileUpsert) { + s.UpdateFormat() + }) +} + +// Exec executes the query. +func (u *BookFileUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BookFileCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BookFileUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *BookFileUpsertOne) ID(ctx context.Context) (id ksuid.ID, err error) { + if u.create.driver.Dialect() == dialect.MySQL { + // In case of "ON CONFLICT", there is no way to get back non-numeric ID + // fields from the database since MySQL does not support the RETURNING clause. + return id, errors.New("ent: BookFileUpsertOne.ID is not supported by MySQL driver. Use BookFileUpsertOne.Exec instead") + } + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *BookFileUpsertOne) IDX(ctx context.Context) ksuid.ID { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// BookFileCreateBulk is the builder for creating many BookFile entities in bulk. +type BookFileCreateBulk struct { + config + err error + builders []*BookFileCreate + conflict []sql.ConflictOption +} + +// Save creates the BookFile entities in the database. +func (bfcb *BookFileCreateBulk) Save(ctx context.Context) ([]*BookFile, error) { + if bfcb.err != nil { + return nil, bfcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(bfcb.builders)) + nodes := make([]*BookFile, len(bfcb.builders)) + mutators := make([]Mutator, len(bfcb.builders)) + for i := range bfcb.builders { + func(i int, root context.Context) { + builder := bfcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BookFileMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, bfcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = bfcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bfcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + mutation.done = true + 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, bfcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bfcb *BookFileCreateBulk) SaveX(ctx context.Context) []*BookFile { + v, err := bfcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bfcb *BookFileCreateBulk) Exec(ctx context.Context) error { + _, err := bfcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfcb *BookFileCreateBulk) ExecX(ctx context.Context) { + if err := bfcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.BookFile.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.BookFileUpsert) { +// SetCreateTime(v+v). +// }). +// Exec(ctx) +func (bfcb *BookFileCreateBulk) OnConflict(opts ...sql.ConflictOption) *BookFileUpsertBulk { + bfcb.conflict = opts + return &BookFileUpsertBulk{ + create: bfcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bfcb *BookFileCreateBulk) OnConflictColumns(columns ...string) *BookFileUpsertBulk { + bfcb.conflict = append(bfcb.conflict, sql.ConflictColumns(columns...)) + return &BookFileUpsertBulk{ + create: bfcb, + } +} + +// BookFileUpsertBulk is the builder for "upsert"-ing +// a bulk of BookFile nodes. +type BookFileUpsertBulk struct { + create *BookFileCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// sql.ResolveWith(func(u *sql.UpdateSet) { +// u.SetIgnore(bookfile.FieldID) +// }), +// ). +// Exec(ctx) +func (u *BookFileUpsertBulk) UpdateNewValues() *BookFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.ID(); exists { + s.SetIgnore(bookfile.FieldID) + } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(bookfile.FieldCreateTime) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.BookFile.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BookFileUpsertBulk) Ignore() *BookFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *BookFileUpsertBulk) DoNothing() *BookFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BookFileCreateBulk.OnConflict +// documentation for more info. +func (u *BookFileUpsertBulk) Update(set func(*BookFileUpsert)) *BookFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BookFileUpsert{UpdateSet: update}) + })) + return u +} + +// SetUpdateTime sets the "update_time" field. +func (u *BookFileUpsertBulk) SetUpdateTime(v time.Time) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *BookFileUpsertBulk) UpdateUpdateTime() *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.UpdateUpdateTime() + }) +} + +// SetName sets the "name" field. +func (u *BookFileUpsertBulk) SetName(v string) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *BookFileUpsertBulk) UpdateName() *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.UpdateName() + }) +} + +// SetPath sets the "path" field. +func (u *BookFileUpsertBulk) SetPath(v string) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *BookFileUpsertBulk) UpdatePath() *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.UpdatePath() + }) +} + +// SetSize sets the "size" field. +func (u *BookFileUpsertBulk) SetSize(v int64) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *BookFileUpsertBulk) AddSize(v int64) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *BookFileUpsertBulk) UpdateSize() *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.UpdateSize() + }) +} + +// SetFormat sets the "format" field. +func (u *BookFileUpsertBulk) SetFormat(v bookfile.Format) *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.SetFormat(v) + }) +} + +// UpdateFormat sets the "format" field to the value that was provided on create. +func (u *BookFileUpsertBulk) UpdateFormat() *BookFileUpsertBulk { + return u.Update(func(s *BookFileUpsert) { + s.UpdateFormat() + }) +} + +// Exec executes the query. +func (u *BookFileUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the BookFileCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BookFileCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BookFileUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/bookfile_delete.go b/internal/ent/bookfile_delete.go new file mode 100644 index 00000000..b8fc4b9b --- /dev/null +++ b/internal/ent/bookfile_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BookFileDelete is the builder for deleting a BookFile entity. +type BookFileDelete struct { + config + hooks []Hook + mutation *BookFileMutation +} + +// Where appends a list predicates to the BookFileDelete builder. +func (bfd *BookFileDelete) Where(ps ...predicate.BookFile) *BookFileDelete { + bfd.mutation.Where(ps...) + return bfd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bfd *BookFileDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, bfd.sqlExec, bfd.mutation, bfd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfd *BookFileDelete) ExecX(ctx context.Context) int { + n, err := bfd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bfd *BookFileDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(bookfile.Table, sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString)) + if ps := bfd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bfd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bfd.mutation.done = true + return affected, err +} + +// BookFileDeleteOne is the builder for deleting a single BookFile entity. +type BookFileDeleteOne struct { + bfd *BookFileDelete +} + +// Where appends a list predicates to the BookFileDelete builder. +func (bfdo *BookFileDeleteOne) Where(ps ...predicate.BookFile) *BookFileDeleteOne { + bfdo.bfd.mutation.Where(ps...) + return bfdo +} + +// Exec executes the deletion query. +func (bfdo *BookFileDeleteOne) Exec(ctx context.Context) error { + n, err := bfdo.bfd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{bookfile.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfdo *BookFileDeleteOne) ExecX(ctx context.Context) { + if err := bfdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/ent/bookfile_query.go b/internal/ent/bookfile_query.go new file mode 100644 index 00000000..14c4a4a5 --- /dev/null +++ b/internal/ent/bookfile_query.go @@ -0,0 +1,634 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/predicate" + "lybbrio/internal/ent/schema/ksuid" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BookFileQuery is the builder for querying BookFile entities. +type BookFileQuery struct { + config + ctx *QueryContext + order []bookfile.OrderOption + inters []Interceptor + predicates []predicate.BookFile + withBook *BookQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*BookFile) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BookFileQuery builder. +func (bfq *BookFileQuery) Where(ps ...predicate.BookFile) *BookFileQuery { + bfq.predicates = append(bfq.predicates, ps...) + return bfq +} + +// Limit the number of records to be returned by this query. +func (bfq *BookFileQuery) Limit(limit int) *BookFileQuery { + bfq.ctx.Limit = &limit + return bfq +} + +// Offset to start from. +func (bfq *BookFileQuery) Offset(offset int) *BookFileQuery { + bfq.ctx.Offset = &offset + return bfq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (bfq *BookFileQuery) Unique(unique bool) *BookFileQuery { + bfq.ctx.Unique = &unique + return bfq +} + +// Order specifies how the records should be ordered. +func (bfq *BookFileQuery) Order(o ...bookfile.OrderOption) *BookFileQuery { + bfq.order = append(bfq.order, o...) + return bfq +} + +// QueryBook chains the current query on the "book" edge. +func (bfq *BookFileQuery) QueryBook() *BookQuery { + query := (&BookClient{config: bfq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bfq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bfq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(bookfile.Table, bookfile.FieldID, selector), + sqlgraph.To(book.Table, book.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, bookfile.BookTable, bookfile.BookColumn), + ) + fromU = sqlgraph.SetNeighbors(bfq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first BookFile entity from the query. +// Returns a *NotFoundError when no BookFile was found. +func (bfq *BookFileQuery) First(ctx context.Context) (*BookFile, error) { + nodes, err := bfq.Limit(1).All(setContextOp(ctx, bfq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{bookfile.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bfq *BookFileQuery) FirstX(ctx context.Context) *BookFile { + node, err := bfq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first BookFile ID from the query. +// Returns a *NotFoundError when no BookFile ID was found. +func (bfq *BookFileQuery) FirstID(ctx context.Context) (id ksuid.ID, err error) { + var ids []ksuid.ID + if ids, err = bfq.Limit(1).IDs(setContextOp(ctx, bfq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{bookfile.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bfq *BookFileQuery) FirstIDX(ctx context.Context) ksuid.ID { + id, err := bfq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single BookFile entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one BookFile entity is found. +// Returns a *NotFoundError when no BookFile entities are found. +func (bfq *BookFileQuery) Only(ctx context.Context) (*BookFile, error) { + nodes, err := bfq.Limit(2).All(setContextOp(ctx, bfq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{bookfile.Label} + default: + return nil, &NotSingularError{bookfile.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bfq *BookFileQuery) OnlyX(ctx context.Context) *BookFile { + node, err := bfq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only BookFile ID in the query. +// Returns a *NotSingularError when more than one BookFile ID is found. +// Returns a *NotFoundError when no entities are found. +func (bfq *BookFileQuery) OnlyID(ctx context.Context) (id ksuid.ID, err error) { + var ids []ksuid.ID + if ids, err = bfq.Limit(2).IDs(setContextOp(ctx, bfq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{bookfile.Label} + default: + err = &NotSingularError{bookfile.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bfq *BookFileQuery) OnlyIDX(ctx context.Context) ksuid.ID { + id, err := bfq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of BookFiles. +func (bfq *BookFileQuery) All(ctx context.Context) ([]*BookFile, error) { + ctx = setContextOp(ctx, bfq.ctx, "All") + if err := bfq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*BookFile, *BookFileQuery]() + return withInterceptors[[]*BookFile](ctx, bfq, qr, bfq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bfq *BookFileQuery) AllX(ctx context.Context) []*BookFile { + nodes, err := bfq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of BookFile IDs. +func (bfq *BookFileQuery) IDs(ctx context.Context) (ids []ksuid.ID, err error) { + if bfq.ctx.Unique == nil && bfq.path != nil { + bfq.Unique(true) + } + ctx = setContextOp(ctx, bfq.ctx, "IDs") + if err = bfq.Select(bookfile.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bfq *BookFileQuery) IDsX(ctx context.Context) []ksuid.ID { + ids, err := bfq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bfq *BookFileQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bfq.ctx, "Count") + if err := bfq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bfq, querierCount[*BookFileQuery](), bfq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bfq *BookFileQuery) CountX(ctx context.Context) int { + count, err := bfq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bfq *BookFileQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bfq.ctx, "Exist") + switch _, err := bfq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (bfq *BookFileQuery) ExistX(ctx context.Context) bool { + exist, err := bfq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BookFileQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bfq *BookFileQuery) Clone() *BookFileQuery { + if bfq == nil { + return nil + } + return &BookFileQuery{ + config: bfq.config, + ctx: bfq.ctx.Clone(), + order: append([]bookfile.OrderOption{}, bfq.order...), + inters: append([]Interceptor{}, bfq.inters...), + predicates: append([]predicate.BookFile{}, bfq.predicates...), + withBook: bfq.withBook.Clone(), + // clone intermediate query. + sql: bfq.sql.Clone(), + path: bfq.path, + } +} + +// WithBook tells the query-builder to eager-load the nodes that are connected to +// the "book" edge. The optional arguments are used to configure the query builder of the edge. +func (bfq *BookFileQuery) WithBook(opts ...func(*BookQuery)) *BookFileQuery { + query := (&BookClient{config: bfq.config}).Query() + for _, opt := range opts { + opt(query) + } + bfq.withBook = query + return bfq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.BookFile.Query(). +// GroupBy(bookfile.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bfq *BookFileQuery) GroupBy(field string, fields ...string) *BookFileGroupBy { + bfq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BookFileGroupBy{build: bfq} + grbuild.flds = &bfq.ctx.Fields + grbuild.label = bookfile.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.BookFile.Query(). +// Select(bookfile.FieldCreateTime). +// Scan(ctx, &v) +func (bfq *BookFileQuery) Select(fields ...string) *BookFileSelect { + bfq.ctx.Fields = append(bfq.ctx.Fields, fields...) + sbuild := &BookFileSelect{BookFileQuery: bfq} + sbuild.label = bookfile.Label + sbuild.flds, sbuild.scan = &bfq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BookFileSelect configured with the given aggregations. +func (bfq *BookFileQuery) Aggregate(fns ...AggregateFunc) *BookFileSelect { + return bfq.Select().Aggregate(fns...) +} + +func (bfq *BookFileQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bfq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, bfq); err != nil { + return err + } + } + } + for _, f := range bfq.ctx.Fields { + if !bookfile.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bfq.path != nil { + prev, err := bfq.path(ctx) + if err != nil { + return err + } + bfq.sql = prev + } + if bookfile.Policy == nil { + return errors.New("ent: uninitialized bookfile.Policy (forgotten import ent/runtime?)") + } + if err := bookfile.Policy.EvalQuery(ctx, bfq); err != nil { + return err + } + return nil +} + +func (bfq *BookFileQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*BookFile, error) { + var ( + nodes = []*BookFile{} + withFKs = bfq.withFKs + _spec = bfq.querySpec() + loadedTypes = [1]bool{ + bfq.withBook != nil, + } + ) + if bfq.withBook != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, bookfile.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*BookFile).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &BookFile{config: bfq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(bfq.modifiers) > 0 { + _spec.Modifiers = bfq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bfq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := bfq.withBook; query != nil { + if err := bfq.loadBook(ctx, query, nodes, nil, + func(n *BookFile, e *Book) { n.Edges.Book = e }); err != nil { + return nil, err + } + } + for i := range bfq.loadTotal { + if err := bfq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (bfq *BookFileQuery) loadBook(ctx context.Context, query *BookQuery, nodes []*BookFile, init func(*BookFile), assign func(*BookFile, *Book)) error { + ids := make([]ksuid.ID, 0, len(nodes)) + nodeids := make(map[ksuid.ID][]*BookFile) + for i := range nodes { + if nodes[i].book_file_book == nil { + continue + } + fk := *nodes[i].book_file_book + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(book.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "book_file_book" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (bfq *BookFileQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bfq.querySpec() + if len(bfq.modifiers) > 0 { + _spec.Modifiers = bfq.modifiers + } + _spec.Node.Columns = bfq.ctx.Fields + if len(bfq.ctx.Fields) > 0 { + _spec.Unique = bfq.ctx.Unique != nil && *bfq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bfq.driver, _spec) +} + +func (bfq *BookFileQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(bookfile.Table, bookfile.Columns, sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString)) + _spec.From = bfq.sql + if unique := bfq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bfq.path != nil { + _spec.Unique = true + } + if fields := bfq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, bookfile.FieldID) + for i := range fields { + if fields[i] != bookfile.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bfq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bfq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bfq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bfq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bfq *BookFileQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(bfq.driver.Dialect()) + t1 := builder.Table(bookfile.Table) + columns := bfq.ctx.Fields + if len(columns) == 0 { + columns = bookfile.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if bfq.sql != nil { + selector = bfq.sql + selector.Select(selector.Columns(columns...)...) + } + if bfq.ctx.Unique != nil && *bfq.ctx.Unique { + selector.Distinct() + } + for _, p := range bfq.predicates { + p(selector) + } + for _, p := range bfq.order { + p(selector) + } + if offset := bfq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := bfq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// BookFileGroupBy is the group-by builder for BookFile entities. +type BookFileGroupBy struct { + selector + build *BookFileQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bfgb *BookFileGroupBy) Aggregate(fns ...AggregateFunc) *BookFileGroupBy { + bfgb.fns = append(bfgb.fns, fns...) + return bfgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bfgb *BookFileGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bfgb.build.ctx, "GroupBy") + if err := bfgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BookFileQuery, *BookFileGroupBy](ctx, bfgb.build, bfgb, bfgb.build.inters, v) +} + +func (bfgb *BookFileGroupBy) sqlScan(ctx context.Context, root *BookFileQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bfgb.fns)) + for _, fn := range bfgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bfgb.flds)+len(bfgb.fns)) + for _, f := range *bfgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bfgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bfgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BookFileSelect is the builder for selecting fields of BookFile entities. +type BookFileSelect struct { + *BookFileQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bfs *BookFileSelect) Aggregate(fns ...AggregateFunc) *BookFileSelect { + bfs.fns = append(bfs.fns, fns...) + return bfs +} + +// Scan applies the selector query and scans the result into the given value. +func (bfs *BookFileSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bfs.ctx, "Select") + if err := bfs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BookFileQuery, *BookFileSelect](ctx, bfs.BookFileQuery, bfs, bfs.inters, v) +} + +func (bfs *BookFileSelect) sqlScan(ctx context.Context, root *BookFileQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bfs.fns)) + for _, fn := range bfs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bfs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bfs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/internal/ent/bookfile_update.go b/internal/ent/bookfile_update.go new file mode 100644 index 00000000..7d5b91a8 --- /dev/null +++ b/internal/ent/bookfile_update.go @@ -0,0 +1,536 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" + "lybbrio/internal/ent/predicate" + "lybbrio/internal/ent/schema/ksuid" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BookFileUpdate is the builder for updating BookFile entities. +type BookFileUpdate struct { + config + hooks []Hook + mutation *BookFileMutation +} + +// Where appends a list predicates to the BookFileUpdate builder. +func (bfu *BookFileUpdate) Where(ps ...predicate.BookFile) *BookFileUpdate { + bfu.mutation.Where(ps...) + return bfu +} + +// SetUpdateTime sets the "update_time" field. +func (bfu *BookFileUpdate) SetUpdateTime(t time.Time) *BookFileUpdate { + bfu.mutation.SetUpdateTime(t) + return bfu +} + +// SetName sets the "name" field. +func (bfu *BookFileUpdate) SetName(s string) *BookFileUpdate { + bfu.mutation.SetName(s) + return bfu +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (bfu *BookFileUpdate) SetNillableName(s *string) *BookFileUpdate { + if s != nil { + bfu.SetName(*s) + } + return bfu +} + +// SetPath sets the "path" field. +func (bfu *BookFileUpdate) SetPath(s string) *BookFileUpdate { + bfu.mutation.SetPath(s) + return bfu +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (bfu *BookFileUpdate) SetNillablePath(s *string) *BookFileUpdate { + if s != nil { + bfu.SetPath(*s) + } + return bfu +} + +// SetSize sets the "size" field. +func (bfu *BookFileUpdate) SetSize(i int64) *BookFileUpdate { + bfu.mutation.ResetSize() + bfu.mutation.SetSize(i) + return bfu +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (bfu *BookFileUpdate) SetNillableSize(i *int64) *BookFileUpdate { + if i != nil { + bfu.SetSize(*i) + } + return bfu +} + +// AddSize adds i to the "size" field. +func (bfu *BookFileUpdate) AddSize(i int64) *BookFileUpdate { + bfu.mutation.AddSize(i) + return bfu +} + +// SetFormat sets the "format" field. +func (bfu *BookFileUpdate) SetFormat(b bookfile.Format) *BookFileUpdate { + bfu.mutation.SetFormat(b) + return bfu +} + +// SetNillableFormat sets the "format" field if the given value is not nil. +func (bfu *BookFileUpdate) SetNillableFormat(b *bookfile.Format) *BookFileUpdate { + if b != nil { + bfu.SetFormat(*b) + } + return bfu +} + +// SetBookID sets the "book" edge to the Book entity by ID. +func (bfu *BookFileUpdate) SetBookID(id ksuid.ID) *BookFileUpdate { + bfu.mutation.SetBookID(id) + return bfu +} + +// SetBook sets the "book" edge to the Book entity. +func (bfu *BookFileUpdate) SetBook(b *Book) *BookFileUpdate { + return bfu.SetBookID(b.ID) +} + +// Mutation returns the BookFileMutation object of the builder. +func (bfu *BookFileUpdate) Mutation() *BookFileMutation { + return bfu.mutation +} + +// ClearBook clears the "book" edge to the Book entity. +func (bfu *BookFileUpdate) ClearBook() *BookFileUpdate { + bfu.mutation.ClearBook() + return bfu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bfu *BookFileUpdate) Save(ctx context.Context) (int, error) { + if err := bfu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, bfu.sqlSave, bfu.mutation, bfu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bfu *BookFileUpdate) SaveX(ctx context.Context) int { + affected, err := bfu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bfu *BookFileUpdate) Exec(ctx context.Context) error { + _, err := bfu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfu *BookFileUpdate) ExecX(ctx context.Context) { + if err := bfu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bfu *BookFileUpdate) defaults() error { + if _, ok := bfu.mutation.UpdateTime(); !ok { + if bookfile.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized bookfile.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := bookfile.UpdateDefaultUpdateTime() + bfu.mutation.SetUpdateTime(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (bfu *BookFileUpdate) check() error { + if v, ok := bfu.mutation.Name(); ok { + if err := bookfile.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "BookFile.name": %w`, err)} + } + } + if v, ok := bfu.mutation.Path(); ok { + if err := bookfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "BookFile.path": %w`, err)} + } + } + if v, ok := bfu.mutation.Size(); ok { + if err := bookfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "BookFile.size": %w`, err)} + } + } + if v, ok := bfu.mutation.Format(); ok { + if err := bookfile.FormatValidator(v); err != nil { + return &ValidationError{Name: "format", err: fmt.Errorf(`ent: validator failed for field "BookFile.format": %w`, err)} + } + } + if _, ok := bfu.mutation.BookID(); bfu.mutation.BookCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "BookFile.book"`) + } + return nil +} + +func (bfu *BookFileUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := bfu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(bookfile.Table, bookfile.Columns, sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString)) + if ps := bfu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bfu.mutation.UpdateTime(); ok { + _spec.SetField(bookfile.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := bfu.mutation.Name(); ok { + _spec.SetField(bookfile.FieldName, field.TypeString, value) + } + if value, ok := bfu.mutation.Path(); ok { + _spec.SetField(bookfile.FieldPath, field.TypeString, value) + } + if value, ok := bfu.mutation.Size(); ok { + _spec.SetField(bookfile.FieldSize, field.TypeInt64, value) + } + if value, ok := bfu.mutation.AddedSize(); ok { + _spec.AddField(bookfile.FieldSize, field.TypeInt64, value) + } + if value, ok := bfu.mutation.Format(); ok { + _spec.SetField(bookfile.FieldFormat, field.TypeEnum, value) + } + if bfu.mutation.BookCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(book.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bfu.mutation.BookIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(book.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, bfu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{bookfile.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bfu.mutation.done = true + return n, nil +} + +// BookFileUpdateOne is the builder for updating a single BookFile entity. +type BookFileUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BookFileMutation +} + +// SetUpdateTime sets the "update_time" field. +func (bfuo *BookFileUpdateOne) SetUpdateTime(t time.Time) *BookFileUpdateOne { + bfuo.mutation.SetUpdateTime(t) + return bfuo +} + +// SetName sets the "name" field. +func (bfuo *BookFileUpdateOne) SetName(s string) *BookFileUpdateOne { + bfuo.mutation.SetName(s) + return bfuo +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (bfuo *BookFileUpdateOne) SetNillableName(s *string) *BookFileUpdateOne { + if s != nil { + bfuo.SetName(*s) + } + return bfuo +} + +// SetPath sets the "path" field. +func (bfuo *BookFileUpdateOne) SetPath(s string) *BookFileUpdateOne { + bfuo.mutation.SetPath(s) + return bfuo +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (bfuo *BookFileUpdateOne) SetNillablePath(s *string) *BookFileUpdateOne { + if s != nil { + bfuo.SetPath(*s) + } + return bfuo +} + +// SetSize sets the "size" field. +func (bfuo *BookFileUpdateOne) SetSize(i int64) *BookFileUpdateOne { + bfuo.mutation.ResetSize() + bfuo.mutation.SetSize(i) + return bfuo +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (bfuo *BookFileUpdateOne) SetNillableSize(i *int64) *BookFileUpdateOne { + if i != nil { + bfuo.SetSize(*i) + } + return bfuo +} + +// AddSize adds i to the "size" field. +func (bfuo *BookFileUpdateOne) AddSize(i int64) *BookFileUpdateOne { + bfuo.mutation.AddSize(i) + return bfuo +} + +// SetFormat sets the "format" field. +func (bfuo *BookFileUpdateOne) SetFormat(b bookfile.Format) *BookFileUpdateOne { + bfuo.mutation.SetFormat(b) + return bfuo +} + +// SetNillableFormat sets the "format" field if the given value is not nil. +func (bfuo *BookFileUpdateOne) SetNillableFormat(b *bookfile.Format) *BookFileUpdateOne { + if b != nil { + bfuo.SetFormat(*b) + } + return bfuo +} + +// SetBookID sets the "book" edge to the Book entity by ID. +func (bfuo *BookFileUpdateOne) SetBookID(id ksuid.ID) *BookFileUpdateOne { + bfuo.mutation.SetBookID(id) + return bfuo +} + +// SetBook sets the "book" edge to the Book entity. +func (bfuo *BookFileUpdateOne) SetBook(b *Book) *BookFileUpdateOne { + return bfuo.SetBookID(b.ID) +} + +// Mutation returns the BookFileMutation object of the builder. +func (bfuo *BookFileUpdateOne) Mutation() *BookFileMutation { + return bfuo.mutation +} + +// ClearBook clears the "book" edge to the Book entity. +func (bfuo *BookFileUpdateOne) ClearBook() *BookFileUpdateOne { + bfuo.mutation.ClearBook() + return bfuo +} + +// Where appends a list predicates to the BookFileUpdate builder. +func (bfuo *BookFileUpdateOne) Where(ps ...predicate.BookFile) *BookFileUpdateOne { + bfuo.mutation.Where(ps...) + return bfuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (bfuo *BookFileUpdateOne) Select(field string, fields ...string) *BookFileUpdateOne { + bfuo.fields = append([]string{field}, fields...) + return bfuo +} + +// Save executes the query and returns the updated BookFile entity. +func (bfuo *BookFileUpdateOne) Save(ctx context.Context) (*BookFile, error) { + if err := bfuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, bfuo.sqlSave, bfuo.mutation, bfuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bfuo *BookFileUpdateOne) SaveX(ctx context.Context) *BookFile { + node, err := bfuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (bfuo *BookFileUpdateOne) Exec(ctx context.Context) error { + _, err := bfuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bfuo *BookFileUpdateOne) ExecX(ctx context.Context) { + if err := bfuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bfuo *BookFileUpdateOne) defaults() error { + if _, ok := bfuo.mutation.UpdateTime(); !ok { + if bookfile.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized bookfile.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := bookfile.UpdateDefaultUpdateTime() + bfuo.mutation.SetUpdateTime(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (bfuo *BookFileUpdateOne) check() error { + if v, ok := bfuo.mutation.Name(); ok { + if err := bookfile.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "BookFile.name": %w`, err)} + } + } + if v, ok := bfuo.mutation.Path(); ok { + if err := bookfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "BookFile.path": %w`, err)} + } + } + if v, ok := bfuo.mutation.Size(); ok { + if err := bookfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "BookFile.size": %w`, err)} + } + } + if v, ok := bfuo.mutation.Format(); ok { + if err := bookfile.FormatValidator(v); err != nil { + return &ValidationError{Name: "format", err: fmt.Errorf(`ent: validator failed for field "BookFile.format": %w`, err)} + } + } + if _, ok := bfuo.mutation.BookID(); bfuo.mutation.BookCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "BookFile.book"`) + } + return nil +} + +func (bfuo *BookFileUpdateOne) sqlSave(ctx context.Context) (_node *BookFile, err error) { + if err := bfuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(bookfile.Table, bookfile.Columns, sqlgraph.NewFieldSpec(bookfile.FieldID, field.TypeString)) + id, ok := bfuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "BookFile.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := bfuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, bookfile.FieldID) + for _, f := range fields { + if !bookfile.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != bookfile.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := bfuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bfuo.mutation.UpdateTime(); ok { + _spec.SetField(bookfile.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := bfuo.mutation.Name(); ok { + _spec.SetField(bookfile.FieldName, field.TypeString, value) + } + if value, ok := bfuo.mutation.Path(); ok { + _spec.SetField(bookfile.FieldPath, field.TypeString, value) + } + if value, ok := bfuo.mutation.Size(); ok { + _spec.SetField(bookfile.FieldSize, field.TypeInt64, value) + } + if value, ok := bfuo.mutation.AddedSize(); ok { + _spec.AddField(bookfile.FieldSize, field.TypeInt64, value) + } + if value, ok := bfuo.mutation.Format(); ok { + _spec.SetField(bookfile.FieldFormat, field.TypeEnum, value) + } + if bfuo.mutation.BookCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(book.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bfuo.mutation.BookIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(book.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &BookFile{config: bfuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, bfuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{bookfile.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + bfuo.mutation.done = true + return _node, nil +} diff --git a/internal/ent/client.go b/internal/ent/client.go index 7bd8c258..d3c6ccaa 100644 --- a/internal/ent/client.go +++ b/internal/ent/client.go @@ -14,6 +14,7 @@ import ( "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -39,6 +40,8 @@ type Client struct { Author *AuthorClient // Book is the client for interacting with the Book builders. Book *BookClient + // BookFile is the client for interacting with the BookFile builders. + BookFile *BookFileClient // Identifier is the client for interacting with the Identifier builders. Identifier *IdentifierClient // Language is the client for interacting with the Language builders. @@ -70,6 +73,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.Author = NewAuthorClient(c.config) c.Book = NewBookClient(c.config) + c.BookFile = NewBookFileClient(c.config) c.Identifier = NewIdentifierClient(c.config) c.Language = NewLanguageClient(c.config) c.Publisher = NewPublisherClient(c.config) @@ -173,6 +177,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, Author: NewAuthorClient(cfg), Book: NewBookClient(cfg), + BookFile: NewBookFileClient(cfg), Identifier: NewIdentifierClient(cfg), Language: NewLanguageClient(cfg), Publisher: NewPublisherClient(cfg), @@ -203,6 +208,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, Author: NewAuthorClient(cfg), Book: NewBookClient(cfg), + BookFile: NewBookFileClient(cfg), Identifier: NewIdentifierClient(cfg), Language: NewLanguageClient(cfg), Publisher: NewPublisherClient(cfg), @@ -241,8 +247,8 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Author, c.Book, c.Identifier, c.Language, c.Publisher, c.Series, c.Shelf, - c.Tag, c.Task, c.User, c.UserPermissions, + c.Author, c.Book, c.BookFile, c.Identifier, c.Language, c.Publisher, c.Series, + c.Shelf, c.Tag, c.Task, c.User, c.UserPermissions, } { n.Use(hooks...) } @@ -252,8 +258,8 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Author, c.Book, c.Identifier, c.Language, c.Publisher, c.Series, c.Shelf, - c.Tag, c.Task, c.User, c.UserPermissions, + c.Author, c.Book, c.BookFile, c.Identifier, c.Language, c.Publisher, c.Series, + c.Shelf, c.Tag, c.Task, c.User, c.UserPermissions, } { n.Intercept(interceptors...) } @@ -266,6 +272,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Author.mutate(ctx, m) case *BookMutation: return c.Book.mutate(ctx, m) + case *BookFileMutation: + return c.BookFile.mutate(ctx, m) case *IdentifierMutation: return c.Identifier.mutate(ctx, m) case *LanguageMutation: @@ -659,6 +667,22 @@ func (c *BookClient) QueryShelf(b *Book) *ShelfQuery { return query } +// QueryFiles queries the files edge of a Book. +func (c *BookClient) QueryFiles(b *Book) *BookFileQuery { + query := (&BookFileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(book.Table, book.FieldID, id), + sqlgraph.To(bookfile.Table, bookfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, book.FilesTable, book.FilesColumn), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *BookClient) Hooks() []Hook { hooks := c.hooks.Book @@ -685,6 +709,156 @@ func (c *BookClient) mutate(ctx context.Context, m *BookMutation) (Value, error) } } +// BookFileClient is a client for the BookFile schema. +type BookFileClient struct { + config +} + +// NewBookFileClient returns a client for the BookFile from the given config. +func NewBookFileClient(c config) *BookFileClient { + return &BookFileClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `bookfile.Hooks(f(g(h())))`. +func (c *BookFileClient) Use(hooks ...Hook) { + c.hooks.BookFile = append(c.hooks.BookFile, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `bookfile.Intercept(f(g(h())))`. +func (c *BookFileClient) Intercept(interceptors ...Interceptor) { + c.inters.BookFile = append(c.inters.BookFile, interceptors...) +} + +// Create returns a builder for creating a BookFile entity. +func (c *BookFileClient) Create() *BookFileCreate { + mutation := newBookFileMutation(c.config, OpCreate) + return &BookFileCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of BookFile entities. +func (c *BookFileClient) CreateBulk(builders ...*BookFileCreate) *BookFileCreateBulk { + return &BookFileCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BookFileClient) MapCreateBulk(slice any, setFunc func(*BookFileCreate, int)) *BookFileCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BookFileCreateBulk{err: fmt.Errorf("calling to BookFileClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BookFileCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BookFileCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for BookFile. +func (c *BookFileClient) Update() *BookFileUpdate { + mutation := newBookFileMutation(c.config, OpUpdate) + return &BookFileUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BookFileClient) UpdateOne(bf *BookFile) *BookFileUpdateOne { + mutation := newBookFileMutation(c.config, OpUpdateOne, withBookFile(bf)) + return &BookFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BookFileClient) UpdateOneID(id ksuid.ID) *BookFileUpdateOne { + mutation := newBookFileMutation(c.config, OpUpdateOne, withBookFileID(id)) + return &BookFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for BookFile. +func (c *BookFileClient) Delete() *BookFileDelete { + mutation := newBookFileMutation(c.config, OpDelete) + return &BookFileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BookFileClient) DeleteOne(bf *BookFile) *BookFileDeleteOne { + return c.DeleteOneID(bf.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BookFileClient) DeleteOneID(id ksuid.ID) *BookFileDeleteOne { + builder := c.Delete().Where(bookfile.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BookFileDeleteOne{builder} +} + +// Query returns a query builder for BookFile. +func (c *BookFileClient) Query() *BookFileQuery { + return &BookFileQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBookFile}, + inters: c.Interceptors(), + } +} + +// Get returns a BookFile entity by its id. +func (c *BookFileClient) Get(ctx context.Context, id ksuid.ID) (*BookFile, error) { + return c.Query().Where(bookfile.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BookFileClient) GetX(ctx context.Context, id ksuid.ID) *BookFile { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryBook queries the book edge of a BookFile. +func (c *BookFileClient) QueryBook(bf *BookFile) *BookQuery { + query := (&BookClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := bf.ID + step := sqlgraph.NewStep( + sqlgraph.From(bookfile.Table, bookfile.FieldID, id), + sqlgraph.To(book.Table, book.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, bookfile.BookTable, bookfile.BookColumn), + ) + fromV = sqlgraph.Neighbors(bf.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *BookFileClient) Hooks() []Hook { + hooks := c.hooks.BookFile + return append(hooks[:len(hooks):len(hooks)], bookfile.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *BookFileClient) Interceptors() []Interceptor { + return c.inters.BookFile +} + +func (c *BookFileClient) mutate(ctx context.Context, m *BookFileMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BookFileCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BookFileUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BookFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BookFileDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown BookFile mutation op: %q", m.Op()) + } +} + // IdentifierClient is a client for the Identifier schema. type IdentifierClient struct { config @@ -2070,11 +2244,11 @@ func (c *UserPermissionsClient) mutate(ctx context.Context, m *UserPermissionsMu // hooks and interceptors per client, for fast access. type ( hooks struct { - Author, Book, Identifier, Language, Publisher, Series, Shelf, Tag, Task, User, - UserPermissions []ent.Hook + Author, Book, BookFile, Identifier, Language, Publisher, Series, Shelf, Tag, + Task, User, UserPermissions []ent.Hook } inters struct { - Author, Book, Identifier, Language, Publisher, Series, Shelf, Tag, Task, User, - UserPermissions []ent.Interceptor + Author, Book, BookFile, Identifier, Language, Publisher, Series, Shelf, Tag, + Task, User, UserPermissions []ent.Interceptor } ) diff --git a/internal/ent/ent.go b/internal/ent/ent.go index 34eeeca2..7ccbf31e 100644 --- a/internal/ent/ent.go +++ b/internal/ent/ent.go @@ -8,6 +8,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -85,6 +86,7 @@ func checkColumn(table, column string) error { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ author.Table: author.ValidColumn, book.Table: book.ValidColumn, + bookfile.Table: bookfile.ValidColumn, identifier.Table: identifier.ValidColumn, language.Table: language.ValidColumn, publisher.Table: publisher.ValidColumn, diff --git a/internal/ent/entql.go b/internal/ent/entql.go index 748ad634..70885cc1 100644 --- a/internal/ent/entql.go +++ b/internal/ent/entql.go @@ -5,6 +5,7 @@ package ent import ( "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" @@ -24,7 +25,7 @@ import ( // schemaGraph holds a representation of ent/schema at runtime. var schemaGraph = func() *sqlgraph.Schema { - graph := &sqlgraph.Schema{Nodes: make([]*sqlgraph.Node, 11)} + graph := &sqlgraph.Schema{Nodes: make([]*sqlgraph.Node, 12)} graph.Nodes[0] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: author.Table, @@ -36,10 +37,12 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Author", Fields: map[string]*sqlgraph.FieldSpec{ - author.FieldCalibreID: {Type: field.TypeInt64, Column: author.FieldCalibreID}, - author.FieldName: {Type: field.TypeString, Column: author.FieldName}, - author.FieldSort: {Type: field.TypeString, Column: author.FieldSort}, - author.FieldLink: {Type: field.TypeString, Column: author.FieldLink}, + author.FieldCreateTime: {Type: field.TypeTime, Column: author.FieldCreateTime}, + author.FieldUpdateTime: {Type: field.TypeTime, Column: author.FieldUpdateTime}, + author.FieldCalibreID: {Type: field.TypeInt64, Column: author.FieldCalibreID}, + author.FieldName: {Type: field.TypeString, Column: author.FieldName}, + author.FieldSort: {Type: field.TypeString, Column: author.FieldSort}, + author.FieldLink: {Type: field.TypeString, Column: author.FieldLink}, }, } graph.Nodes[1] = &sqlgraph.Node{ @@ -53,6 +56,8 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Book", Fields: map[string]*sqlgraph.FieldSpec{ + book.FieldCreateTime: {Type: field.TypeTime, Column: book.FieldCreateTime}, + book.FieldUpdateTime: {Type: field.TypeTime, Column: book.FieldUpdateTime}, book.FieldCalibreID: {Type: field.TypeInt64, Column: book.FieldCalibreID}, book.FieldTitle: {Type: field.TypeString, Column: book.FieldTitle}, book.FieldSort: {Type: field.TypeString, Column: book.FieldSort}, @@ -64,6 +69,25 @@ var schemaGraph = func() *sqlgraph.Schema { }, } graph.Nodes[2] = &sqlgraph.Node{ + NodeSpec: sqlgraph.NodeSpec{ + Table: bookfile.Table, + Columns: bookfile.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeString, + Column: bookfile.FieldID, + }, + }, + Type: "BookFile", + Fields: map[string]*sqlgraph.FieldSpec{ + bookfile.FieldCreateTime: {Type: field.TypeTime, Column: bookfile.FieldCreateTime}, + bookfile.FieldUpdateTime: {Type: field.TypeTime, Column: bookfile.FieldUpdateTime}, + bookfile.FieldName: {Type: field.TypeString, Column: bookfile.FieldName}, + bookfile.FieldPath: {Type: field.TypeString, Column: bookfile.FieldPath}, + bookfile.FieldSize: {Type: field.TypeInt64, Column: bookfile.FieldSize}, + bookfile.FieldFormat: {Type: field.TypeEnum, Column: bookfile.FieldFormat}, + }, + } + graph.Nodes[3] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: identifier.Table, Columns: identifier.Columns, @@ -74,12 +98,14 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Identifier", Fields: map[string]*sqlgraph.FieldSpec{ - identifier.FieldCalibreID: {Type: field.TypeInt64, Column: identifier.FieldCalibreID}, - identifier.FieldType: {Type: field.TypeString, Column: identifier.FieldType}, - identifier.FieldValue: {Type: field.TypeString, Column: identifier.FieldValue}, + identifier.FieldCreateTime: {Type: field.TypeTime, Column: identifier.FieldCreateTime}, + identifier.FieldUpdateTime: {Type: field.TypeTime, Column: identifier.FieldUpdateTime}, + identifier.FieldCalibreID: {Type: field.TypeInt64, Column: identifier.FieldCalibreID}, + identifier.FieldType: {Type: field.TypeString, Column: identifier.FieldType}, + identifier.FieldValue: {Type: field.TypeString, Column: identifier.FieldValue}, }, } - graph.Nodes[3] = &sqlgraph.Node{ + graph.Nodes[4] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: language.Table, Columns: language.Columns, @@ -90,11 +116,13 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Language", Fields: map[string]*sqlgraph.FieldSpec{ - language.FieldCalibreID: {Type: field.TypeInt64, Column: language.FieldCalibreID}, - language.FieldCode: {Type: field.TypeString, Column: language.FieldCode}, + language.FieldCreateTime: {Type: field.TypeTime, Column: language.FieldCreateTime}, + language.FieldUpdateTime: {Type: field.TypeTime, Column: language.FieldUpdateTime}, + language.FieldCalibreID: {Type: field.TypeInt64, Column: language.FieldCalibreID}, + language.FieldCode: {Type: field.TypeString, Column: language.FieldCode}, }, } - graph.Nodes[4] = &sqlgraph.Node{ + graph.Nodes[5] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: publisher.Table, Columns: publisher.Columns, @@ -105,11 +133,13 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Publisher", Fields: map[string]*sqlgraph.FieldSpec{ - publisher.FieldCalibreID: {Type: field.TypeInt64, Column: publisher.FieldCalibreID}, - publisher.FieldName: {Type: field.TypeString, Column: publisher.FieldName}, + publisher.FieldCreateTime: {Type: field.TypeTime, Column: publisher.FieldCreateTime}, + publisher.FieldUpdateTime: {Type: field.TypeTime, Column: publisher.FieldUpdateTime}, + publisher.FieldCalibreID: {Type: field.TypeInt64, Column: publisher.FieldCalibreID}, + publisher.FieldName: {Type: field.TypeString, Column: publisher.FieldName}, }, } - graph.Nodes[5] = &sqlgraph.Node{ + graph.Nodes[6] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: series.Table, Columns: series.Columns, @@ -120,12 +150,14 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Series", Fields: map[string]*sqlgraph.FieldSpec{ - series.FieldCalibreID: {Type: field.TypeInt64, Column: series.FieldCalibreID}, - series.FieldName: {Type: field.TypeString, Column: series.FieldName}, - series.FieldSort: {Type: field.TypeString, Column: series.FieldSort}, + series.FieldCreateTime: {Type: field.TypeTime, Column: series.FieldCreateTime}, + series.FieldUpdateTime: {Type: field.TypeTime, Column: series.FieldUpdateTime}, + series.FieldCalibreID: {Type: field.TypeInt64, Column: series.FieldCalibreID}, + series.FieldName: {Type: field.TypeString, Column: series.FieldName}, + series.FieldSort: {Type: field.TypeString, Column: series.FieldSort}, }, } - graph.Nodes[6] = &sqlgraph.Node{ + graph.Nodes[7] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: shelf.Table, Columns: shelf.Columns, @@ -136,13 +168,15 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "Shelf", Fields: map[string]*sqlgraph.FieldSpec{ + shelf.FieldCreateTime: {Type: field.TypeTime, Column: shelf.FieldCreateTime}, + shelf.FieldUpdateTime: {Type: field.TypeTime, Column: shelf.FieldUpdateTime}, shelf.FieldPublic: {Type: field.TypeBool, Column: shelf.FieldPublic}, shelf.FieldUserID: {Type: field.TypeString, Column: shelf.FieldUserID}, shelf.FieldName: {Type: field.TypeString, Column: shelf.FieldName}, shelf.FieldDescription: {Type: field.TypeString, Column: shelf.FieldDescription}, }, } - graph.Nodes[7] = &sqlgraph.Node{ + graph.Nodes[8] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: tag.Table, Columns: tag.Columns, @@ -157,7 +191,7 @@ var schemaGraph = func() *sqlgraph.Schema { tag.FieldName: {Type: field.TypeString, Column: tag.FieldName}, }, } - graph.Nodes[8] = &sqlgraph.Node{ + graph.Nodes[9] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: task.Table, Columns: task.Columns, @@ -179,7 +213,7 @@ var schemaGraph = func() *sqlgraph.Schema { task.FieldIsSystemTask: {Type: field.TypeBool, Column: task.FieldIsSystemTask}, }, } - graph.Nodes[9] = &sqlgraph.Node{ + graph.Nodes[10] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: user.Table, Columns: user.Columns, @@ -190,12 +224,14 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "User", Fields: map[string]*sqlgraph.FieldSpec{ + user.FieldCreateTime: {Type: field.TypeTime, Column: user.FieldCreateTime}, + user.FieldUpdateTime: {Type: field.TypeTime, Column: user.FieldUpdateTime}, user.FieldUsername: {Type: field.TypeString, Column: user.FieldUsername}, user.FieldPasswordHash: {Type: field.TypeString, Column: user.FieldPasswordHash}, user.FieldEmail: {Type: field.TypeString, Column: user.FieldEmail}, }, } - graph.Nodes[10] = &sqlgraph.Node{ + graph.Nodes[11] = &sqlgraph.Node{ NodeSpec: sqlgraph.NodeSpec{ Table: userpermissions.Table, Columns: userpermissions.Columns, @@ -206,10 +242,12 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "UserPermissions", Fields: map[string]*sqlgraph.FieldSpec{ + userpermissions.FieldCreateTime: {Type: field.TypeTime, Column: userpermissions.FieldCreateTime}, + userpermissions.FieldUpdateTime: {Type: field.TypeTime, Column: userpermissions.FieldUpdateTime}, userpermissions.FieldUserID: {Type: field.TypeString, Column: userpermissions.FieldUserID}, - userpermissions.FieldCanEdit: {Type: field.TypeBool, Column: userpermissions.FieldCanEdit}, userpermissions.FieldAdmin: {Type: field.TypeBool, Column: userpermissions.FieldAdmin}, userpermissions.FieldCanCreatePublic: {Type: field.TypeBool, Column: userpermissions.FieldCanCreatePublic}, + userpermissions.FieldCanEdit: {Type: field.TypeBool, Column: userpermissions.FieldCanEdit}, }, } graph.MustAddE( @@ -308,6 +346,30 @@ var schemaGraph = func() *sqlgraph.Schema { "Book", "Shelf", ) + graph.MustAddE( + "files", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: book.FilesTable, + Columns: []string{book.FilesColumn}, + Bidi: false, + }, + "Book", + "BookFile", + ) + graph.MustAddE( + "book", + &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: bookfile.BookTable, + Columns: []string{bookfile.BookColumn}, + Bidi: false, + }, + "BookFile", + "Book", + ) graph.MustAddE( "book", &sqlgraph.EdgeSpec{ @@ -489,6 +551,16 @@ func (f *AuthorFilter) WhereID(p entql.StringP) { f.Where(p.Field(author.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *AuthorFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(author.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *AuthorFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(author.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *AuthorFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(author.FieldCalibreID)) @@ -563,6 +635,16 @@ func (f *BookFilter) WhereID(p entql.StringP) { f.Where(p.Field(book.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *BookFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(book.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *BookFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(book.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *BookFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(book.FieldCalibreID)) @@ -701,6 +783,104 @@ func (f *BookFilter) WhereHasShelfWith(preds ...predicate.Shelf) { }))) } +// WhereHasFiles applies a predicate to check if query has an edge files. +func (f *BookFilter) WhereHasFiles() { + f.Where(entql.HasEdge("files")) +} + +// WhereHasFilesWith applies a predicate to check if query has an edge files with a given conditions (other predicates). +func (f *BookFilter) WhereHasFilesWith(preds ...predicate.BookFile) { + f.Where(entql.HasEdgeWith("files", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + +// addPredicate implements the predicateAdder interface. +func (bfq *BookFileQuery) addPredicate(pred func(s *sql.Selector)) { + bfq.predicates = append(bfq.predicates, pred) +} + +// Filter returns a Filter implementation to apply filters on the BookFileQuery builder. +func (bfq *BookFileQuery) Filter() *BookFileFilter { + return &BookFileFilter{config: bfq.config, predicateAdder: bfq} +} + +// addPredicate implements the predicateAdder interface. +func (m *BookFileMutation) addPredicate(pred func(s *sql.Selector)) { + m.predicates = append(m.predicates, pred) +} + +// Filter returns an entql.Where implementation to apply filters on the BookFileMutation builder. +func (m *BookFileMutation) Filter() *BookFileFilter { + return &BookFileFilter{config: m.config, predicateAdder: m} +} + +// BookFileFilter provides a generic filtering capability at runtime for BookFileQuery. +type BookFileFilter struct { + predicateAdder + config +} + +// Where applies the entql predicate on the query filter. +func (f *BookFileFilter) Where(p entql.P) { + f.addPredicate(func(s *sql.Selector) { + if err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil { + s.AddError(err) + } + }) +} + +// WhereID applies the entql string predicate on the id field. +func (f *BookFileFilter) WhereID(p entql.StringP) { + f.Where(p.Field(bookfile.FieldID)) +} + +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *BookFileFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(bookfile.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *BookFileFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(bookfile.FieldUpdateTime)) +} + +// WhereName applies the entql string predicate on the name field. +func (f *BookFileFilter) WhereName(p entql.StringP) { + f.Where(p.Field(bookfile.FieldName)) +} + +// WherePath applies the entql string predicate on the path field. +func (f *BookFileFilter) WherePath(p entql.StringP) { + f.Where(p.Field(bookfile.FieldPath)) +} + +// WhereSize applies the entql int64 predicate on the size field. +func (f *BookFileFilter) WhereSize(p entql.Int64P) { + f.Where(p.Field(bookfile.FieldSize)) +} + +// WhereFormat applies the entql string predicate on the format field. +func (f *BookFileFilter) WhereFormat(p entql.StringP) { + f.Where(p.Field(bookfile.FieldFormat)) +} + +// WhereHasBook applies a predicate to check if query has an edge book. +func (f *BookFileFilter) WhereHasBook() { + f.Where(entql.HasEdge("book")) +} + +// WhereHasBookWith applies a predicate to check if query has an edge book with a given conditions (other predicates). +func (f *BookFileFilter) WhereHasBookWith(preds ...predicate.Book) { + f.Where(entql.HasEdgeWith("book", sqlgraph.WrapFunc(func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }))) +} + // addPredicate implements the predicateAdder interface. func (iq *IdentifierQuery) addPredicate(pred func(s *sql.Selector)) { iq.predicates = append(iq.predicates, pred) @@ -730,7 +910,7 @@ type IdentifierFilter struct { // Where applies the entql predicate on the query filter. func (f *IdentifierFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil { s.AddError(err) } }) @@ -741,6 +921,16 @@ func (f *IdentifierFilter) WhereID(p entql.StringP) { f.Where(p.Field(identifier.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *IdentifierFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(identifier.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *IdentifierFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(identifier.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *IdentifierFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(identifier.FieldCalibreID)) @@ -799,7 +989,7 @@ type LanguageFilter struct { // Where applies the entql predicate on the query filter. func (f *LanguageFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil { s.AddError(err) } }) @@ -810,6 +1000,16 @@ func (f *LanguageFilter) WhereID(p entql.StringP) { f.Where(p.Field(language.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *LanguageFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(language.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *LanguageFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(language.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *LanguageFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(language.FieldCalibreID)) @@ -863,7 +1063,7 @@ type PublisherFilter struct { // Where applies the entql predicate on the query filter. func (f *PublisherFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[5].Type, p, s); err != nil { s.AddError(err) } }) @@ -874,6 +1074,16 @@ func (f *PublisherFilter) WhereID(p entql.StringP) { f.Where(p.Field(publisher.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *PublisherFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(publisher.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *PublisherFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(publisher.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *PublisherFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(publisher.FieldCalibreID)) @@ -927,7 +1137,7 @@ type SeriesFilter struct { // Where applies the entql predicate on the query filter. func (f *SeriesFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[5].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[6].Type, p, s); err != nil { s.AddError(err) } }) @@ -938,6 +1148,16 @@ func (f *SeriesFilter) WhereID(p entql.StringP) { f.Where(p.Field(series.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *SeriesFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(series.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *SeriesFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(series.FieldUpdateTime)) +} + // WhereCalibreID applies the entql int64 predicate on the calibre_id field. func (f *SeriesFilter) WhereCalibreID(p entql.Int64P) { f.Where(p.Field(series.FieldCalibreID)) @@ -996,7 +1216,7 @@ type ShelfFilter struct { // Where applies the entql predicate on the query filter. func (f *ShelfFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[6].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[7].Type, p, s); err != nil { s.AddError(err) } }) @@ -1007,6 +1227,16 @@ func (f *ShelfFilter) WhereID(p entql.StringP) { f.Where(p.Field(shelf.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *ShelfFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(shelf.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *ShelfFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(shelf.FieldUpdateTime)) +} + // WherePublic applies the entql bool predicate on the public field. func (f *ShelfFilter) WherePublic(p entql.BoolP) { f.Where(p.Field(shelf.FieldPublic)) @@ -1084,7 +1314,7 @@ type TagFilter struct { // Where applies the entql predicate on the query filter. func (f *TagFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[7].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[8].Type, p, s); err != nil { s.AddError(err) } }) @@ -1148,7 +1378,7 @@ type TaskFilter struct { // Where applies the entql predicate on the query filter. func (f *TaskFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[8].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[9].Type, p, s); err != nil { s.AddError(err) } }) @@ -1247,7 +1477,7 @@ type UserFilter struct { // Where applies the entql predicate on the query filter. func (f *UserFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[9].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[10].Type, p, s); err != nil { s.AddError(err) } }) @@ -1258,6 +1488,16 @@ func (f *UserFilter) WhereID(p entql.StringP) { f.Where(p.Field(user.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *UserFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(user.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *UserFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(user.FieldUpdateTime)) +} + // WhereUsername applies the entql string predicate on the username field. func (f *UserFilter) WhereUsername(p entql.StringP) { f.Where(p.Field(user.FieldUsername)) @@ -1330,7 +1570,7 @@ type UserPermissionsFilter struct { // Where applies the entql predicate on the query filter. func (f *UserPermissionsFilter) Where(p entql.P) { f.addPredicate(func(s *sql.Selector) { - if err := schemaGraph.EvalP(schemaGraph.Nodes[10].Type, p, s); err != nil { + if err := schemaGraph.EvalP(schemaGraph.Nodes[11].Type, p, s); err != nil { s.AddError(err) } }) @@ -1341,16 +1581,21 @@ func (f *UserPermissionsFilter) WhereID(p entql.StringP) { f.Where(p.Field(userpermissions.FieldID)) } +// WhereCreateTime applies the entql time.Time predicate on the create_time field. +func (f *UserPermissionsFilter) WhereCreateTime(p entql.TimeP) { + f.Where(p.Field(userpermissions.FieldCreateTime)) +} + +// WhereUpdateTime applies the entql time.Time predicate on the update_time field. +func (f *UserPermissionsFilter) WhereUpdateTime(p entql.TimeP) { + f.Where(p.Field(userpermissions.FieldUpdateTime)) +} + // WhereUserID applies the entql string predicate on the user_id field. func (f *UserPermissionsFilter) WhereUserID(p entql.StringP) { f.Where(p.Field(userpermissions.FieldUserID)) } -// WhereCanEdit applies the entql bool predicate on the CanEdit field. -func (f *UserPermissionsFilter) WhereCanEdit(p entql.BoolP) { - f.Where(p.Field(userpermissions.FieldCanEdit)) -} - // WhereAdmin applies the entql bool predicate on the Admin field. func (f *UserPermissionsFilter) WhereAdmin(p entql.BoolP) { f.Where(p.Field(userpermissions.FieldAdmin)) @@ -1361,6 +1606,11 @@ func (f *UserPermissionsFilter) WhereCanCreatePublic(p entql.BoolP) { f.Where(p.Field(userpermissions.FieldCanCreatePublic)) } +// WhereCanEdit applies the entql bool predicate on the CanEdit field. +func (f *UserPermissionsFilter) WhereCanEdit(p entql.BoolP) { + f.Where(p.Field(userpermissions.FieldCanEdit)) +} + // WhereHasUser applies a predicate to check if query has an edge user. func (f *UserPermissionsFilter) WhereHasUser() { f.Where(entql.HasEdge("user")) diff --git a/internal/ent/gql_collection.go b/internal/ent/gql_collection.go index cc0c82f9..e476c966 100644 --- a/internal/ent/gql_collection.go +++ b/internal/ent/gql_collection.go @@ -8,6 +8,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -133,6 +134,16 @@ func (a *AuthorQuery) collectField(ctx context.Context, opCtx *graphql.Operation a.WithNamedBooks(alias, func(wq *BookQuery) { *wq = *query }) + case "createTime": + if _, ok := fieldSeen[author.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, author.FieldCreateTime) + fieldSeen[author.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[author.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, author.FieldUpdateTime) + fieldSeen[author.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[author.FieldCalibreID]; !ok { selectedFields = append(selectedFields, author.FieldCalibreID) @@ -327,6 +338,28 @@ func (b *BookQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo b.WithNamedShelf(alias, func(wq *ShelfQuery) { *wq = *query }) + case "files": + var ( + alias = field.Alias + path = append(path, alias) + query = (&BookFileClient{config: b.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + b.WithNamedFiles(alias, func(wq *BookFileQuery) { + *wq = *query + }) + case "createTime": + if _, ok := fieldSeen[book.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, book.FieldCreateTime) + fieldSeen[book.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[book.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, book.FieldUpdateTime) + fieldSeen[book.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[book.FieldCalibreID]; !ok { selectedFields = append(selectedFields, book.FieldCalibreID) @@ -436,6 +469,108 @@ func newBookPaginateArgs(rv map[string]any) *bookPaginateArgs { return args } +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (bf *BookFileQuery) CollectFields(ctx context.Context, satisfies ...string) (*BookFileQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return bf, nil + } + if err := bf.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return bf, nil +} + +func (bf *BookFileQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(bookfile.Columns)) + selectedFields = []string{bookfile.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "book": + var ( + alias = field.Alias + path = append(path, alias) + query = (&BookClient{config: bf.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + bf.withBook = query + case "createTime": + if _, ok := fieldSeen[bookfile.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, bookfile.FieldCreateTime) + fieldSeen[bookfile.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[bookfile.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, bookfile.FieldUpdateTime) + fieldSeen[bookfile.FieldUpdateTime] = struct{}{} + } + case "name": + if _, ok := fieldSeen[bookfile.FieldName]; !ok { + selectedFields = append(selectedFields, bookfile.FieldName) + fieldSeen[bookfile.FieldName] = struct{}{} + } + case "path": + if _, ok := fieldSeen[bookfile.FieldPath]; !ok { + selectedFields = append(selectedFields, bookfile.FieldPath) + fieldSeen[bookfile.FieldPath] = struct{}{} + } + case "size": + if _, ok := fieldSeen[bookfile.FieldSize]; !ok { + selectedFields = append(selectedFields, bookfile.FieldSize) + fieldSeen[bookfile.FieldSize] = struct{}{} + } + case "format": + if _, ok := fieldSeen[bookfile.FieldFormat]; !ok { + selectedFields = append(selectedFields, bookfile.FieldFormat) + fieldSeen[bookfile.FieldFormat] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + bf.Select(selectedFields...) + } + return nil +} + +type bookfilePaginateArgs struct { + first, last *int + after, before *Cursor + opts []BookFilePaginateOption +} + +func newBookFilePaginateArgs(rv map[string]any) *bookfilePaginateArgs { + args := &bookfilePaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[whereField].(*BookFileWhereInput); ok { + args.opts = append(args.opts, WithBookFileFilter(v.Filter)) + } + return args +} + // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. func (i *IdentifierQuery) CollectFields(ctx context.Context, satisfies ...string) (*IdentifierQuery, error) { fc := graphql.GetFieldContext(ctx) @@ -467,6 +602,16 @@ func (i *IdentifierQuery) collectField(ctx context.Context, opCtx *graphql.Opera return err } i.withBook = query + case "createTime": + if _, ok := fieldSeen[identifier.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, identifier.FieldCreateTime) + fieldSeen[identifier.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[identifier.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, identifier.FieldUpdateTime) + fieldSeen[identifier.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[identifier.FieldCalibreID]; !ok { selectedFields = append(selectedFields, identifier.FieldCalibreID) @@ -660,6 +805,16 @@ func (l *LanguageQuery) collectField(ctx context.Context, opCtx *graphql.Operati l.WithNamedBooks(alias, func(wq *BookQuery) { *wq = *query }) + case "createTime": + if _, ok := fieldSeen[language.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, language.FieldCreateTime) + fieldSeen[language.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[language.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, language.FieldUpdateTime) + fieldSeen[language.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[language.FieldCalibreID]; !ok { selectedFields = append(selectedFields, language.FieldCalibreID) @@ -848,6 +1003,16 @@ func (pu *PublisherQuery) collectField(ctx context.Context, opCtx *graphql.Opera pu.WithNamedBooks(alias, func(wq *BookQuery) { *wq = *query }) + case "createTime": + if _, ok := fieldSeen[publisher.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, publisher.FieldCreateTime) + fieldSeen[publisher.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[publisher.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, publisher.FieldUpdateTime) + fieldSeen[publisher.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[publisher.FieldCalibreID]; !ok { selectedFields = append(selectedFields, publisher.FieldCalibreID) @@ -960,6 +1125,16 @@ func (s *SeriesQuery) collectField(ctx context.Context, opCtx *graphql.Operation s.WithNamedBooks(alias, func(wq *BookQuery) { *wq = *query }) + case "createTime": + if _, ok := fieldSeen[series.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, series.FieldCreateTime) + fieldSeen[series.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[series.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, series.FieldUpdateTime) + fieldSeen[series.FieldUpdateTime] = struct{}{} + } case "calibreID": if _, ok := fieldSeen[series.FieldCalibreID]; !ok { selectedFields = append(selectedFields, series.FieldCalibreID) @@ -1167,6 +1342,16 @@ func (s *ShelfQuery) collectField(ctx context.Context, opCtx *graphql.OperationC s.WithNamedBooks(alias, func(wq *BookQuery) { *wq = *query }) + case "createTime": + if _, ok := fieldSeen[shelf.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, shelf.FieldCreateTime) + fieldSeen[shelf.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[shelf.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, shelf.FieldUpdateTime) + fieldSeen[shelf.FieldUpdateTime] = struct{}{} + } case "public": if _, ok := fieldSeen[shelf.FieldPublic]; !ok { selectedFields = append(selectedFields, shelf.FieldPublic) @@ -1636,6 +1821,16 @@ func (u *UserQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo return err } u.withUserPermissions = query + case "createTime": + if _, ok := fieldSeen[user.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, user.FieldCreateTime) + fieldSeen[user.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[user.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, user.FieldUpdateTime) + fieldSeen[user.FieldUpdateTime] = struct{}{} + } case "username": if _, ok := fieldSeen[user.FieldUsername]; !ok { selectedFields = append(selectedFields, user.FieldUsername) @@ -1744,16 +1939,21 @@ func (up *UserPermissionsQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, userpermissions.FieldUserID) fieldSeen[userpermissions.FieldUserID] = struct{}{} } + case "createTime": + if _, ok := fieldSeen[userpermissions.FieldCreateTime]; !ok { + selectedFields = append(selectedFields, userpermissions.FieldCreateTime) + fieldSeen[userpermissions.FieldCreateTime] = struct{}{} + } + case "updateTime": + if _, ok := fieldSeen[userpermissions.FieldUpdateTime]; !ok { + selectedFields = append(selectedFields, userpermissions.FieldUpdateTime) + fieldSeen[userpermissions.FieldUpdateTime] = struct{}{} + } case "userID": if _, ok := fieldSeen[userpermissions.FieldUserID]; !ok { selectedFields = append(selectedFields, userpermissions.FieldUserID) fieldSeen[userpermissions.FieldUserID] = struct{}{} } - case "canedit": - if _, ok := fieldSeen[userpermissions.FieldCanEdit]; !ok { - selectedFields = append(selectedFields, userpermissions.FieldCanEdit) - fieldSeen[userpermissions.FieldCanEdit] = struct{}{} - } case "admin": if _, ok := fieldSeen[userpermissions.FieldAdmin]; !ok { selectedFields = append(selectedFields, userpermissions.FieldAdmin) @@ -1764,6 +1964,11 @@ func (up *UserPermissionsQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, userpermissions.FieldCanCreatePublic) fieldSeen[userpermissions.FieldCanCreatePublic] = struct{}{} } + case "canedit": + if _, ok := fieldSeen[userpermissions.FieldCanEdit]; !ok { + selectedFields = append(selectedFields, userpermissions.FieldCanEdit) + fieldSeen[userpermissions.FieldCanEdit] = struct{}{} + } case "id": case "__typename": default: diff --git a/internal/ent/gql_edge.go b/internal/ent/gql_edge.go index 09202e4d..fa3c2164 100644 --- a/internal/ent/gql_edge.go +++ b/internal/ent/gql_edge.go @@ -113,6 +113,26 @@ func (b *Book) Shelf(ctx context.Context) (result []*Shelf, err error) { return result, err } +func (b *Book) Files(ctx context.Context) (result []*BookFile, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = b.NamedFiles(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = b.Edges.FilesOrErr() + } + if IsNotLoaded(err) { + result, err = b.QueryFiles().All(ctx) + } + return result, err +} + +func (bf *BookFile) Book(ctx context.Context) (*Book, error) { + result, err := bf.Edges.BookOrErr() + if IsNotLoaded(err) { + result, err = bf.QueryBook().Only(ctx) + } + return result, err +} + func (i *Identifier) Book(ctx context.Context) (*Book, error) { result, err := i.Edges.BookOrErr() if IsNotLoaded(err) { diff --git a/internal/ent/gql_mutation_input.go b/internal/ent/gql_mutation_input.go index 20d056db..18945709 100644 --- a/internal/ent/gql_mutation_input.go +++ b/internal/ent/gql_mutation_input.go @@ -9,15 +9,23 @@ import ( // CreateAuthorInput represents a mutation input for creating authors. type CreateAuthorInput struct { - CalibreID *int64 - Name string - Sort string - Link *string - BookIDs []ksuid.ID + CreateTime *time.Time + UpdateTime *time.Time + CalibreID *int64 + Name string + Sort string + Link *string + BookIDs []ksuid.ID } // Mutate applies the CreateAuthorInput on the AuthorMutation builder. func (i *CreateAuthorInput) Mutate(m *AuthorMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -39,6 +47,7 @@ func (c *AuthorCreate) SetInput(i CreateAuthorInput) *AuthorCreate { // UpdateAuthorInput represents a mutation input for updating authors. type UpdateAuthorInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Name *string @@ -52,6 +61,9 @@ type UpdateAuthorInput struct { // Mutate applies the UpdateAuthorInput on the AuthorMutation builder. func (i *UpdateAuthorInput) Mutate(m *AuthorMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -95,6 +107,8 @@ func (c *AuthorUpdateOne) SetInput(i UpdateAuthorInput) *AuthorUpdateOne { // CreateBookInput represents a mutation input for creating books. type CreateBookInput struct { + CreateTime *time.Time + UpdateTime *time.Time CalibreID *int64 Title string Sort string @@ -110,10 +124,17 @@ type CreateBookInput struct { TagIDs []ksuid.ID LanguageIDs []ksuid.ID ShelfIDs []ksuid.ID + FileIDs []ksuid.ID } // Mutate applies the CreateBookInput on the BookMutation builder. func (i *CreateBookInput) Mutate(m *BookMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -153,6 +174,9 @@ func (i *CreateBookInput) Mutate(m *BookMutation) { if v := i.ShelfIDs; len(v) > 0 { m.AddShelfIDs(v...) } + if v := i.FileIDs; len(v) > 0 { + m.AddFileIDs(v...) + } } // SetInput applies the change-set in the CreateBookInput on the BookCreate builder. @@ -163,6 +187,7 @@ func (c *BookCreate) SetInput(i CreateBookInput) *BookCreate { // UpdateBookInput represents a mutation input for updating books. type UpdateBookInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Title *string @@ -197,10 +222,16 @@ type UpdateBookInput struct { ClearShelf bool AddShelfIDs []ksuid.ID RemoveShelfIDs []ksuid.ID + ClearFiles bool + AddFileIDs []ksuid.ID + RemoveFileIDs []ksuid.ID } // Mutate applies the UpdateBookInput on the BookMutation builder. func (i *UpdateBookInput) Mutate(m *BookMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -303,6 +334,15 @@ func (i *UpdateBookInput) Mutate(m *BookMutation) { if v := i.RemoveShelfIDs; len(v) > 0 { m.RemoveShelfIDs(v...) } + if i.ClearFiles { + m.ClearFiles() + } + if v := i.AddFileIDs; len(v) > 0 { + m.AddFileIDs(v...) + } + if v := i.RemoveFileIDs; len(v) > 0 { + m.RemoveFileIDs(v...) + } } // SetInput applies the change-set in the UpdateBookInput on the BookUpdate builder. @@ -319,14 +359,22 @@ func (c *BookUpdateOne) SetInput(i UpdateBookInput) *BookUpdateOne { // CreateIdentifierInput represents a mutation input for creating identifiers. type CreateIdentifierInput struct { - CalibreID *int64 - Type string - Value string - BookID ksuid.ID + CreateTime *time.Time + UpdateTime *time.Time + CalibreID *int64 + Type string + Value string + BookID ksuid.ID } // Mutate applies the CreateIdentifierInput on the IdentifierMutation builder. func (i *CreateIdentifierInput) Mutate(m *IdentifierMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -343,6 +391,7 @@ func (c *IdentifierCreate) SetInput(i CreateIdentifierInput) *IdentifierCreate { // UpdateIdentifierInput represents a mutation input for updating identifiers. type UpdateIdentifierInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Type *string @@ -352,6 +401,9 @@ type UpdateIdentifierInput struct { // Mutate applies the UpdateIdentifierInput on the IdentifierMutation builder. func (i *UpdateIdentifierInput) Mutate(m *IdentifierMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -383,13 +435,21 @@ func (c *IdentifierUpdateOne) SetInput(i UpdateIdentifierInput) *IdentifierUpdat // CreateLanguageInput represents a mutation input for creating languages. type CreateLanguageInput struct { - CalibreID *int64 - Code string - BookIDs []ksuid.ID + CreateTime *time.Time + UpdateTime *time.Time + CalibreID *int64 + Code string + BookIDs []ksuid.ID } // Mutate applies the CreateLanguageInput on the LanguageMutation builder. func (i *CreateLanguageInput) Mutate(m *LanguageMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -407,6 +467,7 @@ func (c *LanguageCreate) SetInput(i CreateLanguageInput) *LanguageCreate { // UpdateLanguageInput represents a mutation input for updating languages. type UpdateLanguageInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Code *string @@ -417,6 +478,9 @@ type UpdateLanguageInput struct { // Mutate applies the UpdateLanguageInput on the LanguageMutation builder. func (i *UpdateLanguageInput) Mutate(m *LanguageMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -451,13 +515,21 @@ func (c *LanguageUpdateOne) SetInput(i UpdateLanguageInput) *LanguageUpdateOne { // CreatePublisherInput represents a mutation input for creating publishers. type CreatePublisherInput struct { - CalibreID *int64 - Name string - BookIDs []ksuid.ID + CreateTime *time.Time + UpdateTime *time.Time + CalibreID *int64 + Name string + BookIDs []ksuid.ID } // Mutate applies the CreatePublisherInput on the PublisherMutation builder. func (i *CreatePublisherInput) Mutate(m *PublisherMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -475,6 +547,7 @@ func (c *PublisherCreate) SetInput(i CreatePublisherInput) *PublisherCreate { // UpdatePublisherInput represents a mutation input for updating publishers. type UpdatePublisherInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Name *string @@ -485,6 +558,9 @@ type UpdatePublisherInput struct { // Mutate applies the UpdatePublisherInput on the PublisherMutation builder. func (i *UpdatePublisherInput) Mutate(m *PublisherMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -519,14 +595,22 @@ func (c *PublisherUpdateOne) SetInput(i UpdatePublisherInput) *PublisherUpdateOn // CreateSeriesInput represents a mutation input for creating seriesslice. type CreateSeriesInput struct { - CalibreID *int64 - Name string - Sort string - BookIDs []ksuid.ID + CreateTime *time.Time + UpdateTime *time.Time + CalibreID *int64 + Name string + Sort string + BookIDs []ksuid.ID } // Mutate applies the CreateSeriesInput on the SeriesMutation builder. func (i *CreateSeriesInput) Mutate(m *SeriesMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.CalibreID; v != nil { m.SetCalibreID(*v) } @@ -545,6 +629,7 @@ func (c *SeriesCreate) SetInput(i CreateSeriesInput) *SeriesCreate { // UpdateSeriesInput represents a mutation input for updating seriesslice. type UpdateSeriesInput struct { + UpdateTime *time.Time ClearCalibreID bool CalibreID *int64 Name *string @@ -556,6 +641,9 @@ type UpdateSeriesInput struct { // Mutate applies the UpdateSeriesInput on the SeriesMutation builder. func (i *UpdateSeriesInput) Mutate(m *SeriesMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if i.ClearCalibreID { m.ClearCalibreID() } @@ -593,6 +681,7 @@ func (c *SeriesUpdateOne) SetInput(i UpdateSeriesInput) *SeriesUpdateOne { // UpdateShelfInput represents a mutation input for updating shelves. type UpdateShelfInput struct { + UpdateTime *time.Time Public *bool Name *string ClearDescription bool @@ -604,6 +693,9 @@ type UpdateShelfInput struct { // Mutate applies the UpdateShelfInput on the ShelfMutation builder. func (i *UpdateShelfInput) Mutate(m *ShelfMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.Public; v != nil { m.SetPublic(*v) } @@ -709,6 +801,7 @@ func (c *TagUpdateOne) SetInput(i UpdateTagInput) *TagUpdateOne { // UpdateUserInput represents a mutation input for updating users. type UpdateUserInput struct { + UpdateTime *time.Time Username *string ClearPasswordHash bool PasswordHash *string @@ -720,6 +813,9 @@ type UpdateUserInput struct { // Mutate applies the UpdateUserInput on the UserMutation builder. func (i *UpdateUserInput) Mutate(m *UserMutation) { + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } if v := i.Username; v != nil { m.SetUsername(*v) } @@ -757,6 +853,8 @@ func (c *UserUpdateOne) SetInput(i UpdateUserInput) *UserUpdateOne { // CreateUserInput represents a mutation input for creating users. type CreateUserInput struct { + CreateTime *time.Time + UpdateTime *time.Time Username string PasswordHash *string Email string @@ -766,6 +864,12 @@ type CreateUserInput struct { // Mutate applies the CreateUserInput on the UserMutation builder. func (i *CreateUserInput) Mutate(m *UserMutation) { + if v := i.CreateTime; v != nil { + m.SetCreateTime(*v) + } + if v := i.UpdateTime; v != nil { + m.SetUpdateTime(*v) + } m.SetUsername(i.Username) if v := i.PasswordHash; v != nil { m.SetPasswordHash(*v) diff --git a/internal/ent/gql_node.go b/internal/ent/gql_node.go index 207a7469..bbdb56cf 100644 --- a/internal/ent/gql_node.go +++ b/internal/ent/gql_node.go @@ -7,6 +7,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -34,6 +35,9 @@ func (n *Author) IsNode() {} // IsNode implements the Node interface check for GQLGen. func (n *Book) IsNode() {} +// IsNode implements the Node interface check for GQLGen. +func (n *BookFile) IsNode() {} + // IsNode implements the Node interface check for GQLGen. func (n *Identifier) IsNode() {} @@ -151,6 +155,22 @@ func (c *Client) noder(ctx context.Context, table string, id ksuid.ID) (Noder, e return nil, err } return n, nil + case bookfile.Table: + var uid ksuid.ID + if err := uid.UnmarshalGQL(id); err != nil { + return nil, err + } + query := c.BookFile.Query(). + Where(bookfile.ID(uid)) + query, err := query.CollectFields(ctx, "BookFile") + if err != nil { + return nil, err + } + n, err := query.Only(ctx) + if err != nil { + return nil, err + } + return n, nil case identifier.Table: var uid ksuid.ID if err := uid.UnmarshalGQL(id); err != nil { @@ -400,6 +420,22 @@ func (c *Client) noders(ctx context.Context, table string, ids []ksuid.ID) ([]No *noder = node } } + case bookfile.Table: + query := c.BookFile.Query(). + Where(bookfile.IDIn(ids...)) + query, err := query.CollectFields(ctx, "BookFile") + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } case identifier.Table: query := c.Identifier.Query(). Where(identifier.IDIn(ids...)) diff --git a/internal/ent/gql_pagination.go b/internal/ent/gql_pagination.go index 8268f076..0423fe3f 100644 --- a/internal/ent/gql_pagination.go +++ b/internal/ent/gql_pagination.go @@ -9,6 +9,7 @@ import ( "io" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -628,8 +629,12 @@ func (p *bookPager) applyOrder(query *BookQuery) *BookQuery { if o.Field.column == DefaultBookOrder.Field.column { defaultOrdered = true } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(o.Field.column) + switch o.Field.column { + case BookOrderFieldFilesCount.column: + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } if !defaultOrdered { @@ -643,9 +648,18 @@ func (p *bookPager) applyOrder(query *BookQuery) *BookQuery { } func (p *bookPager) orderExpr(query *BookQuery) sql.Querier { - if len(query.ctx.Fields) > 0 { - for _, o := range p.order { - query.ctx.AppendFieldOnce(o.Field.column) + for _, o := range p.order { + switch o.Field.column { + case BookOrderFieldFilesCount.column: + direction := o.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(o.Field.toTerm(direction.OrderTermOption())) + default: + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(o.Field.column) + } } } return sql.ExprFunc(func(b *sql.Builder) { @@ -772,6 +786,25 @@ var ( } }, } + // BookOrderFieldFilesCount orders by FILES_COUNT. + BookOrderFieldFilesCount = &BookOrderField{ + Value: func(b *Book) (ent.Value, error) { + return b.Value("files_count") + }, + column: "files_count", + toTerm: func(opts ...sql.OrderTermOption) book.OrderOption { + return book.ByFilesCount( + append(opts, sql.OrderSelectAs("files_count"))..., + ) + }, + toCursor: func(b *Book) Cursor { + cv, _ := b.Value("files_count") + return Cursor{ + ID: b.ID, + Value: cv, + } + }, + } ) // String implement fmt.Stringer interface. @@ -786,6 +819,8 @@ func (f BookOrderField) String() string { str = "PUB_DATE" case BookOrderFieldIsbn.column: str = "ISBN" + case BookOrderFieldFilesCount.column: + str = "FILES_COUNT" } return str } @@ -810,6 +845,8 @@ func (f *BookOrderField) UnmarshalGQL(v interface{}) error { *f = *BookOrderFieldPublishedDate case "ISBN": *f = *BookOrderFieldIsbn + case "FILES_COUNT": + *f = *BookOrderFieldFilesCount default: return fmt.Errorf("%s is not a valid BookOrderField", str) } @@ -857,6 +894,252 @@ func (b *Book) ToEdge(order *BookOrder) *BookEdge { } } +// BookFileEdge is the edge representation of BookFile. +type BookFileEdge struct { + Node *BookFile `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// BookFileConnection is the connection containing edges to BookFile. +type BookFileConnection struct { + Edges []*BookFileEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *BookFileConnection) build(nodes []*BookFile, pager *bookfilePager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *BookFile + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *BookFile { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *BookFile { + return nodes[i] + } + } + c.Edges = make([]*BookFileEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &BookFileEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// BookFilePaginateOption enables pagination customization. +type BookFilePaginateOption func(*bookfilePager) error + +// WithBookFileOrder configures pagination ordering. +func WithBookFileOrder(order *BookFileOrder) BookFilePaginateOption { + if order == nil { + order = DefaultBookFileOrder + } + o := *order + return func(pager *bookfilePager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultBookFileOrder.Field + } + pager.order = &o + return nil + } +} + +// WithBookFileFilter configures pagination filter. +func WithBookFileFilter(filter func(*BookFileQuery) (*BookFileQuery, error)) BookFilePaginateOption { + return func(pager *bookfilePager) error { + if filter == nil { + return errors.New("BookFileQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type bookfilePager struct { + reverse bool + order *BookFileOrder + filter func(*BookFileQuery) (*BookFileQuery, error) +} + +func newBookFilePager(opts []BookFilePaginateOption, reverse bool) (*bookfilePager, error) { + pager := &bookfilePager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultBookFileOrder + } + return pager, nil +} + +func (p *bookfilePager) applyFilter(query *BookFileQuery) (*BookFileQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *bookfilePager) toCursor(bf *BookFile) Cursor { + return p.order.Field.toCursor(bf) +} + +func (p *bookfilePager) applyCursors(query *BookFileQuery, after, before *Cursor) (*BookFileQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultBookFileOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *bookfilePager) applyOrder(query *BookFileQuery) *BookFileQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultBookFileOrder.Field { + query = query.Order(DefaultBookFileOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *bookfilePager) orderExpr(query *BookFileQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultBookFileOrder.Field { + b.Comma().Ident(DefaultBookFileOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a relay based cursor connection to BookFile. +func (bf *BookFileQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...BookFilePaginateOption, +) (*BookFileConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newBookFilePager(opts, last != nil) + if err != nil { + return nil, err + } + if bf, err = pager.applyFilter(bf); err != nil { + return nil, err + } + conn := &BookFileConnection{Edges: []*BookFileEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + if conn.TotalCount, err = bf.Clone().Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if bf, err = pager.applyCursors(bf, after, before); err != nil { + return nil, err + } + if limit := paginateLimit(first, last); limit != 0 { + bf.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := bf.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + bf = pager.applyOrder(bf) + nodes, err := bf.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +// BookFileOrderField defines the ordering field of BookFile. +type BookFileOrderField struct { + // Value extracts the ordering value from the given BookFile. + Value func(*BookFile) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) bookfile.OrderOption + toCursor func(*BookFile) Cursor +} + +// BookFileOrder defines the ordering of BookFile. +type BookFileOrder struct { + Direction OrderDirection `json:"direction"` + Field *BookFileOrderField `json:"field"` +} + +// DefaultBookFileOrder is the default ordering of BookFile. +var DefaultBookFileOrder = &BookFileOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &BookFileOrderField{ + Value: func(bf *BookFile) (ent.Value, error) { + return bf.ID, nil + }, + column: bookfile.FieldID, + toTerm: bookfile.ByID, + toCursor: func(bf *BookFile) Cursor { + return Cursor{ID: bf.ID} + }, + }, +} + +// ToEdge converts BookFile into BookFileEdge. +func (bf *BookFile) ToEdge(order *BookFileOrder) *BookFileEdge { + if order == nil { + order = DefaultBookFileOrder + } + return &BookFileEdge{ + Node: bf, + Cursor: order.Field.toCursor(bf), + } +} + // IdentifierEdge is the edge representation of Identifier. type IdentifierEdge struct { Node *Identifier `json:"node"` diff --git a/internal/ent/gql_where_input.go b/internal/ent/gql_where_input.go index 714457e4..2689076e 100644 --- a/internal/ent/gql_where_input.go +++ b/internal/ent/gql_where_input.go @@ -7,6 +7,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" @@ -39,6 +40,26 @@ type AuthorWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "calibre_id" field predicates. CalibreID *int64 `json:"calibreID,omitempty"` CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` @@ -198,6 +219,54 @@ func (i *AuthorWhereInput) P() (predicate.Author, error) { if i.IDLTE != nil { predicates = append(predicates, author.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, author.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, author.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, author.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, author.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, author.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, author.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, author.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, author.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, author.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, author.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, author.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, author.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, author.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, author.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, author.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, author.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.CalibreID != nil { predicates = append(predicates, author.CalibreIDEQ(*i.CalibreID)) } @@ -397,6 +466,26 @@ type BookWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "calibre_id" field predicates. CalibreID *int64 `json:"calibreID,omitempty"` CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` @@ -539,6 +628,10 @@ type BookWhereInput struct { // "shelf" edge predicates. HasShelf *bool `json:"hasShelf,omitempty"` HasShelfWith []*ShelfWhereInput `json:"hasShelfWith,omitempty"` + + // "files" edge predicates. + HasFiles *bool `json:"hasFiles,omitempty"` + HasFilesWith []*BookFileWhereInput `json:"hasFilesWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -636,6 +729,54 @@ func (i *BookWhereInput) P() (predicate.Book, error) { if i.IDLTE != nil { predicates = append(predicates, book.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, book.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, book.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, book.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, book.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, book.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, book.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, book.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, book.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, book.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, book.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, book.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, book.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, book.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, book.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, book.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, book.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.CalibreID != nil { predicates = append(predicates, book.CalibreIDEQ(*i.CalibreID)) } @@ -1060,6 +1201,24 @@ func (i *BookWhereInput) P() (predicate.Book, error) { } predicates = append(predicates, book.HasShelfWith(with...)) } + if i.HasFiles != nil { + p := book.HasFiles() + if !*i.HasFiles { + p = book.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasFilesWith) > 0 { + with := make([]predicate.BookFile, 0, len(i.HasFilesWith)) + for _, w := range i.HasFilesWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasFilesWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, book.HasFilesWith(with...)) + } switch len(predicates) { case 0: return nil, ErrEmptyBookWhereInput @@ -1070,12 +1229,12 @@ func (i *BookWhereInput) P() (predicate.Book, error) { } } -// IdentifierWhereInput represents a where input for filtering Identifier queries. -type IdentifierWhereInput struct { - Predicates []predicate.Identifier `json:"-"` - Not *IdentifierWhereInput `json:"not,omitempty"` - Or []*IdentifierWhereInput `json:"or,omitempty"` - And []*IdentifierWhereInput `json:"and,omitempty"` +// BookFileWhereInput represents a where input for filtering BookFile queries. +type BookFileWhereInput struct { + Predicates []predicate.BookFile `json:"-"` + Not *BookFileWhereInput `json:"not,omitempty"` + Or []*BookFileWhereInput `json:"or,omitempty"` + And []*BookFileWhereInput `json:"and,omitempty"` // "id" field predicates. ID *ksuid.ID `json:"id,omitempty"` @@ -1087,47 +1246,71 @@ type IdentifierWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` - // "calibre_id" field predicates. - CalibreID *int64 `json:"calibreID,omitempty"` - CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` - CalibreIDIn []int64 `json:"calibreIDIn,omitempty"` - CalibreIDNotIn []int64 `json:"calibreIDNotIn,omitempty"` - CalibreIDGT *int64 `json:"calibreIDGT,omitempty"` - CalibreIDGTE *int64 `json:"calibreIDGTE,omitempty"` - CalibreIDLT *int64 `json:"calibreIDLT,omitempty"` - CalibreIDLTE *int64 `json:"calibreIDLTE,omitempty"` - CalibreIDIsNil bool `json:"calibreIDIsNil,omitempty"` - CalibreIDNotNil bool `json:"calibreIDNotNil,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` - // "type" field predicates. - Type *string `json:"type,omitempty"` - TypeNEQ *string `json:"typeNEQ,omitempty"` - TypeIn []string `json:"typeIn,omitempty"` - TypeNotIn []string `json:"typeNotIn,omitempty"` - TypeGT *string `json:"typeGT,omitempty"` - TypeGTE *string `json:"typeGTE,omitempty"` - TypeLT *string `json:"typeLT,omitempty"` - TypeLTE *string `json:"typeLTE,omitempty"` - TypeContains *string `json:"typeContains,omitempty"` - TypeHasPrefix *string `json:"typeHasPrefix,omitempty"` - TypeHasSuffix *string `json:"typeHasSuffix,omitempty"` - TypeEqualFold *string `json:"typeEqualFold,omitempty"` - TypeContainsFold *string `json:"typeContainsFold,omitempty"` + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` - // "value" field predicates. - Value *string `json:"value,omitempty"` - ValueNEQ *string `json:"valueNEQ,omitempty"` - ValueIn []string `json:"valueIn,omitempty"` - ValueNotIn []string `json:"valueNotIn,omitempty"` - ValueGT *string `json:"valueGT,omitempty"` - ValueGTE *string `json:"valueGTE,omitempty"` - ValueLT *string `json:"valueLT,omitempty"` - ValueLTE *string `json:"valueLTE,omitempty"` - ValueContains *string `json:"valueContains,omitempty"` - ValueHasPrefix *string `json:"valueHasPrefix,omitempty"` - ValueHasSuffix *string `json:"valueHasSuffix,omitempty"` - ValueEqualFold *string `json:"valueEqualFold,omitempty"` - ValueContainsFold *string `json:"valueContainsFold,omitempty"` + // "name" field predicates. + Name *string `json:"name,omitempty"` + NameNEQ *string `json:"nameNEQ,omitempty"` + NameIn []string `json:"nameIn,omitempty"` + NameNotIn []string `json:"nameNotIn,omitempty"` + NameGT *string `json:"nameGT,omitempty"` + NameGTE *string `json:"nameGTE,omitempty"` + NameLT *string `json:"nameLT,omitempty"` + NameLTE *string `json:"nameLTE,omitempty"` + NameContains *string `json:"nameContains,omitempty"` + NameHasPrefix *string `json:"nameHasPrefix,omitempty"` + NameHasSuffix *string `json:"nameHasSuffix,omitempty"` + NameEqualFold *string `json:"nameEqualFold,omitempty"` + NameContainsFold *string `json:"nameContainsFold,omitempty"` + + // "path" field predicates. + Path *string `json:"path,omitempty"` + PathNEQ *string `json:"pathNEQ,omitempty"` + PathIn []string `json:"pathIn,omitempty"` + PathNotIn []string `json:"pathNotIn,omitempty"` + PathGT *string `json:"pathGT,omitempty"` + PathGTE *string `json:"pathGTE,omitempty"` + PathLT *string `json:"pathLT,omitempty"` + PathLTE *string `json:"pathLTE,omitempty"` + PathContains *string `json:"pathContains,omitempty"` + PathHasPrefix *string `json:"pathHasPrefix,omitempty"` + PathHasSuffix *string `json:"pathHasSuffix,omitempty"` + PathEqualFold *string `json:"pathEqualFold,omitempty"` + PathContainsFold *string `json:"pathContainsFold,omitempty"` + + // "size" field predicates. + Size *int64 `json:"size,omitempty"` + SizeNEQ *int64 `json:"sizeNEQ,omitempty"` + SizeIn []int64 `json:"sizeIn,omitempty"` + SizeNotIn []int64 `json:"sizeNotIn,omitempty"` + SizeGT *int64 `json:"sizeGT,omitempty"` + SizeGTE *int64 `json:"sizeGTE,omitempty"` + SizeLT *int64 `json:"sizeLT,omitempty"` + SizeLTE *int64 `json:"sizeLTE,omitempty"` + + // "format" field predicates. + Format *bookfile.Format `json:"format,omitempty"` + FormatNEQ *bookfile.Format `json:"formatNEQ,omitempty"` + FormatIn []bookfile.Format `json:"formatIn,omitempty"` + FormatNotIn []bookfile.Format `json:"formatNotIn,omitempty"` // "book" edge predicates. HasBook *bool `json:"hasBook,omitempty"` @@ -1135,18 +1318,18 @@ type IdentifierWhereInput struct { } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *IdentifierWhereInput) AddPredicates(predicates ...predicate.Identifier) { +func (i *BookFileWhereInput) AddPredicates(predicates ...predicate.BookFile) { i.Predicates = append(i.Predicates, predicates...) } -// Filter applies the IdentifierWhereInput filter on the IdentifierQuery builder. -func (i *IdentifierWhereInput) Filter(q *IdentifierQuery) (*IdentifierQuery, error) { +// Filter applies the BookFileWhereInput filter on the BookFileQuery builder. +func (i *BookFileWhereInput) Filter(q *BookFileQuery) (*BookFileQuery, error) { if i == nil { return q, nil } p, err := i.P() if err != nil { - if err == ErrEmptyIdentifierWhereInput { + if err == ErrEmptyBookFileWhereInput { return q, nil } return nil, err @@ -1154,19 +1337,19 @@ func (i *IdentifierWhereInput) Filter(q *IdentifierQuery) (*IdentifierQuery, err return q.Where(p), nil } -// ErrEmptyIdentifierWhereInput is returned in case the IdentifierWhereInput is empty. -var ErrEmptyIdentifierWhereInput = errors.New("ent: empty predicate IdentifierWhereInput") +// ErrEmptyBookFileWhereInput is returned in case the BookFileWhereInput is empty. +var ErrEmptyBookFileWhereInput = errors.New("ent: empty predicate BookFileWhereInput") -// P returns a predicate for filtering identifiers. +// P returns a predicate for filtering bookfiles. // An error is returned if the input is empty or invalid. -func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { - var predicates []predicate.Identifier +func (i *BookFileWhereInput) P() (predicate.BookFile, error) { + var predicates []predicate.BookFile if i.Not != nil { p, err := i.Not.P() if err != nil { return nil, fmt.Errorf("%w: field 'not'", err) } - predicates = append(predicates, identifier.Not(p)) + predicates = append(predicates, bookfile.Not(p)) } switch n := len(i.Or); { case n == 1: @@ -1176,7 +1359,7 @@ func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { } predicates = append(predicates, p) case n > 1: - or := make([]predicate.Identifier, 0, n) + or := make([]predicate.BookFile, 0, n) for _, w := range i.Or { p, err := w.P() if err != nil { @@ -1184,7 +1367,7 @@ func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { } or = append(or, p) } - predicates = append(predicates, identifier.Or(or...)) + predicates = append(predicates, bookfile.Or(or...)) } switch n := len(i.And); { case n == 1: @@ -1194,7 +1377,7 @@ func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { } predicates = append(predicates, p) case n > 1: - and := make([]predicate.Identifier, 0, n) + and := make([]predicate.BookFile, 0, n) for _, w := range i.And { p, err := w.P() if err != nil { @@ -1202,59 +1385,477 @@ func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { } and = append(and, p) } - predicates = append(predicates, identifier.And(and...)) + predicates = append(predicates, bookfile.And(and...)) } predicates = append(predicates, i.Predicates...) if i.ID != nil { - predicates = append(predicates, identifier.IDEQ(*i.ID)) + predicates = append(predicates, bookfile.IDEQ(*i.ID)) } if i.IDNEQ != nil { - predicates = append(predicates, identifier.IDNEQ(*i.IDNEQ)) + predicates = append(predicates, bookfile.IDNEQ(*i.IDNEQ)) } if len(i.IDIn) > 0 { - predicates = append(predicates, identifier.IDIn(i.IDIn...)) + predicates = append(predicates, bookfile.IDIn(i.IDIn...)) } if len(i.IDNotIn) > 0 { - predicates = append(predicates, identifier.IDNotIn(i.IDNotIn...)) + predicates = append(predicates, bookfile.IDNotIn(i.IDNotIn...)) } if i.IDGT != nil { - predicates = append(predicates, identifier.IDGT(*i.IDGT)) + predicates = append(predicates, bookfile.IDGT(*i.IDGT)) } if i.IDGTE != nil { - predicates = append(predicates, identifier.IDGTE(*i.IDGTE)) + predicates = append(predicates, bookfile.IDGTE(*i.IDGTE)) } if i.IDLT != nil { - predicates = append(predicates, identifier.IDLT(*i.IDLT)) + predicates = append(predicates, bookfile.IDLT(*i.IDLT)) } if i.IDLTE != nil { - predicates = append(predicates, identifier.IDLTE(*i.IDLTE)) + predicates = append(predicates, bookfile.IDLTE(*i.IDLTE)) } - if i.CalibreID != nil { - predicates = append(predicates, identifier.CalibreIDEQ(*i.CalibreID)) + if i.CreateTime != nil { + predicates = append(predicates, bookfile.CreateTimeEQ(*i.CreateTime)) } - if i.CalibreIDNEQ != nil { - predicates = append(predicates, identifier.CalibreIDNEQ(*i.CalibreIDNEQ)) + if i.CreateTimeNEQ != nil { + predicates = append(predicates, bookfile.CreateTimeNEQ(*i.CreateTimeNEQ)) } - if len(i.CalibreIDIn) > 0 { - predicates = append(predicates, identifier.CalibreIDIn(i.CalibreIDIn...)) + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, bookfile.CreateTimeIn(i.CreateTimeIn...)) } - if len(i.CalibreIDNotIn) > 0 { - predicates = append(predicates, identifier.CalibreIDNotIn(i.CalibreIDNotIn...)) + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, bookfile.CreateTimeNotIn(i.CreateTimeNotIn...)) } - if i.CalibreIDGT != nil { - predicates = append(predicates, identifier.CalibreIDGT(*i.CalibreIDGT)) + if i.CreateTimeGT != nil { + predicates = append(predicates, bookfile.CreateTimeGT(*i.CreateTimeGT)) } - if i.CalibreIDGTE != nil { - predicates = append(predicates, identifier.CalibreIDGTE(*i.CalibreIDGTE)) + if i.CreateTimeGTE != nil { + predicates = append(predicates, bookfile.CreateTimeGTE(*i.CreateTimeGTE)) } - if i.CalibreIDLT != nil { - predicates = append(predicates, identifier.CalibreIDLT(*i.CalibreIDLT)) + if i.CreateTimeLT != nil { + predicates = append(predicates, bookfile.CreateTimeLT(*i.CreateTimeLT)) } - if i.CalibreIDLTE != nil { - predicates = append(predicates, identifier.CalibreIDLTE(*i.CalibreIDLTE)) + if i.CreateTimeLTE != nil { + predicates = append(predicates, bookfile.CreateTimeLTE(*i.CreateTimeLTE)) } - if i.CalibreIDIsNil { - predicates = append(predicates, identifier.CalibreIDIsNil()) + if i.UpdateTime != nil { + predicates = append(predicates, bookfile.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, bookfile.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, bookfile.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, bookfile.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, bookfile.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, bookfile.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, bookfile.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, bookfile.UpdateTimeLTE(*i.UpdateTimeLTE)) + } + if i.Name != nil { + predicates = append(predicates, bookfile.NameEQ(*i.Name)) + } + if i.NameNEQ != nil { + predicates = append(predicates, bookfile.NameNEQ(*i.NameNEQ)) + } + if len(i.NameIn) > 0 { + predicates = append(predicates, bookfile.NameIn(i.NameIn...)) + } + if len(i.NameNotIn) > 0 { + predicates = append(predicates, bookfile.NameNotIn(i.NameNotIn...)) + } + if i.NameGT != nil { + predicates = append(predicates, bookfile.NameGT(*i.NameGT)) + } + if i.NameGTE != nil { + predicates = append(predicates, bookfile.NameGTE(*i.NameGTE)) + } + if i.NameLT != nil { + predicates = append(predicates, bookfile.NameLT(*i.NameLT)) + } + if i.NameLTE != nil { + predicates = append(predicates, bookfile.NameLTE(*i.NameLTE)) + } + if i.NameContains != nil { + predicates = append(predicates, bookfile.NameContains(*i.NameContains)) + } + if i.NameHasPrefix != nil { + predicates = append(predicates, bookfile.NameHasPrefix(*i.NameHasPrefix)) + } + if i.NameHasSuffix != nil { + predicates = append(predicates, bookfile.NameHasSuffix(*i.NameHasSuffix)) + } + if i.NameEqualFold != nil { + predicates = append(predicates, bookfile.NameEqualFold(*i.NameEqualFold)) + } + if i.NameContainsFold != nil { + predicates = append(predicates, bookfile.NameContainsFold(*i.NameContainsFold)) + } + if i.Path != nil { + predicates = append(predicates, bookfile.PathEQ(*i.Path)) + } + if i.PathNEQ != nil { + predicates = append(predicates, bookfile.PathNEQ(*i.PathNEQ)) + } + if len(i.PathIn) > 0 { + predicates = append(predicates, bookfile.PathIn(i.PathIn...)) + } + if len(i.PathNotIn) > 0 { + predicates = append(predicates, bookfile.PathNotIn(i.PathNotIn...)) + } + if i.PathGT != nil { + predicates = append(predicates, bookfile.PathGT(*i.PathGT)) + } + if i.PathGTE != nil { + predicates = append(predicates, bookfile.PathGTE(*i.PathGTE)) + } + if i.PathLT != nil { + predicates = append(predicates, bookfile.PathLT(*i.PathLT)) + } + if i.PathLTE != nil { + predicates = append(predicates, bookfile.PathLTE(*i.PathLTE)) + } + if i.PathContains != nil { + predicates = append(predicates, bookfile.PathContains(*i.PathContains)) + } + if i.PathHasPrefix != nil { + predicates = append(predicates, bookfile.PathHasPrefix(*i.PathHasPrefix)) + } + if i.PathHasSuffix != nil { + predicates = append(predicates, bookfile.PathHasSuffix(*i.PathHasSuffix)) + } + if i.PathEqualFold != nil { + predicates = append(predicates, bookfile.PathEqualFold(*i.PathEqualFold)) + } + if i.PathContainsFold != nil { + predicates = append(predicates, bookfile.PathContainsFold(*i.PathContainsFold)) + } + if i.Size != nil { + predicates = append(predicates, bookfile.SizeEQ(*i.Size)) + } + if i.SizeNEQ != nil { + predicates = append(predicates, bookfile.SizeNEQ(*i.SizeNEQ)) + } + if len(i.SizeIn) > 0 { + predicates = append(predicates, bookfile.SizeIn(i.SizeIn...)) + } + if len(i.SizeNotIn) > 0 { + predicates = append(predicates, bookfile.SizeNotIn(i.SizeNotIn...)) + } + if i.SizeGT != nil { + predicates = append(predicates, bookfile.SizeGT(*i.SizeGT)) + } + if i.SizeGTE != nil { + predicates = append(predicates, bookfile.SizeGTE(*i.SizeGTE)) + } + if i.SizeLT != nil { + predicates = append(predicates, bookfile.SizeLT(*i.SizeLT)) + } + if i.SizeLTE != nil { + predicates = append(predicates, bookfile.SizeLTE(*i.SizeLTE)) + } + if i.Format != nil { + predicates = append(predicates, bookfile.FormatEQ(*i.Format)) + } + if i.FormatNEQ != nil { + predicates = append(predicates, bookfile.FormatNEQ(*i.FormatNEQ)) + } + if len(i.FormatIn) > 0 { + predicates = append(predicates, bookfile.FormatIn(i.FormatIn...)) + } + if len(i.FormatNotIn) > 0 { + predicates = append(predicates, bookfile.FormatNotIn(i.FormatNotIn...)) + } + + if i.HasBook != nil { + p := bookfile.HasBook() + if !*i.HasBook { + p = bookfile.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasBookWith) > 0 { + with := make([]predicate.Book, 0, len(i.HasBookWith)) + for _, w := range i.HasBookWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasBookWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, bookfile.HasBookWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyBookFileWhereInput + case 1: + return predicates[0], nil + default: + return bookfile.And(predicates...), nil + } +} + +// IdentifierWhereInput represents a where input for filtering Identifier queries. +type IdentifierWhereInput struct { + Predicates []predicate.Identifier `json:"-"` + Not *IdentifierWhereInput `json:"not,omitempty"` + Or []*IdentifierWhereInput `json:"or,omitempty"` + And []*IdentifierWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *ksuid.ID `json:"id,omitempty"` + IDNEQ *ksuid.ID `json:"idNEQ,omitempty"` + IDIn []ksuid.ID `json:"idIn,omitempty"` + IDNotIn []ksuid.ID `json:"idNotIn,omitempty"` + IDGT *ksuid.ID `json:"idGT,omitempty"` + IDGTE *ksuid.ID `json:"idGTE,omitempty"` + IDLT *ksuid.ID `json:"idLT,omitempty"` + IDLTE *ksuid.ID `json:"idLTE,omitempty"` + + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + + // "calibre_id" field predicates. + CalibreID *int64 `json:"calibreID,omitempty"` + CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` + CalibreIDIn []int64 `json:"calibreIDIn,omitempty"` + CalibreIDNotIn []int64 `json:"calibreIDNotIn,omitempty"` + CalibreIDGT *int64 `json:"calibreIDGT,omitempty"` + CalibreIDGTE *int64 `json:"calibreIDGTE,omitempty"` + CalibreIDLT *int64 `json:"calibreIDLT,omitempty"` + CalibreIDLTE *int64 `json:"calibreIDLTE,omitempty"` + CalibreIDIsNil bool `json:"calibreIDIsNil,omitempty"` + CalibreIDNotNil bool `json:"calibreIDNotNil,omitempty"` + + // "type" field predicates. + Type *string `json:"type,omitempty"` + TypeNEQ *string `json:"typeNEQ,omitempty"` + TypeIn []string `json:"typeIn,omitempty"` + TypeNotIn []string `json:"typeNotIn,omitempty"` + TypeGT *string `json:"typeGT,omitempty"` + TypeGTE *string `json:"typeGTE,omitempty"` + TypeLT *string `json:"typeLT,omitempty"` + TypeLTE *string `json:"typeLTE,omitempty"` + TypeContains *string `json:"typeContains,omitempty"` + TypeHasPrefix *string `json:"typeHasPrefix,omitempty"` + TypeHasSuffix *string `json:"typeHasSuffix,omitempty"` + TypeEqualFold *string `json:"typeEqualFold,omitempty"` + TypeContainsFold *string `json:"typeContainsFold,omitempty"` + + // "value" field predicates. + Value *string `json:"value,omitempty"` + ValueNEQ *string `json:"valueNEQ,omitempty"` + ValueIn []string `json:"valueIn,omitempty"` + ValueNotIn []string `json:"valueNotIn,omitempty"` + ValueGT *string `json:"valueGT,omitempty"` + ValueGTE *string `json:"valueGTE,omitempty"` + ValueLT *string `json:"valueLT,omitempty"` + ValueLTE *string `json:"valueLTE,omitempty"` + ValueContains *string `json:"valueContains,omitempty"` + ValueHasPrefix *string `json:"valueHasPrefix,omitempty"` + ValueHasSuffix *string `json:"valueHasSuffix,omitempty"` + ValueEqualFold *string `json:"valueEqualFold,omitempty"` + ValueContainsFold *string `json:"valueContainsFold,omitempty"` + + // "book" edge predicates. + HasBook *bool `json:"hasBook,omitempty"` + HasBookWith []*BookWhereInput `json:"hasBookWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *IdentifierWhereInput) AddPredicates(predicates ...predicate.Identifier) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the IdentifierWhereInput filter on the IdentifierQuery builder. +func (i *IdentifierWhereInput) Filter(q *IdentifierQuery) (*IdentifierQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyIdentifierWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyIdentifierWhereInput is returned in case the IdentifierWhereInput is empty. +var ErrEmptyIdentifierWhereInput = errors.New("ent: empty predicate IdentifierWhereInput") + +// P returns a predicate for filtering identifiers. +// An error is returned if the input is empty or invalid. +func (i *IdentifierWhereInput) P() (predicate.Identifier, error) { + var predicates []predicate.Identifier + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, identifier.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.Identifier, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, identifier.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.Identifier, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, identifier.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, identifier.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, identifier.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, identifier.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, identifier.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, identifier.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, identifier.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, identifier.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, identifier.IDLTE(*i.IDLTE)) + } + if i.CreateTime != nil { + predicates = append(predicates, identifier.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, identifier.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, identifier.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, identifier.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, identifier.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, identifier.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, identifier.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, identifier.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, identifier.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, identifier.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, identifier.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, identifier.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, identifier.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, identifier.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, identifier.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, identifier.UpdateTimeLTE(*i.UpdateTimeLTE)) + } + if i.CalibreID != nil { + predicates = append(predicates, identifier.CalibreIDEQ(*i.CalibreID)) + } + if i.CalibreIDNEQ != nil { + predicates = append(predicates, identifier.CalibreIDNEQ(*i.CalibreIDNEQ)) + } + if len(i.CalibreIDIn) > 0 { + predicates = append(predicates, identifier.CalibreIDIn(i.CalibreIDIn...)) + } + if len(i.CalibreIDNotIn) > 0 { + predicates = append(predicates, identifier.CalibreIDNotIn(i.CalibreIDNotIn...)) + } + if i.CalibreIDGT != nil { + predicates = append(predicates, identifier.CalibreIDGT(*i.CalibreIDGT)) + } + if i.CalibreIDGTE != nil { + predicates = append(predicates, identifier.CalibreIDGTE(*i.CalibreIDGTE)) + } + if i.CalibreIDLT != nil { + predicates = append(predicates, identifier.CalibreIDLT(*i.CalibreIDLT)) + } + if i.CalibreIDLTE != nil { + predicates = append(predicates, identifier.CalibreIDLTE(*i.CalibreIDLTE)) + } + if i.CalibreIDIsNil { + predicates = append(predicates, identifier.CalibreIDIsNil()) } if i.CalibreIDNotNil { predicates = append(predicates, identifier.CalibreIDNotNil()) @@ -1383,6 +1984,26 @@ type LanguageWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "calibre_id" field predicates. CalibreID *int64 `json:"calibreID,omitempty"` CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` @@ -1510,6 +2131,54 @@ func (i *LanguageWhereInput) P() (predicate.Language, error) { if i.IDLTE != nil { predicates = append(predicates, language.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, language.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, language.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, language.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, language.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, language.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, language.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, language.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, language.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, language.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, language.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, language.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, language.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, language.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, language.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, language.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, language.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.CalibreID != nil { predicates = append(predicates, language.CalibreIDEQ(*i.CalibreID)) } @@ -1625,6 +2294,26 @@ type PublisherWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "calibre_id" field predicates. CalibreID *int64 `json:"calibreID,omitempty"` CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` @@ -1727,30 +2416,78 @@ func (i *PublisherWhereInput) P() (predicate.Publisher, error) { } predicates = append(predicates, publisher.And(and...)) } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, publisher.IDEQ(*i.ID)) + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, publisher.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, publisher.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, publisher.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, publisher.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, publisher.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, publisher.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, publisher.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, publisher.IDLTE(*i.IDLTE)) + } + if i.CreateTime != nil { + predicates = append(predicates, publisher.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, publisher.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, publisher.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, publisher.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, publisher.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, publisher.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, publisher.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, publisher.CreateTimeLTE(*i.CreateTimeLTE)) } - if i.IDNEQ != nil { - predicates = append(predicates, publisher.IDNEQ(*i.IDNEQ)) + if i.UpdateTime != nil { + predicates = append(predicates, publisher.UpdateTimeEQ(*i.UpdateTime)) } - if len(i.IDIn) > 0 { - predicates = append(predicates, publisher.IDIn(i.IDIn...)) + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, publisher.UpdateTimeNEQ(*i.UpdateTimeNEQ)) } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, publisher.IDNotIn(i.IDNotIn...)) + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, publisher.UpdateTimeIn(i.UpdateTimeIn...)) } - if i.IDGT != nil { - predicates = append(predicates, publisher.IDGT(*i.IDGT)) + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, publisher.UpdateTimeNotIn(i.UpdateTimeNotIn...)) } - if i.IDGTE != nil { - predicates = append(predicates, publisher.IDGTE(*i.IDGTE)) + if i.UpdateTimeGT != nil { + predicates = append(predicates, publisher.UpdateTimeGT(*i.UpdateTimeGT)) } - if i.IDLT != nil { - predicates = append(predicates, publisher.IDLT(*i.IDLT)) + if i.UpdateTimeGTE != nil { + predicates = append(predicates, publisher.UpdateTimeGTE(*i.UpdateTimeGTE)) } - if i.IDLTE != nil { - predicates = append(predicates, publisher.IDLTE(*i.IDLTE)) + if i.UpdateTimeLT != nil { + predicates = append(predicates, publisher.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, publisher.UpdateTimeLTE(*i.UpdateTimeLTE)) } if i.CalibreID != nil { predicates = append(predicates, publisher.CalibreIDEQ(*i.CalibreID)) @@ -1867,6 +2604,26 @@ type SeriesWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "calibre_id" field predicates. CalibreID *int64 `json:"calibreID,omitempty"` CalibreIDNEQ *int64 `json:"calibreIDNEQ,omitempty"` @@ -2009,6 +2766,54 @@ func (i *SeriesWhereInput) P() (predicate.Series, error) { if i.IDLTE != nil { predicates = append(predicates, series.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, series.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, series.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, series.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, series.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, series.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, series.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, series.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, series.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, series.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, series.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, series.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, series.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, series.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, series.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, series.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, series.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.CalibreID != nil { predicates = append(predicates, series.CalibreIDEQ(*i.CalibreID)) } @@ -2163,6 +2968,26 @@ type ShelfWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "public" field predicates. Public *bool `json:"public,omitempty"` PublicNEQ *bool `json:"publicNEQ,omitempty"` @@ -2318,6 +3143,54 @@ func (i *ShelfWhereInput) P() (predicate.Shelf, error) { if i.IDLTE != nil { predicates = append(predicates, shelf.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, shelf.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, shelf.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, shelf.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, shelf.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, shelf.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, shelf.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, shelf.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, shelf.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, shelf.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, shelf.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, shelf.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, shelf.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, shelf.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, shelf.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, shelf.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, shelf.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.Public != nil { predicates = append(predicates, shelf.PublicEQ(*i.Public)) } @@ -3233,6 +4106,26 @@ type UserWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "username" field predicates. Username *string `json:"username,omitempty"` UsernameNEQ *string `json:"usernameNEQ,omitempty"` @@ -3384,6 +4277,54 @@ func (i *UserWhereInput) P() (predicate.User, error) { if i.IDLTE != nil { predicates = append(predicates, user.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, user.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, user.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, user.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, user.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, user.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, user.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, user.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, user.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, user.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, user.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, user.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, user.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, user.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, user.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, user.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, user.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.Username != nil { predicates = append(predicates, user.UsernameEQ(*i.Username)) } @@ -3571,6 +4512,26 @@ type UserPermissionsWhereInput struct { IDLT *ksuid.ID `json:"idLT,omitempty"` IDLTE *ksuid.ID `json:"idLTE,omitempty"` + // "create_time" field predicates. + CreateTime *time.Time `json:"createTime,omitempty"` + CreateTimeNEQ *time.Time `json:"createTimeNEQ,omitempty"` + CreateTimeIn []time.Time `json:"createTimeIn,omitempty"` + CreateTimeNotIn []time.Time `json:"createTimeNotIn,omitempty"` + CreateTimeGT *time.Time `json:"createTimeGT,omitempty"` + CreateTimeGTE *time.Time `json:"createTimeGTE,omitempty"` + CreateTimeLT *time.Time `json:"createTimeLT,omitempty"` + CreateTimeLTE *time.Time `json:"createTimeLTE,omitempty"` + + // "update_time" field predicates. + UpdateTime *time.Time `json:"updateTime,omitempty"` + UpdateTimeNEQ *time.Time `json:"updateTimeNEQ,omitempty"` + UpdateTimeIn []time.Time `json:"updateTimeIn,omitempty"` + UpdateTimeNotIn []time.Time `json:"updateTimeNotIn,omitempty"` + UpdateTimeGT *time.Time `json:"updateTimeGT,omitempty"` + UpdateTimeGTE *time.Time `json:"updateTimeGTE,omitempty"` + UpdateTimeLT *time.Time `json:"updateTimeLT,omitempty"` + UpdateTimeLTE *time.Time `json:"updateTimeLTE,omitempty"` + // "user_id" field predicates. UserID *ksuid.ID `json:"userID,omitempty"` UserIDNEQ *ksuid.ID `json:"userIDNEQ,omitempty"` @@ -3588,10 +4549,6 @@ type UserPermissionsWhereInput struct { UserIDEqualFold *ksuid.ID `json:"userIDEqualFold,omitempty"` UserIDContainsFold *ksuid.ID `json:"userIDContainsFold,omitempty"` - // "CanEdit" field predicates. - CanEdit *bool `json:"canedit,omitempty"` - CanEditNEQ *bool `json:"caneditNEQ,omitempty"` - // "Admin" field predicates. Admin *bool `json:"admin,omitempty"` AdminNEQ *bool `json:"adminNEQ,omitempty"` @@ -3600,6 +4557,10 @@ type UserPermissionsWhereInput struct { CanCreatePublic *bool `json:"cancreatepublic,omitempty"` CanCreatePublicNEQ *bool `json:"cancreatepublicNEQ,omitempty"` + // "CanEdit" field predicates. + CanEdit *bool `json:"canedit,omitempty"` + CanEditNEQ *bool `json:"caneditNEQ,omitempty"` + // "user" edge predicates. HasUser *bool `json:"hasUser,omitempty"` HasUserWith []*UserWhereInput `json:"hasUserWith,omitempty"` @@ -3700,6 +4661,54 @@ func (i *UserPermissionsWhereInput) P() (predicate.UserPermissions, error) { if i.IDLTE != nil { predicates = append(predicates, userpermissions.IDLTE(*i.IDLTE)) } + if i.CreateTime != nil { + predicates = append(predicates, userpermissions.CreateTimeEQ(*i.CreateTime)) + } + if i.CreateTimeNEQ != nil { + predicates = append(predicates, userpermissions.CreateTimeNEQ(*i.CreateTimeNEQ)) + } + if len(i.CreateTimeIn) > 0 { + predicates = append(predicates, userpermissions.CreateTimeIn(i.CreateTimeIn...)) + } + if len(i.CreateTimeNotIn) > 0 { + predicates = append(predicates, userpermissions.CreateTimeNotIn(i.CreateTimeNotIn...)) + } + if i.CreateTimeGT != nil { + predicates = append(predicates, userpermissions.CreateTimeGT(*i.CreateTimeGT)) + } + if i.CreateTimeGTE != nil { + predicates = append(predicates, userpermissions.CreateTimeGTE(*i.CreateTimeGTE)) + } + if i.CreateTimeLT != nil { + predicates = append(predicates, userpermissions.CreateTimeLT(*i.CreateTimeLT)) + } + if i.CreateTimeLTE != nil { + predicates = append(predicates, userpermissions.CreateTimeLTE(*i.CreateTimeLTE)) + } + if i.UpdateTime != nil { + predicates = append(predicates, userpermissions.UpdateTimeEQ(*i.UpdateTime)) + } + if i.UpdateTimeNEQ != nil { + predicates = append(predicates, userpermissions.UpdateTimeNEQ(*i.UpdateTimeNEQ)) + } + if len(i.UpdateTimeIn) > 0 { + predicates = append(predicates, userpermissions.UpdateTimeIn(i.UpdateTimeIn...)) + } + if len(i.UpdateTimeNotIn) > 0 { + predicates = append(predicates, userpermissions.UpdateTimeNotIn(i.UpdateTimeNotIn...)) + } + if i.UpdateTimeGT != nil { + predicates = append(predicates, userpermissions.UpdateTimeGT(*i.UpdateTimeGT)) + } + if i.UpdateTimeGTE != nil { + predicates = append(predicates, userpermissions.UpdateTimeGTE(*i.UpdateTimeGTE)) + } + if i.UpdateTimeLT != nil { + predicates = append(predicates, userpermissions.UpdateTimeLT(*i.UpdateTimeLT)) + } + if i.UpdateTimeLTE != nil { + predicates = append(predicates, userpermissions.UpdateTimeLTE(*i.UpdateTimeLTE)) + } if i.UserID != nil { predicates = append(predicates, userpermissions.UserIDEQ(*i.UserID)) } @@ -3745,12 +4754,6 @@ func (i *UserPermissionsWhereInput) P() (predicate.UserPermissions, error) { if i.UserIDContainsFold != nil { predicates = append(predicates, userpermissions.UserIDContainsFold(*i.UserIDContainsFold)) } - if i.CanEdit != nil { - predicates = append(predicates, userpermissions.CanEditEQ(*i.CanEdit)) - } - if i.CanEditNEQ != nil { - predicates = append(predicates, userpermissions.CanEditNEQ(*i.CanEditNEQ)) - } if i.Admin != nil { predicates = append(predicates, userpermissions.AdminEQ(*i.Admin)) } @@ -3763,6 +4766,12 @@ func (i *UserPermissionsWhereInput) P() (predicate.UserPermissions, error) { if i.CanCreatePublicNEQ != nil { predicates = append(predicates, userpermissions.CanCreatePublicNEQ(*i.CanCreatePublicNEQ)) } + if i.CanEdit != nil { + predicates = append(predicates, userpermissions.CanEditEQ(*i.CanEdit)) + } + if i.CanEditNEQ != nil { + predicates = append(predicates, userpermissions.CanEditNEQ(*i.CanEditNEQ)) + } if i.HasUser != nil { p := userpermissions.HasUser() diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go index c83c85e5..caf286f4 100644 --- a/internal/ent/hook/hook.go +++ b/internal/ent/hook/hook.go @@ -32,6 +32,18 @@ func (f BookFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BookMutation", m) } +// The BookFileFunc type is an adapter to allow the use of ordinary +// function as BookFile mutator. +type BookFileFunc func(context.Context, *ent.BookFileMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BookFileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BookFileMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BookFileMutation", m) +} + // The IdentifierFunc type is an adapter to allow the use of ordinary // function as Identifier mutator. type IdentifierFunc func(context.Context, *ent.IdentifierMutation) (ent.Value, error) diff --git a/internal/ent/identifier.go b/internal/ent/identifier.go index a821a9a8..55084271 100644 --- a/internal/ent/identifier.go +++ b/internal/ent/identifier.go @@ -8,6 +8,7 @@ import ( "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/schema/ksuid" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -18,6 +19,10 @@ type Identifier struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Type holds the value of the "type" field. @@ -64,6 +69,8 @@ func (*Identifier) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case identifier.FieldID, identifier.FieldType, identifier.FieldValue: values[i] = new(sql.NullString) + case identifier.FieldCreateTime, identifier.FieldUpdateTime: + values[i] = new(sql.NullTime) case identifier.ForeignKeys[0]: // identifier_book values[i] = new(sql.NullString) default: @@ -87,6 +94,18 @@ func (i *Identifier) assignValues(columns []string, values []any) error { } else if value.Valid { i.ID = ksuid.ID(value.String) } + case identifier.FieldCreateTime: + if value, ok := values[j].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[j]) + } else if value.Valid { + i.CreateTime = value.Time + } + case identifier.FieldUpdateTime: + if value, ok := values[j].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[j]) + } else if value.Valid { + i.UpdateTime = value.Time + } case identifier.FieldCalibreID: if value, ok := values[j].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[j]) @@ -153,6 +172,12 @@ func (i *Identifier) String() string { var builder strings.Builder builder.WriteString("Identifier(") builder.WriteString(fmt.Sprintf("id=%v, ", i.ID)) + builder.WriteString("create_time=") + builder.WriteString(i.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(i.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", i.CalibreID)) builder.WriteString(", ") diff --git a/internal/ent/identifier/identifier.go b/internal/ent/identifier/identifier.go index 31433346..22eb50ce 100644 --- a/internal/ent/identifier/identifier.go +++ b/internal/ent/identifier/identifier.go @@ -4,6 +4,7 @@ package identifier import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "identifier" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldType holds the string denoting the type field in the database. @@ -37,6 +42,8 @@ const ( // Columns holds all SQL columns for identifier fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldType, FieldValue, @@ -71,6 +78,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // TypeValidator is a validator for the "type" field. It is called by the builders before save. TypeValidator func(string) error // ValueValidator is a validator for the "value" field. It is called by the builders before save. @@ -87,6 +100,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() diff --git a/internal/ent/identifier/where.go b/internal/ent/identifier/where.go index f00dcf83..f32438c9 100644 --- a/internal/ent/identifier/where.go +++ b/internal/ent/identifier/where.go @@ -5,6 +5,7 @@ package identifier import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Identifier { return predicate.Identifier(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Identifier { return predicate.Identifier(sql.FieldEQ(FieldCalibreID, v)) @@ -70,6 +81,86 @@ func Value(v string) predicate.Identifier { return predicate.Identifier(sql.FieldEQ(FieldValue, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Identifier { + return predicate.Identifier(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Identifier { return predicate.Identifier(sql.FieldEQ(FieldCalibreID, v)) diff --git a/internal/ent/identifier_create.go b/internal/ent/identifier_create.go index 147fb46e..ed98a683 100644 --- a/internal/ent/identifier_create.go +++ b/internal/ent/identifier_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/book" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,6 +25,34 @@ type IdentifierCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (ic *IdentifierCreate) SetCreateTime(t time.Time) *IdentifierCreate { + ic.mutation.SetCreateTime(t) + return ic +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (ic *IdentifierCreate) SetNillableCreateTime(t *time.Time) *IdentifierCreate { + if t != nil { + ic.SetCreateTime(*t) + } + return ic +} + +// SetUpdateTime sets the "update_time" field. +func (ic *IdentifierCreate) SetUpdateTime(t time.Time) *IdentifierCreate { + ic.mutation.SetUpdateTime(t) + return ic +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (ic *IdentifierCreate) SetNillableUpdateTime(t *time.Time) *IdentifierCreate { + if t != nil { + ic.SetUpdateTime(*t) + } + return ic +} + // SetCalibreID sets the "calibre_id" field. func (ic *IdentifierCreate) SetCalibreID(i int64) *IdentifierCreate { ic.mutation.SetCalibreID(i) @@ -112,6 +141,20 @@ func (ic *IdentifierCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (ic *IdentifierCreate) defaults() error { + if _, ok := ic.mutation.CreateTime(); !ok { + if identifier.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized identifier.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := identifier.DefaultCreateTime() + ic.mutation.SetCreateTime(v) + } + if _, ok := ic.mutation.UpdateTime(); !ok { + if identifier.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized identifier.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := identifier.DefaultUpdateTime() + ic.mutation.SetUpdateTime(v) + } if _, ok := ic.mutation.ID(); !ok { if identifier.DefaultID == nil { return fmt.Errorf("ent: uninitialized identifier.DefaultID (forgotten import ent/runtime?)") @@ -124,6 +167,12 @@ func (ic *IdentifierCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (ic *IdentifierCreate) check() error { + if _, ok := ic.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Identifier.create_time"`)} + } + if _, ok := ic.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Identifier.update_time"`)} + } if _, ok := ic.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Identifier.type"`)} } @@ -179,6 +228,14 @@ func (ic *IdentifierCreate) createSpec() (*Identifier, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := ic.mutation.CreateTime(); ok { + _spec.SetField(identifier.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := ic.mutation.UpdateTime(); ok { + _spec.SetField(identifier.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := ic.mutation.CalibreID(); ok { _spec.SetField(identifier.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -215,7 +272,7 @@ func (ic *IdentifierCreate) createSpec() (*Identifier, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Identifier.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -224,7 +281,7 @@ func (ic *IdentifierCreate) createSpec() (*Identifier, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.IdentifierUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (ic *IdentifierCreate) OnConflict(opts ...sql.ConflictOption) *IdentifierUpsertOne { @@ -260,6 +317,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *IdentifierUpsert) SetUpdateTime(v time.Time) *IdentifierUpsert { + u.Set(identifier.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *IdentifierUpsert) UpdateUpdateTime() *IdentifierUpsert { + u.SetExcluded(identifier.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *IdentifierUpsert) SetCalibreID(v int64) *IdentifierUpsert { u.Set(identifier.FieldCalibreID, v) @@ -325,6 +394,9 @@ func (u *IdentifierUpsertOne) UpdateNewValues() *IdentifierUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(identifier.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(identifier.FieldCreateTime) + } })) return u } @@ -356,6 +428,20 @@ func (u *IdentifierUpsertOne) Update(set func(*IdentifierUpsert)) *IdentifierUps return u } +// SetUpdateTime sets the "update_time" field. +func (u *IdentifierUpsertOne) SetUpdateTime(v time.Time) *IdentifierUpsertOne { + return u.Update(func(s *IdentifierUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *IdentifierUpsertOne) UpdateUpdateTime() *IdentifierUpsertOne { + return u.Update(func(s *IdentifierUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *IdentifierUpsertOne) SetCalibreID(v int64) *IdentifierUpsertOne { return u.Update(func(s *IdentifierUpsert) { @@ -548,7 +634,7 @@ func (icb *IdentifierCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.IdentifierUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (icb *IdentifierCreateBulk) OnConflict(opts ...sql.ConflictOption) *IdentifierUpsertBulk { @@ -595,6 +681,9 @@ func (u *IdentifierUpsertBulk) UpdateNewValues() *IdentifierUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(identifier.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(identifier.FieldCreateTime) + } } })) return u @@ -627,6 +716,20 @@ func (u *IdentifierUpsertBulk) Update(set func(*IdentifierUpsert)) *IdentifierUp return u } +// SetUpdateTime sets the "update_time" field. +func (u *IdentifierUpsertBulk) SetUpdateTime(v time.Time) *IdentifierUpsertBulk { + return u.Update(func(s *IdentifierUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *IdentifierUpsertBulk) UpdateUpdateTime() *IdentifierUpsertBulk { + return u.Update(func(s *IdentifierUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *IdentifierUpsertBulk) SetCalibreID(v int64) *IdentifierUpsertBulk { return u.Update(func(s *IdentifierUpsert) { diff --git a/internal/ent/identifier_query.go b/internal/ent/identifier_query.go index 1dfcae32..3bb20729 100644 --- a/internal/ent/identifier_query.go +++ b/internal/ent/identifier_query.go @@ -302,12 +302,12 @@ func (iq *IdentifierQuery) WithBook(opts ...func(*BookQuery)) *IdentifierQuery { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Identifier.Query(). -// GroupBy(identifier.FieldCalibreID). +// GroupBy(identifier.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (iq *IdentifierQuery) GroupBy(field string, fields ...string) *IdentifierGroupBy { @@ -325,11 +325,11 @@ func (iq *IdentifierQuery) GroupBy(field string, fields ...string) *IdentifierGr // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Identifier.Query(). -// Select(identifier.FieldCalibreID). +// Select(identifier.FieldCreateTime). // Scan(ctx, &v) func (iq *IdentifierQuery) Select(fields ...string) *IdentifierSelect { iq.ctx.Fields = append(iq.ctx.Fields, fields...) diff --git a/internal/ent/identifier_update.go b/internal/ent/identifier_update.go index 4482acb8..43c31781 100644 --- a/internal/ent/identifier_update.go +++ b/internal/ent/identifier_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (iu *IdentifierUpdate) Where(ps ...predicate.Identifier) *IdentifierUpdate return iu } +// SetUpdateTime sets the "update_time" field. +func (iu *IdentifierUpdate) SetUpdateTime(t time.Time) *IdentifierUpdate { + iu.mutation.SetUpdateTime(t) + return iu +} + // SetCalibreID sets the "calibre_id" field. func (iu *IdentifierUpdate) SetCalibreID(i int64) *IdentifierUpdate { iu.mutation.ResetCalibreID() @@ -108,6 +115,9 @@ func (iu *IdentifierUpdate) ClearBook() *IdentifierUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (iu *IdentifierUpdate) Save(ctx context.Context) (int, error) { + if err := iu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, iu.sqlSave, iu.mutation, iu.hooks) } @@ -133,6 +143,18 @@ func (iu *IdentifierUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (iu *IdentifierUpdate) defaults() error { + if _, ok := iu.mutation.UpdateTime(); !ok { + if identifier.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized identifier.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := identifier.UpdateDefaultUpdateTime() + iu.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (iu *IdentifierUpdate) check() error { if v, ok := iu.mutation.GetType(); ok { @@ -163,6 +185,9 @@ func (iu *IdentifierUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := iu.mutation.UpdateTime(); ok { + _spec.SetField(identifier.FieldUpdateTime, field.TypeTime, value) + } if value, ok := iu.mutation.CalibreID(); ok { _spec.SetField(identifier.FieldCalibreID, field.TypeInt64, value) } @@ -227,6 +252,12 @@ type IdentifierUpdateOne struct { mutation *IdentifierMutation } +// SetUpdateTime sets the "update_time" field. +func (iuo *IdentifierUpdateOne) SetUpdateTime(t time.Time) *IdentifierUpdateOne { + iuo.mutation.SetUpdateTime(t) + return iuo +} + // SetCalibreID sets the "calibre_id" field. func (iuo *IdentifierUpdateOne) SetCalibreID(i int64) *IdentifierUpdateOne { iuo.mutation.ResetCalibreID() @@ -319,6 +350,9 @@ func (iuo *IdentifierUpdateOne) Select(field string, fields ...string) *Identifi // Save executes the query and returns the updated Identifier entity. func (iuo *IdentifierUpdateOne) Save(ctx context.Context) (*Identifier, error) { + if err := iuo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, iuo.sqlSave, iuo.mutation, iuo.hooks) } @@ -344,6 +378,18 @@ func (iuo *IdentifierUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (iuo *IdentifierUpdateOne) defaults() error { + if _, ok := iuo.mutation.UpdateTime(); !ok { + if identifier.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized identifier.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := identifier.UpdateDefaultUpdateTime() + iuo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (iuo *IdentifierUpdateOne) check() error { if v, ok := iuo.mutation.GetType(); ok { @@ -391,6 +437,9 @@ func (iuo *IdentifierUpdateOne) sqlSave(ctx context.Context) (_node *Identifier, } } } + if value, ok := iuo.mutation.UpdateTime(); ok { + _spec.SetField(identifier.FieldUpdateTime, field.TypeTime, value) + } if value, ok := iuo.mutation.CalibreID(); ok { _spec.SetField(identifier.FieldCalibreID, field.TypeInt64, value) } diff --git a/internal/ent/internal/schema.go b/internal/ent/internal/schema.go index 8e76a09c..7d1aa7ea 100644 --- a/internal/ent/internal/schema.go +++ b/internal/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = `{"Schema":"lybbrio/internal/ent/schema","Package":"lybbrio/internal/ent","Schemas":[{"name":"Author","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"unique":true,"fields":["name"]},{"unique":true,"fields":["sort"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"atr"}}},{"name":"Book","config":{"Table":""},"edges":[{"name":"authors","type":"Author","ref_name":"books","inverse":true},{"name":"publisher","type":"Publisher","ref_name":"books","inverse":true},{"name":"series","type":"Series","ref_name":"books","inverse":true},{"name":"identifiers","type":"Identifier","ref_name":"book","inverse":true},{"name":"tags","type":"Tag","ref_name":"books","inverse":true},{"name":"language","type":"Language","ref_name":"books","inverse":true},{"name":"shelf","type":"Shelf","ref_name":"books","inverse":true}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"title","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TITLE"}}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"published_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":2,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"PUB_DATE"}}},{"name":"path","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"isbn","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"optional":true,"position":{"Index":4,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"ISBN"}}},{"name":"description","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"optional":true,"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"series_index","type":{"Type":20,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["title"]},{"fields":["sort"]},{"fields":["published_date"]},{"fields":["isbn"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"bok"}}},{"name":"Identifier","config":{"Table":""},"edges":[{"name":"book","type":"Book","unique":true,"required":true}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"type","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TYPE"}}},{"name":"value","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"VALUE"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["type","value"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"idn"}}},{"name":"Language","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"code","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["code"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"lng"}}},{"name":"Publisher","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"pub"}}},{"name":"Series","config":{"Table":""},"edges":[{"name":"books","type":"Book"}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"srs"}}},{"name":"Shelf","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","unique":true,"required":true,"immutable":true},{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"public","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"immutable":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"description","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"shf"}}},{"name":"Tag","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"tag"}}},{"name":"Task","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","unique":true,"immutable":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"type","type":{"Type":6,"Ident":"task_enums.TaskType","PkgPath":"lybbrio/internal/ent/schema/task_enums","PkgName":"task_enums","Nillable":false,"RType":{"Name":"TaskType","Ident":"task_enums.TaskType","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/task_enums","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Values":{"In":[],"Out":[{"Name":"","Ident":"[]string","Kind":23,"PkgPath":"","Methods":null}]}}}},"enums":[{"N":"noop","V":"noop"},{"N":"calibre_import","V":"calibre_import"}],"default":true,"default_value":"noop","default_kind":24,"immutable":true,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TYPE"}}},{"name":"status","type":{"Type":6,"Ident":"task_enums.Status","PkgPath":"lybbrio/internal/ent/schema/task_enums","PkgName":"task_enums","Nillable":false,"RType":{"Name":"Status","Ident":"task_enums.Status","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/task_enums","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Values":{"In":[],"Out":[{"Name":"","Ident":"[]string","Kind":23,"PkgPath":"","Methods":null}]}}}},"enums":[{"N":"pending","V":"pending"},{"N":"in_progress","V":"in_progress"},{"N":"success","V":"success"},{"N":"failure","V":"failure"}],"default":true,"default_value":"pending","default_kind":24,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"STATUS"}}},{"name":"progress","type":{"Type":20,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":0,"default_kind":14,"position":{"Index":2,"MixedIn":false,"MixinIndex":0},"comment":"Progress of the task. 0-1"},{"name":"message","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"MixedIn":false,"MixinIndex":0},"comment":"Message of the task"},{"name":"error","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":4,"MixedIn":false,"MixinIndex":0},"comment":"Error message of the task"},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"optional":true,"immutable":true,"position":{"Index":5,"MixedIn":false,"MixinIndex":0},"comment":"The user who created this task. Empty for System Task"},{"name":"is_system_task","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0},"comment":"Whether this task is created by the system"}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"tsk"}}},{"name":"User","config":{"Table":""},"edges":[{"name":"shelves","type":"Shelf","ref_name":"user","inverse":true},{"name":"user_permissions","type":"UserPermissions","unique":true,"required":true,"immutable":true}],"fields":[{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"username","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"USERNAME"}}},{"name":"password_hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"sensitive":true},{"name":"email","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["username"]},{"fields":["password_hash"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MutationInputs":[{},{"IsCreate":true}],"QueryField":{}},"KSUID":{"Prefix":"usr"}}},{"name":"UserPermissions","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","ref_name":"user_permissions","unique":true,"inverse":true}],"fields":[{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"optional":true,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"CanEdit","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"Admin","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"CanCreatePublic","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":3,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"KSUID":{"Prefix":"prm"}}}],"Features":["entql","privacy","schema/snapshot","sql/upsert","namedges"]}` +const Schema = `{"Schema":"lybbrio/internal/ent/schema","Package":"lybbrio/internal/ent","Schemas":[{"name":"Author","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"link","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"unique":true,"fields":["name"]},{"unique":true,"fields":["sort"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"atr"}}},{"name":"Book","config":{"Table":""},"edges":[{"name":"authors","type":"Author","ref_name":"books","inverse":true},{"name":"publisher","type":"Publisher","ref_name":"books","inverse":true},{"name":"series","type":"Series","ref_name":"books","inverse":true},{"name":"identifiers","type":"Identifier","ref_name":"book","inverse":true},{"name":"tags","type":"Tag","ref_name":"books","inverse":true},{"name":"language","type":"Language","ref_name":"books","inverse":true},{"name":"shelf","type":"Shelf","ref_name":"books","inverse":true},{"name":"files","type":"BookFile","ref_name":"book","inverse":true,"annotations":{"EntGQL":{"OrderField":"FILES_COUNT"}}}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"title","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TITLE"}}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"published_date","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":2,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"PUB_DATE"}}},{"name":"path","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":3,"MixedIn":false,"MixinIndex":0}},{"name":"isbn","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"optional":true,"position":{"Index":4,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"ISBN"}}},{"name":"description","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"optional":true,"position":{"Index":5,"MixedIn":false,"MixinIndex":0}},{"name":"series_index","type":{"Type":20,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":6,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["title"]},{"fields":["sort"]},{"fields":["published_date"]},{"fields":["isbn"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"bok"}}},{"name":"BookFile","config":{"Table":""},"edges":[{"name":"book","type":"Book","unique":true,"required":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"path","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"size":2147483647,"validators":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"size","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0},"comment":"Size in bytes"},{"name":"format","type":{"Type":6,"Ident":"bookfile.Format","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"enums":[{"N":"AZW3","V":"AZW3"},{"N":"EPUB","V":"EPUB"},{"N":"KEPUB","V":"KEPUB"},{"N":"PDF","V":"PDF"},{"N":"CBC","V":"CBC"},{"N":"CBR","V":"CBR"},{"N":"CB7","V":"CB7"},{"N":"CBZ","V":"CBZ"},{"N":"CBT","V":"CBT"}],"position":{"Index":3,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"QueryField":{}},"KSUID":{"Prefix":"fil"}}},{"name":"Identifier","config":{"Table":""},"edges":[{"name":"book","type":"Book","unique":true,"required":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"type","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TYPE"}}},{"name":"value","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"VALUE"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["type","value"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"idn"}}},{"name":"Language","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"code","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["code"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"lng"}}},{"name":"Publisher","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"pub"}}},{"name":"Series","config":{"Table":""},"edges":[{"name":"books","type":"Book"}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"sort","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"srs"}}},{"name":"Shelf","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","unique":true,"required":true,"immutable":true},{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"public","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"immutable":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":2}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":3}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}},{"name":"description","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":true,"MixinIndex":2},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"shf"}}},{"name":"Tag","config":{"Table":""},"edges":[{"name":"books","type":"Book","annotations":{"EntGQL":{"OrderField":"BOOKS_COUNT","RelayConnection":true}}}],"fields":[{"name":"calibre_id","type":{"Type":13,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"optional":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"NAME"}}}],"indexes":[{"unique":true,"fields":["calibre_id"]},{"fields":["name"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"MutationInputs":[{"IsCreate":true},{}],"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"tag"}}},{"name":"Task","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","unique":true,"immutable":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":1}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":1}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"type","type":{"Type":6,"Ident":"task_enums.TaskType","PkgPath":"lybbrio/internal/ent/schema/task_enums","PkgName":"task_enums","Nillable":false,"RType":{"Name":"TaskType","Ident":"task_enums.TaskType","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/task_enums","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Values":{"In":[],"Out":[{"Name":"","Ident":"[]string","Kind":23,"PkgPath":"","Methods":null}]}}}},"enums":[{"N":"noop","V":"noop"},{"N":"calibre_import","V":"calibre_import"}],"default":true,"default_value":"noop","default_kind":24,"immutable":true,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"TYPE"}}},{"name":"status","type":{"Type":6,"Ident":"task_enums.Status","PkgPath":"lybbrio/internal/ent/schema/task_enums","PkgName":"task_enums","Nillable":false,"RType":{"Name":"Status","Ident":"task_enums.Status","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/task_enums","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Values":{"In":[],"Out":[{"Name":"","Ident":"[]string","Kind":23,"PkgPath":"","Methods":null}]}}}},"enums":[{"N":"pending","V":"pending"},{"N":"in_progress","V":"in_progress"},{"N":"success","V":"success"},{"N":"failure","V":"failure"}],"default":true,"default_value":"pending","default_kind":24,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"STATUS"}}},{"name":"progress","type":{"Type":20,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":0,"default_kind":14,"position":{"Index":2,"MixedIn":false,"MixinIndex":0},"comment":"Progress of the task. 0-1"},{"name":"message","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":3,"MixedIn":false,"MixinIndex":0},"comment":"Message of the task"},{"name":"error","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":4,"MixedIn":false,"MixinIndex":0},"comment":"Error message of the task"},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"optional":true,"immutable":true,"position":{"Index":5,"MixedIn":false,"MixinIndex":0},"comment":"The user who created this task. Empty for System Task"},{"name":"is_system_task","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":6,"MixedIn":false,"MixinIndex":0},"comment":"Whether this task is created by the system"}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MultiOrder":true,"QueryField":{},"RelayConnection":true},"KSUID":{"Prefix":"tsk"}}},{"name":"User","config":{"Table":""},"edges":[{"name":"shelves","type":"Shelf","ref_name":"user","inverse":true},{"name":"user_permissions","type":"UserPermissions","unique":true,"required":true,"immutable":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"username","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0},"annotations":{"EntGQL":{"OrderField":"USERNAME"}}},{"name":"password_hash","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"optional":true,"position":{"Index":1,"MixedIn":false,"MixinIndex":0},"sensitive":true},{"name":"email","type":{"Type":7,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"unique":true,"validators":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}}],"indexes":[{"fields":["username"]},{"fields":["password_hash"]}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"EntGQL":{"MutationInputs":[{},{"IsCreate":true}],"QueryField":{}},"KSUID":{"Prefix":"usr"}}},{"name":"UserPermissions","config":{"Table":""},"edges":[{"name":"user","type":"User","field":"user_id","ref_name":"user_permissions","unique":true,"inverse":true}],"fields":[{"name":"create_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"immutable":true,"position":{"Index":0,"MixedIn":true,"MixinIndex":0}},{"name":"update_time","type":{"Type":2,"Ident":"","PkgPath":"time","PkgName":"","Nillable":false,"RType":null},"default":true,"default_kind":19,"update_default":true,"position":{"Index":1,"MixedIn":true,"MixinIndex":0}},{"name":"id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"default":true,"default_kind":19,"position":{"Index":0,"MixedIn":true,"MixinIndex":2}},{"name":"user_id","type":{"Type":7,"Ident":"ksuid.ID","PkgPath":"lybbrio/internal/ent/schema/ksuid","PkgName":"ksuid","Nillable":false,"RType":{"Name":"ID","Ident":"ksuid.ID","Kind":24,"PkgPath":"lybbrio/internal/ent/schema/ksuid","Methods":{"MarshalGQL":{"In":[{"Name":"Writer","Ident":"io.Writer","Kind":20,"PkgPath":"io","Methods":null}],"Out":[]},"Scan":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"String":{"In":[],"Out":[{"Name":"string","Ident":"string","Kind":24,"PkgPath":"","Methods":null}]},"UnmarshalGQL":{"In":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null}],"Out":[{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]},"Value":{"In":[],"Out":[{"Name":"","Ident":"interface {}","Kind":20,"PkgPath":"","Methods":null},{"Name":"error","Ident":"error","Kind":20,"PkgPath":"","Methods":null}]}}}},"optional":true,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"Admin","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}},{"name":"CanCreatePublic","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":2,"MixedIn":false,"MixinIndex":0}},{"name":"CanEdit","type":{"Type":1,"Ident":"","PkgPath":"","PkgName":"","Nillable":false,"RType":null},"default":true,"default_value":false,"default_kind":1,"position":{"Index":3,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":false,"MixinIndex":0}],"annotations":{"KSUID":{"Prefix":"prm"}}}],"Features":["entql","privacy","schema/snapshot","sql/upsert","namedges"]}` diff --git a/internal/ent/ksuid.go b/internal/ent/ksuid.go index 4d155a83..6f5c293b 100644 --- a/internal/ent/ksuid.go +++ b/internal/ent/ksuid.go @@ -7,6 +7,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -23,6 +24,7 @@ import ( var prefixMap = map[ksuid.ID]string{ "atr": author.Table, "bok": book.Table, + "fil": bookfile.Table, "idn": identifier.Table, "lng": language.Table, "pub": publisher.Table, diff --git a/internal/ent/language.go b/internal/ent/language.go index bd31d679..884f7f3d 100644 --- a/internal/ent/language.go +++ b/internal/ent/language.go @@ -7,6 +7,7 @@ import ( "lybbrio/internal/ent/language" "lybbrio/internal/ent/schema/ksuid" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -17,6 +18,10 @@ type Language struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Code holds the value of the "code" field. @@ -58,6 +63,8 @@ func (*Language) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case language.FieldID, language.FieldCode: values[i] = new(sql.NullString) + case language.FieldCreateTime, language.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -79,6 +86,18 @@ func (l *Language) assignValues(columns []string, values []any) error { } else if value.Valid { l.ID = ksuid.ID(value.String) } + case language.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + l.CreateTime = value.Time + } + case language.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + l.UpdateTime = value.Time + } case language.FieldCalibreID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[i]) @@ -132,6 +151,12 @@ func (l *Language) String() string { var builder strings.Builder builder.WriteString("Language(") builder.WriteString(fmt.Sprintf("id=%v, ", l.ID)) + builder.WriteString("create_time=") + builder.WriteString(l.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(l.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", l.CalibreID)) builder.WriteString(", ") diff --git a/internal/ent/language/language.go b/internal/ent/language/language.go index fd3abb18..7bbafcbe 100644 --- a/internal/ent/language/language.go +++ b/internal/ent/language/language.go @@ -4,6 +4,7 @@ package language import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "language" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldCode holds the string denoting the code field in the database. @@ -33,6 +38,8 @@ const ( // Columns holds all SQL columns for language fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldCode, } @@ -61,6 +68,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // CodeValidator is a validator for the "code" field. It is called by the builders before save. CodeValidator func(string) error // DefaultID holds the default value on creation for the "id" field. @@ -75,6 +88,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() diff --git a/internal/ent/language/where.go b/internal/ent/language/where.go index f6558f8e..407276dc 100644 --- a/internal/ent/language/where.go +++ b/internal/ent/language/where.go @@ -5,6 +5,7 @@ package language import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Language { return predicate.Language(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Language { + return predicate.Language(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Language { + return predicate.Language(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Language { return predicate.Language(sql.FieldEQ(FieldCalibreID, v)) @@ -65,6 +76,86 @@ func Code(v string) predicate.Language { return predicate.Language(sql.FieldEQ(FieldCode, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Language { + return predicate.Language(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Language { + return predicate.Language(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Language { + return predicate.Language(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Language { + return predicate.Language(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Language { + return predicate.Language(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Language { + return predicate.Language(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Language { + return predicate.Language(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Language { + return predicate.Language(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Language { + return predicate.Language(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Language { + return predicate.Language(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Language { + return predicate.Language(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Language { + return predicate.Language(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Language { + return predicate.Language(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Language { + return predicate.Language(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Language { + return predicate.Language(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Language { + return predicate.Language(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Language { return predicate.Language(sql.FieldEQ(FieldCalibreID, v)) diff --git a/internal/ent/language_create.go b/internal/ent/language_create.go index dda94f73..8197cd3c 100644 --- a/internal/ent/language_create.go +++ b/internal/ent/language_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/book" "lybbrio/internal/ent/language" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,6 +25,34 @@ type LanguageCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (lc *LanguageCreate) SetCreateTime(t time.Time) *LanguageCreate { + lc.mutation.SetCreateTime(t) + return lc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (lc *LanguageCreate) SetNillableCreateTime(t *time.Time) *LanguageCreate { + if t != nil { + lc.SetCreateTime(*t) + } + return lc +} + +// SetUpdateTime sets the "update_time" field. +func (lc *LanguageCreate) SetUpdateTime(t time.Time) *LanguageCreate { + lc.mutation.SetUpdateTime(t) + return lc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (lc *LanguageCreate) SetNillableUpdateTime(t *time.Time) *LanguageCreate { + if t != nil { + lc.SetUpdateTime(*t) + } + return lc +} + // SetCalibreID sets the "calibre_id" field. func (lc *LanguageCreate) SetCalibreID(i int64) *LanguageCreate { lc.mutation.SetCalibreID(i) @@ -110,6 +139,20 @@ func (lc *LanguageCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (lc *LanguageCreate) defaults() error { + if _, ok := lc.mutation.CreateTime(); !ok { + if language.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized language.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := language.DefaultCreateTime() + lc.mutation.SetCreateTime(v) + } + if _, ok := lc.mutation.UpdateTime(); !ok { + if language.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized language.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := language.DefaultUpdateTime() + lc.mutation.SetUpdateTime(v) + } if _, ok := lc.mutation.ID(); !ok { if language.DefaultID == nil { return fmt.Errorf("ent: uninitialized language.DefaultID (forgotten import ent/runtime?)") @@ -122,6 +165,12 @@ func (lc *LanguageCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (lc *LanguageCreate) check() error { + if _, ok := lc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Language.create_time"`)} + } + if _, ok := lc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Language.update_time"`)} + } if _, ok := lc.mutation.Code(); !ok { return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "Language.code"`)} } @@ -166,6 +215,14 @@ func (lc *LanguageCreate) createSpec() (*Language, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := lc.mutation.CreateTime(); ok { + _spec.SetField(language.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := lc.mutation.UpdateTime(); ok { + _spec.SetField(language.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := lc.mutation.CalibreID(); ok { _spec.SetField(language.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -197,7 +254,7 @@ func (lc *LanguageCreate) createSpec() (*Language, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Language.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -206,7 +263,7 @@ func (lc *LanguageCreate) createSpec() (*Language, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.LanguageUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (lc *LanguageCreate) OnConflict(opts ...sql.ConflictOption) *LanguageUpsertOne { @@ -242,6 +299,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *LanguageUpsert) SetUpdateTime(v time.Time) *LanguageUpsert { + u.Set(language.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *LanguageUpsert) UpdateUpdateTime() *LanguageUpsert { + u.SetExcluded(language.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *LanguageUpsert) SetCalibreID(v int64) *LanguageUpsert { u.Set(language.FieldCalibreID, v) @@ -295,6 +364,9 @@ func (u *LanguageUpsertOne) UpdateNewValues() *LanguageUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(language.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(language.FieldCreateTime) + } })) return u } @@ -326,6 +398,20 @@ func (u *LanguageUpsertOne) Update(set func(*LanguageUpsert)) *LanguageUpsertOne return u } +// SetUpdateTime sets the "update_time" field. +func (u *LanguageUpsertOne) SetUpdateTime(v time.Time) *LanguageUpsertOne { + return u.Update(func(s *LanguageUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *LanguageUpsertOne) UpdateUpdateTime() *LanguageUpsertOne { + return u.Update(func(s *LanguageUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *LanguageUpsertOne) SetCalibreID(v int64) *LanguageUpsertOne { return u.Update(func(s *LanguageUpsert) { @@ -504,7 +590,7 @@ func (lcb *LanguageCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.LanguageUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (lcb *LanguageCreateBulk) OnConflict(opts ...sql.ConflictOption) *LanguageUpsertBulk { @@ -551,6 +637,9 @@ func (u *LanguageUpsertBulk) UpdateNewValues() *LanguageUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(language.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(language.FieldCreateTime) + } } })) return u @@ -583,6 +672,20 @@ func (u *LanguageUpsertBulk) Update(set func(*LanguageUpsert)) *LanguageUpsertBu return u } +// SetUpdateTime sets the "update_time" field. +func (u *LanguageUpsertBulk) SetUpdateTime(v time.Time) *LanguageUpsertBulk { + return u.Update(func(s *LanguageUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *LanguageUpsertBulk) UpdateUpdateTime() *LanguageUpsertBulk { + return u.Update(func(s *LanguageUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *LanguageUpsertBulk) SetCalibreID(v int64) *LanguageUpsertBulk { return u.Update(func(s *LanguageUpsert) { diff --git a/internal/ent/language_query.go b/internal/ent/language_query.go index bedde6ab..f7eaadfd 100644 --- a/internal/ent/language_query.go +++ b/internal/ent/language_query.go @@ -303,12 +303,12 @@ func (lq *LanguageQuery) WithBooks(opts ...func(*BookQuery)) *LanguageQuery { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Language.Query(). -// GroupBy(language.FieldCalibreID). +// GroupBy(language.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (lq *LanguageQuery) GroupBy(field string, fields ...string) *LanguageGroupBy { @@ -326,11 +326,11 @@ func (lq *LanguageQuery) GroupBy(field string, fields ...string) *LanguageGroupB // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Language.Query(). -// Select(language.FieldCalibreID). +// Select(language.FieldCreateTime). // Scan(ctx, &v) func (lq *LanguageQuery) Select(fields ...string) *LanguageSelect { lq.ctx.Fields = append(lq.ctx.Fields, fields...) diff --git a/internal/ent/language_update.go b/internal/ent/language_update.go index e0446cec..bb4df8c2 100644 --- a/internal/ent/language_update.go +++ b/internal/ent/language_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (lu *LanguageUpdate) Where(ps ...predicate.Language) *LanguageUpdate { return lu } +// SetUpdateTime sets the "update_time" field. +func (lu *LanguageUpdate) SetUpdateTime(t time.Time) *LanguageUpdate { + lu.mutation.SetUpdateTime(t) + return lu +} + // SetCalibreID sets the "calibre_id" field. func (lu *LanguageUpdate) SetCalibreID(i int64) *LanguageUpdate { lu.mutation.ResetCalibreID() @@ -113,6 +120,9 @@ func (lu *LanguageUpdate) RemoveBooks(b ...*Book) *LanguageUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (lu *LanguageUpdate) Save(ctx context.Context) (int, error) { + if err := lu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, lu.sqlSave, lu.mutation, lu.hooks) } @@ -138,6 +148,18 @@ func (lu *LanguageUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (lu *LanguageUpdate) defaults() error { + if _, ok := lu.mutation.UpdateTime(); !ok { + if language.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized language.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := language.UpdateDefaultUpdateTime() + lu.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (lu *LanguageUpdate) check() error { if v, ok := lu.mutation.Code(); ok { @@ -160,6 +182,9 @@ func (lu *LanguageUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := lu.mutation.UpdateTime(); ok { + _spec.SetField(language.FieldUpdateTime, field.TypeTime, value) + } if value, ok := lu.mutation.CalibreID(); ok { _spec.SetField(language.FieldCalibreID, field.TypeInt64, value) } @@ -237,6 +262,12 @@ type LanguageUpdateOne struct { mutation *LanguageMutation } +// SetUpdateTime sets the "update_time" field. +func (luo *LanguageUpdateOne) SetUpdateTime(t time.Time) *LanguageUpdateOne { + luo.mutation.SetUpdateTime(t) + return luo +} + // SetCalibreID sets the "calibre_id" field. func (luo *LanguageUpdateOne) SetCalibreID(i int64) *LanguageUpdateOne { luo.mutation.ResetCalibreID() @@ -334,6 +365,9 @@ func (luo *LanguageUpdateOne) Select(field string, fields ...string) *LanguageUp // Save executes the query and returns the updated Language entity. func (luo *LanguageUpdateOne) Save(ctx context.Context) (*Language, error) { + if err := luo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, luo.sqlSave, luo.mutation, luo.hooks) } @@ -359,6 +393,18 @@ func (luo *LanguageUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (luo *LanguageUpdateOne) defaults() error { + if _, ok := luo.mutation.UpdateTime(); !ok { + if language.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized language.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := language.UpdateDefaultUpdateTime() + luo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (luo *LanguageUpdateOne) check() error { if v, ok := luo.mutation.Code(); ok { @@ -398,6 +444,9 @@ func (luo *LanguageUpdateOne) sqlSave(ctx context.Context) (_node *Language, err } } } + if value, ok := luo.mutation.UpdateTime(); ok { + _spec.SetField(language.FieldUpdateTime, field.TypeTime, value) + } if value, ok := luo.mutation.CalibreID(); ok { _spec.SetField(language.FieldCalibreID, field.TypeInt64, value) } diff --git a/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go index 02015b9e..4c67d1cb 100644 --- a/internal/ent/migrate/schema.go +++ b/internal/ent/migrate/schema.go @@ -11,6 +11,8 @@ var ( // AuthorsColumns holds the columns for the "authors" table. AuthorsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "name", Type: field.TypeString, Unique: true}, {Name: "sort", Type: field.TypeString}, @@ -25,23 +27,25 @@ var ( { Name: "author_calibre_id", Unique: true, - Columns: []*schema.Column{AuthorsColumns[1]}, + Columns: []*schema.Column{AuthorsColumns[3]}, }, { Name: "author_name", Unique: true, - Columns: []*schema.Column{AuthorsColumns[2]}, + Columns: []*schema.Column{AuthorsColumns[4]}, }, { Name: "author_sort", Unique: true, - Columns: []*schema.Column{AuthorsColumns[3]}, + Columns: []*schema.Column{AuthorsColumns[5]}, }, }, } // BooksColumns holds the columns for the "books" table. BooksColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "title", Type: field.TypeString, Size: 2147483647}, {Name: "sort", Type: field.TypeString, Size: 2147483647}, @@ -60,33 +64,60 @@ var ( { Name: "book_calibre_id", Unique: true, - Columns: []*schema.Column{BooksColumns[1]}, + Columns: []*schema.Column{BooksColumns[3]}, }, { Name: "book_title", Unique: false, - Columns: []*schema.Column{BooksColumns[2]}, + Columns: []*schema.Column{BooksColumns[4]}, }, { Name: "book_sort", Unique: false, - Columns: []*schema.Column{BooksColumns[3]}, + Columns: []*schema.Column{BooksColumns[5]}, }, { Name: "book_published_date", Unique: false, - Columns: []*schema.Column{BooksColumns[4]}, + Columns: []*schema.Column{BooksColumns[6]}, }, { Name: "book_isbn", Unique: false, - Columns: []*schema.Column{BooksColumns[6]}, + Columns: []*schema.Column{BooksColumns[8]}, + }, + }, + } + // BookFilesColumns holds the columns for the "book_files" table. + BookFilesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 2147483647}, + {Name: "path", Type: field.TypeString, Size: 2147483647}, + {Name: "size", Type: field.TypeInt64}, + {Name: "format", Type: field.TypeEnum, Enums: []string{"AZW3", "EPUB", "KEPUB", "PDF", "CBC", "CBR", "CB7", "CBZ", "CBT"}}, + {Name: "book_file_book", Type: field.TypeString}, + } + // BookFilesTable holds the schema information for the "book_files" table. + BookFilesTable = &schema.Table{ + Name: "book_files", + Columns: BookFilesColumns, + PrimaryKey: []*schema.Column{BookFilesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "book_files_books_book", + Columns: []*schema.Column{BookFilesColumns[7]}, + RefColumns: []*schema.Column{BooksColumns[0]}, + OnDelete: schema.NoAction, }, }, } // IdentifiersColumns holds the columns for the "identifiers" table. IdentifiersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "type", Type: field.TypeString}, {Name: "value", Type: field.TypeString}, @@ -100,7 +131,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "identifiers_books_book", - Columns: []*schema.Column{IdentifiersColumns[4]}, + Columns: []*schema.Column{IdentifiersColumns[6]}, RefColumns: []*schema.Column{BooksColumns[0]}, OnDelete: schema.NoAction, }, @@ -109,18 +140,20 @@ var ( { Name: "identifier_calibre_id", Unique: true, - Columns: []*schema.Column{IdentifiersColumns[1]}, + Columns: []*schema.Column{IdentifiersColumns[3]}, }, { Name: "identifier_type_value", Unique: false, - Columns: []*schema.Column{IdentifiersColumns[2], IdentifiersColumns[3]}, + Columns: []*schema.Column{IdentifiersColumns[4], IdentifiersColumns[5]}, }, }, } // LanguagesColumns holds the columns for the "languages" table. LanguagesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "code", Type: field.TypeString}, } @@ -133,18 +166,20 @@ var ( { Name: "language_calibre_id", Unique: true, - Columns: []*schema.Column{LanguagesColumns[1]}, + Columns: []*schema.Column{LanguagesColumns[3]}, }, { Name: "language_code", Unique: false, - Columns: []*schema.Column{LanguagesColumns[2]}, + Columns: []*schema.Column{LanguagesColumns[4]}, }, }, } // PublishersColumns holds the columns for the "publishers" table. PublishersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "name", Type: field.TypeString}, } @@ -157,18 +192,20 @@ var ( { Name: "publisher_calibre_id", Unique: true, - Columns: []*schema.Column{PublishersColumns[1]}, + Columns: []*schema.Column{PublishersColumns[3]}, }, { Name: "publisher_name", Unique: false, - Columns: []*schema.Column{PublishersColumns[2]}, + Columns: []*schema.Column{PublishersColumns[4]}, }, }, } // SeriesColumns holds the columns for the "series" table. SeriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "calibre_id", Type: field.TypeInt64, Unique: true, Nullable: true}, {Name: "name", Type: field.TypeString}, {Name: "sort", Type: field.TypeString}, @@ -182,18 +219,20 @@ var ( { Name: "series_calibre_id", Unique: true, - Columns: []*schema.Column{SeriesColumns[1]}, + Columns: []*schema.Column{SeriesColumns[3]}, }, { Name: "series_name", Unique: false, - Columns: []*schema.Column{SeriesColumns[2]}, + Columns: []*schema.Column{SeriesColumns[4]}, }, }, } // ShelvesColumns holds the columns for the "shelves" table. ShelvesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "public", Type: field.TypeBool, Default: false}, {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, @@ -207,7 +246,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "shelves_users_user", - Columns: []*schema.Column{ShelvesColumns[4]}, + Columns: []*schema.Column{ShelvesColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, @@ -216,7 +255,7 @@ var ( { Name: "shelf_name", Unique: false, - Columns: []*schema.Column{ShelvesColumns[2]}, + Columns: []*schema.Column{ShelvesColumns[4]}, }, }, } @@ -274,6 +313,8 @@ var ( // UsersColumns holds the columns for the "users" table. UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "username", Type: field.TypeString, Unique: true}, {Name: "password_hash", Type: field.TypeString, Nullable: true}, {Name: "email", Type: field.TypeString, Unique: true}, @@ -287,21 +328,23 @@ var ( { Name: "user_username", Unique: false, - Columns: []*schema.Column{UsersColumns[1]}, + Columns: []*schema.Column{UsersColumns[3]}, }, { Name: "user_password_hash", Unique: false, - Columns: []*schema.Column{UsersColumns[2]}, + Columns: []*schema.Column{UsersColumns[4]}, }, }, } // UserPermissionsColumns holds the columns for the "user_permissions" table. UserPermissionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, - {Name: "can_edit", Type: field.TypeBool, Default: false}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, {Name: "admin", Type: field.TypeBool, Default: false}, {Name: "can_create_public", Type: field.TypeBool, Default: false}, + {Name: "can_edit", Type: field.TypeBool, Default: false}, {Name: "user_id", Type: field.TypeString, Unique: true, Nullable: true}, } // UserPermissionsTable holds the schema information for the "user_permissions" table. @@ -312,7 +355,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "user_permissions_users_user_permissions", - Columns: []*schema.Column{UserPermissionsColumns[4]}, + Columns: []*schema.Column{UserPermissionsColumns[6]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.SetNull, }, @@ -472,6 +515,7 @@ var ( Tables = []*schema.Table{ AuthorsTable, BooksTable, + BookFilesTable, IdentifiersTable, LanguagesTable, PublishersTable, @@ -491,6 +535,7 @@ var ( ) func init() { + BookFilesTable.ForeignKeys[0].RefTable = BooksTable IdentifiersTable.ForeignKeys[0].RefTable = BooksTable ShelvesTable.ForeignKeys[0].RefTable = UsersTable TasksTable.ForeignKeys[0].RefTable = UsersTable diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go index 790e93fa..390fff49 100644 --- a/internal/ent/mutation.go +++ b/internal/ent/mutation.go @@ -8,6 +8,7 @@ import ( "fmt" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/predicate" @@ -38,6 +39,7 @@ const ( // Node types. TypeAuthor = "Author" TypeBook = "Book" + TypeBookFile = "BookFile" TypeIdentifier = "Identifier" TypeLanguage = "Language" TypePublisher = "Publisher" @@ -55,6 +57,8 @@ type AuthorMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time calibre_id *int64 addcalibre_id *int64 name *string @@ -173,6 +177,78 @@ func (m *AuthorMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *AuthorMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *AuthorMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Author entity. +// If the Author object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *AuthorMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *AuthorMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *AuthorMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Author entity. +// If the Author object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *AuthorMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetCalibreID sets the "calibre_id" field. func (m *AuthorMutation) SetCalibreID(i int64) { m.calibre_id = &i @@ -452,7 +528,13 @@ func (m *AuthorMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *AuthorMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 6) + if m.create_time != nil { + fields = append(fields, author.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, author.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, author.FieldCalibreID) } @@ -473,6 +555,10 @@ func (m *AuthorMutation) Fields() []string { // schema. func (m *AuthorMutation) Field(name string) (ent.Value, bool) { switch name { + case author.FieldCreateTime: + return m.CreateTime() + case author.FieldUpdateTime: + return m.UpdateTime() case author.FieldCalibreID: return m.CalibreID() case author.FieldName: @@ -490,6 +576,10 @@ func (m *AuthorMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *AuthorMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case author.FieldCreateTime: + return m.OldCreateTime(ctx) + case author.FieldUpdateTime: + return m.OldUpdateTime(ctx) case author.FieldCalibreID: return m.OldCalibreID(ctx) case author.FieldName: @@ -507,6 +597,20 @@ func (m *AuthorMutation) OldField(ctx context.Context, name string) (ent.Value, // type. func (m *AuthorMutation) SetField(name string, value ent.Value) error { switch name { + case author.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case author.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case author.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -614,6 +718,12 @@ func (m *AuthorMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *AuthorMutation) ResetField(name string) error { switch name { + case author.FieldCreateTime: + m.ResetCreateTime() + return nil + case author.FieldUpdateTime: + m.ResetUpdateTime() + return nil case author.FieldCalibreID: m.ResetCalibreID() return nil @@ -720,6 +830,8 @@ type BookMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time calibre_id *int64 addcalibre_id *int64 title *string @@ -752,6 +864,9 @@ type BookMutation struct { shelf map[ksuid.ID]struct{} removedshelf map[ksuid.ID]struct{} clearedshelf bool + files map[ksuid.ID]struct{} + removedfiles map[ksuid.ID]struct{} + clearedfiles bool done bool oldValue func(context.Context) (*Book, error) predicates []predicate.Book @@ -861,6 +976,78 @@ func (m *BookMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *BookMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *BookMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Book entity. +// If the Book object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *BookMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *BookMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *BookMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Book entity. +// If the Book object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *BookMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetCalibreID sets the "calibre_id" field. func (m *BookMutation) SetCalibreID(i int64) { m.calibre_id = &i @@ -1634,6 +1821,60 @@ func (m *BookMutation) ResetShelf() { m.removedshelf = nil } +// AddFileIDs adds the "files" edge to the BookFile entity by ids. +func (m *BookMutation) AddFileIDs(ids ...ksuid.ID) { + if m.files == nil { + m.files = make(map[ksuid.ID]struct{}) + } + for i := range ids { + m.files[ids[i]] = struct{}{} + } +} + +// ClearFiles clears the "files" edge to the BookFile entity. +func (m *BookMutation) ClearFiles() { + m.clearedfiles = true +} + +// FilesCleared reports if the "files" edge to the BookFile entity was cleared. +func (m *BookMutation) FilesCleared() bool { + return m.clearedfiles +} + +// RemoveFileIDs removes the "files" edge to the BookFile entity by IDs. +func (m *BookMutation) RemoveFileIDs(ids ...ksuid.ID) { + if m.removedfiles == nil { + m.removedfiles = make(map[ksuid.ID]struct{}) + } + for i := range ids { + delete(m.files, ids[i]) + m.removedfiles[ids[i]] = struct{}{} + } +} + +// RemovedFiles returns the removed IDs of the "files" edge to the BookFile entity. +func (m *BookMutation) RemovedFilesIDs() (ids []ksuid.ID) { + for id := range m.removedfiles { + ids = append(ids, id) + } + return +} + +// FilesIDs returns the "files" edge IDs in the mutation. +func (m *BookMutation) FilesIDs() (ids []ksuid.ID) { + for id := range m.files { + ids = append(ids, id) + } + return +} + +// ResetFiles resets all changes to the "files" edge. +func (m *BookMutation) ResetFiles() { + m.files = nil + m.clearedfiles = false + m.removedfiles = nil +} + // Where appends a list predicates to the BookMutation builder. func (m *BookMutation) Where(ps ...predicate.Book) { m.predicates = append(m.predicates, ps...) @@ -1668,7 +1909,13 @@ func (m *BookMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BookMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 10) + if m.create_time != nil { + fields = append(fields, book.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, book.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, book.FieldCalibreID) } @@ -1701,6 +1948,10 @@ func (m *BookMutation) Fields() []string { // schema. func (m *BookMutation) Field(name string) (ent.Value, bool) { switch name { + case book.FieldCreateTime: + return m.CreateTime() + case book.FieldUpdateTime: + return m.UpdateTime() case book.FieldCalibreID: return m.CalibreID() case book.FieldTitle: @@ -1726,6 +1977,10 @@ func (m *BookMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *BookMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case book.FieldCreateTime: + return m.OldCreateTime(ctx) + case book.FieldUpdateTime: + return m.OldUpdateTime(ctx) case book.FieldCalibreID: return m.OldCalibreID(ctx) case book.FieldTitle: @@ -1751,6 +2006,20 @@ func (m *BookMutation) OldField(ctx context.Context, name string) (ent.Value, er // type. func (m *BookMutation) SetField(name string, value ent.Value) error { switch name { + case book.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case book.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case book.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -1916,6 +2185,12 @@ func (m *BookMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *BookMutation) ResetField(name string) error { switch name { + case book.FieldCreateTime: + m.ResetCreateTime() + return nil + case book.FieldUpdateTime: + m.ResetUpdateTime() + return nil case book.FieldCalibreID: m.ResetCalibreID() return nil @@ -1946,7 +2221,7 @@ func (m *BookMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *BookMutation) AddedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.authors != nil { edges = append(edges, book.EdgeAuthors) } @@ -1968,6 +2243,9 @@ func (m *BookMutation) AddedEdges() []string { if m.shelf != nil { edges = append(edges, book.EdgeShelf) } + if m.files != nil { + edges = append(edges, book.EdgeFiles) + } return edges } @@ -2017,13 +2295,19 @@ func (m *BookMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case book.EdgeFiles: + ids := make([]ent.Value, 0, len(m.files)) + for id := range m.files { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *BookMutation) RemovedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.removedauthors != nil { edges = append(edges, book.EdgeAuthors) } @@ -2045,6 +2329,9 @@ func (m *BookMutation) RemovedEdges() []string { if m.removedshelf != nil { edges = append(edges, book.EdgeShelf) } + if m.removedfiles != nil { + edges = append(edges, book.EdgeFiles) + } return edges } @@ -2094,13 +2381,19 @@ func (m *BookMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case book.EdgeFiles: + ids := make([]ent.Value, 0, len(m.removedfiles)) + for id := range m.removedfiles { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *BookMutation) ClearedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.clearedauthors { edges = append(edges, book.EdgeAuthors) } @@ -2122,6 +2415,9 @@ func (m *BookMutation) ClearedEdges() []string { if m.clearedshelf { edges = append(edges, book.EdgeShelf) } + if m.clearedfiles { + edges = append(edges, book.EdgeFiles) + } return edges } @@ -2143,6 +2439,8 @@ func (m *BookMutation) EdgeCleared(name string) bool { return m.clearedlanguage case book.EdgeShelf: return m.clearedshelf + case book.EdgeFiles: + return m.clearedfiles } return false } @@ -2180,39 +2478,45 @@ func (m *BookMutation) ResetEdge(name string) error { case book.EdgeShelf: m.ResetShelf() return nil + case book.EdgeFiles: + m.ResetFiles() + return nil } return fmt.Errorf("unknown Book edge %s", name) } -// IdentifierMutation represents an operation that mutates the Identifier nodes in the graph. -type IdentifierMutation struct { +// BookFileMutation represents an operation that mutates the BookFile nodes in the graph. +type BookFileMutation struct { config op Op typ string id *ksuid.ID - calibre_id *int64 - addcalibre_id *int64 - _type *string - value *string + create_time *time.Time + update_time *time.Time + name *string + _path *string + size *int64 + addsize *int64 + format *bookfile.Format clearedFields map[string]struct{} book *ksuid.ID clearedbook bool done bool - oldValue func(context.Context) (*Identifier, error) - predicates []predicate.Identifier + oldValue func(context.Context) (*BookFile, error) + predicates []predicate.BookFile } -var _ ent.Mutation = (*IdentifierMutation)(nil) +var _ ent.Mutation = (*BookFileMutation)(nil) -// identifierOption allows management of the mutation configuration using functional options. -type identifierOption func(*IdentifierMutation) +// bookfileOption allows management of the mutation configuration using functional options. +type bookfileOption func(*BookFileMutation) -// newIdentifierMutation creates new mutation for the Identifier entity. -func newIdentifierMutation(c config, op Op, opts ...identifierOption) *IdentifierMutation { - m := &IdentifierMutation{ +// newBookFileMutation creates new mutation for the BookFile entity. +func newBookFileMutation(c config, op Op, opts ...bookfileOption) *BookFileMutation { + m := &BookFileMutation{ config: c, op: op, - typ: TypeIdentifier, + typ: TypeBookFile, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -2221,20 +2525,20 @@ func newIdentifierMutation(c config, op Op, opts ...identifierOption) *Identifie return m } -// withIdentifierID sets the ID field of the mutation. -func withIdentifierID(id ksuid.ID) identifierOption { - return func(m *IdentifierMutation) { +// withBookFileID sets the ID field of the mutation. +func withBookFileID(id ksuid.ID) bookfileOption { + return func(m *BookFileMutation) { var ( err error once sync.Once - value *Identifier + value *BookFile ) - m.oldValue = func(ctx context.Context) (*Identifier, error) { + m.oldValue = func(ctx context.Context) (*BookFile, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Identifier.Get(ctx, id) + value, err = m.Client().BookFile.Get(ctx, id) } }) return value, err @@ -2243,10 +2547,10 @@ func withIdentifierID(id ksuid.ID) identifierOption { } } -// withIdentifier sets the old Identifier of the mutation. -func withIdentifier(node *Identifier) identifierOption { - return func(m *IdentifierMutation) { - m.oldValue = func(context.Context) (*Identifier, error) { +// withBookFile sets the old BookFile of the mutation. +func withBookFile(node *BookFile) bookfileOption { + return func(m *BookFileMutation) { + m.oldValue = func(context.Context) (*BookFile, error) { return node, nil } m.id = &node.ID @@ -2255,7 +2559,7 @@ func withIdentifier(node *Identifier) identifierOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m IdentifierMutation) Client() *Client { +func (m BookFileMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2263,7 +2567,7 @@ func (m IdentifierMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m IdentifierMutation) Tx() (*Tx, error) { +func (m BookFileMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -2273,14 +2577,14 @@ func (m IdentifierMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Identifier entities. -func (m *IdentifierMutation) SetID(id ksuid.ID) { +// operation is only accepted on creation of BookFile entities. +func (m *BookFileMutation) SetID(id ksuid.ID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *IdentifierMutation) ID() (id ksuid.ID, exists bool) { +func (m *BookFileMutation) ID() (id ksuid.ID, exists bool) { if m.id == nil { return } @@ -2291,7 +2595,7 @@ func (m *IdentifierMutation) ID() (id ksuid.ID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *IdentifierMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { +func (m *BookFileMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -2300,31 +2604,807 @@ func (m *IdentifierMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Identifier.Query().Where(m.predicates...).IDs(ctx) + return m.Client().BookFile.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetCalibreID sets the "calibre_id" field. -func (m *IdentifierMutation) SetCalibreID(i int64) { - m.calibre_id = &i - m.addcalibre_id = nil +// SetCreateTime sets the "create_time" field. +func (m *BookFileMutation) SetCreateTime(t time.Time) { + m.create_time = &t } -// CalibreID returns the value of the "calibre_id" field in the mutation. -func (m *IdentifierMutation) CalibreID() (r int64, exists bool) { - v := m.calibre_id +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *BookFileMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time if v == nil { return } return *v, true } -// OldCalibreID returns the old "calibre_id" field's value of the Identifier entity. -// If the Identifier object wasn't provided to the builder, the object is fetched from the database. +// OldCreateTime returns the old "create_time" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *IdentifierMutation) OldCalibreID(ctx context.Context) (v int64, err error) { +func (m *BookFileMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *BookFileMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *BookFileMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *BookFileMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookFileMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *BookFileMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetName sets the "name" field. +func (m *BookFileMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *BookFileMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookFileMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *BookFileMutation) ResetName() { + m.name = nil +} + +// SetPath sets the "path" field. +func (m *BookFileMutation) SetPath(s string) { + m._path = &s +} + +// Path returns the value of the "path" field in the mutation. +func (m *BookFileMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true +} + +// OldPath returns the old "path" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookFileMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) + } + return oldValue.Path, nil +} + +// ResetPath resets all changes to the "path" field. +func (m *BookFileMutation) ResetPath() { + m._path = nil +} + +// SetSize sets the "size" field. +func (m *BookFileMutation) SetSize(i int64) { + m.size = &i + m.addsize = nil +} + +// Size returns the value of the "size" field in the mutation. +func (m *BookFileMutation) Size() (r int64, exists bool) { + v := m.size + if v == nil { + return + } + return *v, true +} + +// OldSize returns the old "size" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookFileMutation) OldSize(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSize: %w", err) + } + return oldValue.Size, nil +} + +// AddSize adds i to the "size" field. +func (m *BookFileMutation) AddSize(i int64) { + if m.addsize != nil { + *m.addsize += i + } else { + m.addsize = &i + } +} + +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *BookFileMutation) AddedSize() (r int64, exists bool) { + v := m.addsize + if v == nil { + return + } + return *v, true +} + +// ResetSize resets all changes to the "size" field. +func (m *BookFileMutation) ResetSize() { + m.size = nil + m.addsize = nil +} + +// SetFormat sets the "format" field. +func (m *BookFileMutation) SetFormat(b bookfile.Format) { + m.format = &b +} + +// Format returns the value of the "format" field in the mutation. +func (m *BookFileMutation) Format() (r bookfile.Format, exists bool) { + v := m.format + if v == nil { + return + } + return *v, true +} + +// OldFormat returns the old "format" field's value of the BookFile entity. +// If the BookFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BookFileMutation) OldFormat(ctx context.Context) (v bookfile.Format, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFormat is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFormat requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFormat: %w", err) + } + return oldValue.Format, nil +} + +// ResetFormat resets all changes to the "format" field. +func (m *BookFileMutation) ResetFormat() { + m.format = nil +} + +// SetBookID sets the "book" edge to the Book entity by id. +func (m *BookFileMutation) SetBookID(id ksuid.ID) { + m.book = &id +} + +// ClearBook clears the "book" edge to the Book entity. +func (m *BookFileMutation) ClearBook() { + m.clearedbook = true +} + +// BookCleared reports if the "book" edge to the Book entity was cleared. +func (m *BookFileMutation) BookCleared() bool { + return m.clearedbook +} + +// BookID returns the "book" edge ID in the mutation. +func (m *BookFileMutation) BookID() (id ksuid.ID, exists bool) { + if m.book != nil { + return *m.book, true + } + return +} + +// BookIDs returns the "book" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// BookID instead. It exists only for internal usage by the builders. +func (m *BookFileMutation) BookIDs() (ids []ksuid.ID) { + if id := m.book; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetBook resets all changes to the "book" edge. +func (m *BookFileMutation) ResetBook() { + m.book = nil + m.clearedbook = false +} + +// Where appends a list predicates to the BookFileMutation builder. +func (m *BookFileMutation) Where(ps ...predicate.BookFile) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BookFileMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BookFileMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.BookFile, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *BookFileMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *BookFileMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (BookFile). +func (m *BookFileMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *BookFileMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.create_time != nil { + fields = append(fields, bookfile.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, bookfile.FieldUpdateTime) + } + if m.name != nil { + fields = append(fields, bookfile.FieldName) + } + if m._path != nil { + fields = append(fields, bookfile.FieldPath) + } + if m.size != nil { + fields = append(fields, bookfile.FieldSize) + } + if m.format != nil { + fields = append(fields, bookfile.FieldFormat) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *BookFileMutation) Field(name string) (ent.Value, bool) { + switch name { + case bookfile.FieldCreateTime: + return m.CreateTime() + case bookfile.FieldUpdateTime: + return m.UpdateTime() + case bookfile.FieldName: + return m.Name() + case bookfile.FieldPath: + return m.Path() + case bookfile.FieldSize: + return m.Size() + case bookfile.FieldFormat: + return m.Format() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *BookFileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case bookfile.FieldCreateTime: + return m.OldCreateTime(ctx) + case bookfile.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case bookfile.FieldName: + return m.OldName(ctx) + case bookfile.FieldPath: + return m.OldPath(ctx) + case bookfile.FieldSize: + return m.OldSize(ctx) + case bookfile.FieldFormat: + return m.OldFormat(ctx) + } + return nil, fmt.Errorf("unknown BookFile field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BookFileMutation) SetField(name string, value ent.Value) error { + switch name { + case bookfile.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case bookfile.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case bookfile.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case bookfile.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case bookfile.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + case bookfile.FieldFormat: + v, ok := value.(bookfile.Format) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFormat(v) + return nil + } + return fmt.Errorf("unknown BookFile field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BookFileMutation) AddedFields() []string { + var fields []string + if m.addsize != nil { + fields = append(fields, bookfile.FieldSize) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *BookFileMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case bookfile.FieldSize: + return m.AddedSize() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BookFileMutation) AddField(name string, value ent.Value) error { + switch name { + case bookfile.FieldSize: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSize(v) + return nil + } + return fmt.Errorf("unknown BookFile numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BookFileMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BookFileMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *BookFileMutation) ClearField(name string) error { + return fmt.Errorf("unknown BookFile nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *BookFileMutation) ResetField(name string) error { + switch name { + case bookfile.FieldCreateTime: + m.ResetCreateTime() + return nil + case bookfile.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case bookfile.FieldName: + m.ResetName() + return nil + case bookfile.FieldPath: + m.ResetPath() + return nil + case bookfile.FieldSize: + m.ResetSize() + return nil + case bookfile.FieldFormat: + m.ResetFormat() + return nil + } + return fmt.Errorf("unknown BookFile field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BookFileMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.book != nil { + edges = append(edges, bookfile.EdgeBook) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *BookFileMutation) AddedIDs(name string) []ent.Value { + switch name { + case bookfile.EdgeBook: + if id := m.book; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BookFileMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *BookFileMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BookFileMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedbook { + edges = append(edges, bookfile.EdgeBook) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *BookFileMutation) EdgeCleared(name string) bool { + switch name { + case bookfile.EdgeBook: + return m.clearedbook + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *BookFileMutation) ClearEdge(name string) error { + switch name { + case bookfile.EdgeBook: + m.ClearBook() + return nil + } + return fmt.Errorf("unknown BookFile unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *BookFileMutation) ResetEdge(name string) error { + switch name { + case bookfile.EdgeBook: + m.ResetBook() + return nil + } + return fmt.Errorf("unknown BookFile edge %s", name) +} + +// IdentifierMutation represents an operation that mutates the Identifier nodes in the graph. +type IdentifierMutation struct { + config + op Op + typ string + id *ksuid.ID + create_time *time.Time + update_time *time.Time + calibre_id *int64 + addcalibre_id *int64 + _type *string + value *string + clearedFields map[string]struct{} + book *ksuid.ID + clearedbook bool + done bool + oldValue func(context.Context) (*Identifier, error) + predicates []predicate.Identifier +} + +var _ ent.Mutation = (*IdentifierMutation)(nil) + +// identifierOption allows management of the mutation configuration using functional options. +type identifierOption func(*IdentifierMutation) + +// newIdentifierMutation creates new mutation for the Identifier entity. +func newIdentifierMutation(c config, op Op, opts ...identifierOption) *IdentifierMutation { + m := &IdentifierMutation{ + config: c, + op: op, + typ: TypeIdentifier, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withIdentifierID sets the ID field of the mutation. +func withIdentifierID(id ksuid.ID) identifierOption { + return func(m *IdentifierMutation) { + var ( + err error + once sync.Once + value *Identifier + ) + m.oldValue = func(ctx context.Context) (*Identifier, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Identifier.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withIdentifier sets the old Identifier of the mutation. +func withIdentifier(node *Identifier) identifierOption { + return func(m *IdentifierMutation) { + m.oldValue = func(context.Context) (*Identifier, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m IdentifierMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m IdentifierMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Identifier entities. +func (m *IdentifierMutation) SetID(id ksuid.ID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *IdentifierMutation) ID() (id ksuid.ID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *IdentifierMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []ksuid.ID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Identifier.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *IdentifierMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *IdentifierMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Identifier entity. +// If the Identifier object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *IdentifierMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *IdentifierMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *IdentifierMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *IdentifierMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Identifier entity. +// If the Identifier object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *IdentifierMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *IdentifierMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetCalibreID sets the "calibre_id" field. +func (m *IdentifierMutation) SetCalibreID(i int64) { + m.calibre_id = &i + m.addcalibre_id = nil +} + +// CalibreID returns the value of the "calibre_id" field in the mutation. +func (m *IdentifierMutation) CalibreID() (r int64, exists bool) { + v := m.calibre_id + if v == nil { + return + } + return *v, true +} + +// OldCalibreID returns the old "calibre_id" field's value of the Identifier entity. +// If the Identifier object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *IdentifierMutation) OldCalibreID(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCalibreID is only allowed on UpdateOne operations") } @@ -2521,7 +3601,13 @@ func (m *IdentifierMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *IdentifierMutation) Fields() []string { - fields := make([]string, 0, 3) + fields := make([]string, 0, 5) + if m.create_time != nil { + fields = append(fields, identifier.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, identifier.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, identifier.FieldCalibreID) } @@ -2539,6 +3625,10 @@ func (m *IdentifierMutation) Fields() []string { // schema. func (m *IdentifierMutation) Field(name string) (ent.Value, bool) { switch name { + case identifier.FieldCreateTime: + return m.CreateTime() + case identifier.FieldUpdateTime: + return m.UpdateTime() case identifier.FieldCalibreID: return m.CalibreID() case identifier.FieldType: @@ -2554,6 +3644,10 @@ func (m *IdentifierMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *IdentifierMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case identifier.FieldCreateTime: + return m.OldCreateTime(ctx) + case identifier.FieldUpdateTime: + return m.OldUpdateTime(ctx) case identifier.FieldCalibreID: return m.OldCalibreID(ctx) case identifier.FieldType: @@ -2569,6 +3663,20 @@ func (m *IdentifierMutation) OldField(ctx context.Context, name string) (ent.Val // type. func (m *IdentifierMutation) SetField(name string, value ent.Value) error { switch name { + case identifier.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case identifier.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case identifier.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -2663,6 +3771,12 @@ func (m *IdentifierMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *IdentifierMutation) ResetField(name string) error { switch name { + case identifier.FieldCreateTime: + m.ResetCreateTime() + return nil + case identifier.FieldUpdateTime: + m.ResetUpdateTime() + return nil case identifier.FieldCalibreID: m.ResetCalibreID() return nil @@ -2756,6 +3870,8 @@ type LanguageMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time calibre_id *int64 addcalibre_id *int64 code *string @@ -2872,6 +3988,78 @@ func (m *LanguageMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *LanguageMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *LanguageMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Language entity. +// If the Language object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LanguageMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *LanguageMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *LanguageMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *LanguageMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Language entity. +// If the Language object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LanguageMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *LanguageMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetCalibreID sets the "calibre_id" field. func (m *LanguageMutation) SetCalibreID(i int64) { m.calibre_id = &i @@ -3066,7 +4254,13 @@ func (m *LanguageMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *LanguageMutation) Fields() []string { - fields := make([]string, 0, 2) + fields := make([]string, 0, 4) + if m.create_time != nil { + fields = append(fields, language.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, language.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, language.FieldCalibreID) } @@ -3081,6 +4275,10 @@ func (m *LanguageMutation) Fields() []string { // schema. func (m *LanguageMutation) Field(name string) (ent.Value, bool) { switch name { + case language.FieldCreateTime: + return m.CreateTime() + case language.FieldUpdateTime: + return m.UpdateTime() case language.FieldCalibreID: return m.CalibreID() case language.FieldCode: @@ -3094,6 +4292,10 @@ func (m *LanguageMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *LanguageMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case language.FieldCreateTime: + return m.OldCreateTime(ctx) + case language.FieldUpdateTime: + return m.OldUpdateTime(ctx) case language.FieldCalibreID: return m.OldCalibreID(ctx) case language.FieldCode: @@ -3107,6 +4309,20 @@ func (m *LanguageMutation) OldField(ctx context.Context, name string) (ent.Value // type. func (m *LanguageMutation) SetField(name string, value ent.Value) error { switch name { + case language.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case language.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case language.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -3194,6 +4410,12 @@ func (m *LanguageMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *LanguageMutation) ResetField(name string) error { switch name { + case language.FieldCreateTime: + m.ResetCreateTime() + return nil + case language.FieldUpdateTime: + m.ResetUpdateTime() + return nil case language.FieldCalibreID: m.ResetCalibreID() return nil @@ -3294,6 +4516,8 @@ type PublisherMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time calibre_id *int64 addcalibre_id *int64 name *string @@ -3410,6 +4634,78 @@ func (m *PublisherMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *PublisherMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *PublisherMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Publisher entity. +// If the Publisher object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PublisherMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *PublisherMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *PublisherMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *PublisherMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Publisher entity. +// If the Publisher object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PublisherMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *PublisherMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetCalibreID sets the "calibre_id" field. func (m *PublisherMutation) SetCalibreID(i int64) { m.calibre_id = &i @@ -3604,7 +4900,13 @@ func (m *PublisherMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PublisherMutation) Fields() []string { - fields := make([]string, 0, 2) + fields := make([]string, 0, 4) + if m.create_time != nil { + fields = append(fields, publisher.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, publisher.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, publisher.FieldCalibreID) } @@ -3619,6 +4921,10 @@ func (m *PublisherMutation) Fields() []string { // schema. func (m *PublisherMutation) Field(name string) (ent.Value, bool) { switch name { + case publisher.FieldCreateTime: + return m.CreateTime() + case publisher.FieldUpdateTime: + return m.UpdateTime() case publisher.FieldCalibreID: return m.CalibreID() case publisher.FieldName: @@ -3632,6 +4938,10 @@ func (m *PublisherMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *PublisherMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case publisher.FieldCreateTime: + return m.OldCreateTime(ctx) + case publisher.FieldUpdateTime: + return m.OldUpdateTime(ctx) case publisher.FieldCalibreID: return m.OldCalibreID(ctx) case publisher.FieldName: @@ -3645,6 +4955,20 @@ func (m *PublisherMutation) OldField(ctx context.Context, name string) (ent.Valu // type. func (m *PublisherMutation) SetField(name string, value ent.Value) error { switch name { + case publisher.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case publisher.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case publisher.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -3732,6 +5056,12 @@ func (m *PublisherMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *PublisherMutation) ResetField(name string) error { switch name { + case publisher.FieldCreateTime: + m.ResetCreateTime() + return nil + case publisher.FieldUpdateTime: + m.ResetUpdateTime() + return nil case publisher.FieldCalibreID: m.ResetCalibreID() return nil @@ -3832,6 +5162,8 @@ type SeriesMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time calibre_id *int64 addcalibre_id *int64 name *string @@ -3949,6 +5281,78 @@ func (m *SeriesMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *SeriesMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *SeriesMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Series entity. +// If the Series object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SeriesMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *SeriesMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *SeriesMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *SeriesMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Series entity. +// If the Series object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SeriesMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *SeriesMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetCalibreID sets the "calibre_id" field. func (m *SeriesMutation) SetCalibreID(i int64) { m.calibre_id = &i @@ -4179,7 +5583,13 @@ func (m *SeriesMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *SeriesMutation) Fields() []string { - fields := make([]string, 0, 3) + fields := make([]string, 0, 5) + if m.create_time != nil { + fields = append(fields, series.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, series.FieldUpdateTime) + } if m.calibre_id != nil { fields = append(fields, series.FieldCalibreID) } @@ -4197,6 +5607,10 @@ func (m *SeriesMutation) Fields() []string { // schema. func (m *SeriesMutation) Field(name string) (ent.Value, bool) { switch name { + case series.FieldCreateTime: + return m.CreateTime() + case series.FieldUpdateTime: + return m.UpdateTime() case series.FieldCalibreID: return m.CalibreID() case series.FieldName: @@ -4212,6 +5626,10 @@ func (m *SeriesMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *SeriesMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case series.FieldCreateTime: + return m.OldCreateTime(ctx) + case series.FieldUpdateTime: + return m.OldUpdateTime(ctx) case series.FieldCalibreID: return m.OldCalibreID(ctx) case series.FieldName: @@ -4227,6 +5645,20 @@ func (m *SeriesMutation) OldField(ctx context.Context, name string) (ent.Value, // type. func (m *SeriesMutation) SetField(name string, value ent.Value) error { switch name { + case series.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case series.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case series.FieldCalibreID: v, ok := value.(int64) if !ok { @@ -4321,6 +5753,12 @@ func (m *SeriesMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *SeriesMutation) ResetField(name string) error { switch name { + case series.FieldCreateTime: + m.ResetCreateTime() + return nil + case series.FieldUpdateTime: + m.ResetUpdateTime() + return nil case series.FieldCalibreID: m.ResetCalibreID() return nil @@ -4424,6 +5862,8 @@ type ShelfMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time public *bool name *string description *string @@ -4542,6 +5982,78 @@ func (m *ShelfMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *ShelfMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ShelfMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Shelf entity. +// If the Shelf object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ShelfMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ShelfMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ShelfMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ShelfMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Shelf entity. +// If the Shelf object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ShelfMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ShelfMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetPublic sets the "public" field. func (m *ShelfMutation) SetPublic(b bool) { m.public = &b @@ -4814,7 +6326,13 @@ func (m *ShelfMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ShelfMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 6) + if m.create_time != nil { + fields = append(fields, shelf.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, shelf.FieldUpdateTime) + } if m.public != nil { fields = append(fields, shelf.FieldPublic) } @@ -4835,6 +6353,10 @@ func (m *ShelfMutation) Fields() []string { // schema. func (m *ShelfMutation) Field(name string) (ent.Value, bool) { switch name { + case shelf.FieldCreateTime: + return m.CreateTime() + case shelf.FieldUpdateTime: + return m.UpdateTime() case shelf.FieldPublic: return m.Public() case shelf.FieldUserID: @@ -4852,6 +6374,10 @@ func (m *ShelfMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *ShelfMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case shelf.FieldCreateTime: + return m.OldCreateTime(ctx) + case shelf.FieldUpdateTime: + return m.OldUpdateTime(ctx) case shelf.FieldPublic: return m.OldPublic(ctx) case shelf.FieldUserID: @@ -4869,6 +6395,20 @@ func (m *ShelfMutation) OldField(ctx context.Context, name string) (ent.Value, e // type. func (m *ShelfMutation) SetField(name string, value ent.Value) error { switch name { + case shelf.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case shelf.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case shelf.FieldPublic: v, ok := value.(bool) if !ok { @@ -4955,6 +6495,12 @@ func (m *ShelfMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *ShelfMutation) ResetField(name string) error { switch name { + case shelf.FieldCreateTime: + m.ResetCreateTime() + return nil + case shelf.FieldUpdateTime: + m.ResetUpdateTime() + return nil case shelf.FieldPublic: m.ResetPublic() return nil @@ -6531,6 +8077,8 @@ type UserMutation struct { op Op typ string id *ksuid.ID + create_time *time.Time + update_time *time.Time username *string password_hash *string email *string @@ -6627,26 +8175,98 @@ func (m *UserMutation) ID() (id ksuid.ID, exists bool) { if m.id == nil { return } - return *m.id, true + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []ksuid.ID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *UserMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *UserMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *UserMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *UserMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *UserMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []ksuid.ID{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// OldUpdateTime returns the old "update_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *UserMutation) ResetUpdateTime() { + m.update_time = nil } // SetUsername sets the "username" field. @@ -6897,7 +8517,13 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 3) + fields := make([]string, 0, 5) + if m.create_time != nil { + fields = append(fields, user.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, user.FieldUpdateTime) + } if m.username != nil { fields = append(fields, user.FieldUsername) } @@ -6915,6 +8541,10 @@ func (m *UserMutation) Fields() []string { // schema. func (m *UserMutation) Field(name string) (ent.Value, bool) { switch name { + case user.FieldCreateTime: + return m.CreateTime() + case user.FieldUpdateTime: + return m.UpdateTime() case user.FieldUsername: return m.Username() case user.FieldPasswordHash: @@ -6930,6 +8560,10 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case user.FieldCreateTime: + return m.OldCreateTime(ctx) + case user.FieldUpdateTime: + return m.OldUpdateTime(ctx) case user.FieldUsername: return m.OldUsername(ctx) case user.FieldPasswordHash: @@ -6945,6 +8579,20 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er // type. func (m *UserMutation) SetField(name string, value ent.Value) error { switch name { + case user.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case user.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil case user.FieldUsername: v, ok := value.(string) if !ok { @@ -7024,6 +8672,12 @@ func (m *UserMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *UserMutation) ResetField(name string) error { switch name { + case user.FieldCreateTime: + m.ResetCreateTime() + return nil + case user.FieldUpdateTime: + m.ResetUpdateTime() + return nil case user.FieldUsername: m.ResetUsername() return nil @@ -7145,9 +8799,11 @@ type UserPermissionsMutation struct { op Op typ string id *ksuid.ID - _CanEdit *bool + create_time *time.Time + update_time *time.Time _Admin *bool _CanCreatePublic *bool + _CanEdit *bool clearedFields map[string]struct{} user *ksuid.ID cleareduser bool @@ -7260,6 +8916,78 @@ func (m *UserPermissionsMutation) IDs(ctx context.Context) ([]ksuid.ID, error) { } } +// SetCreateTime sets the "create_time" field. +func (m *UserPermissionsMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *UserPermissionsMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the UserPermissions entity. +// If the UserPermissions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserPermissionsMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *UserPermissionsMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *UserPermissionsMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *UserPermissionsMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the UserPermissions entity. +// If the UserPermissions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserPermissionsMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *UserPermissionsMutation) ResetUpdateTime() { + m.update_time = nil +} + // SetUserID sets the "user_id" field. func (m *UserPermissionsMutation) SetUserID(k ksuid.ID) { m.user = &k @@ -7309,42 +9037,6 @@ func (m *UserPermissionsMutation) ResetUserID() { delete(m.clearedFields, userpermissions.FieldUserID) } -// SetCanEdit sets the "CanEdit" field. -func (m *UserPermissionsMutation) SetCanEdit(b bool) { - m._CanEdit = &b -} - -// CanEdit returns the value of the "CanEdit" field in the mutation. -func (m *UserPermissionsMutation) CanEdit() (r bool, exists bool) { - v := m._CanEdit - if v == nil { - return - } - return *v, true -} - -// OldCanEdit returns the old "CanEdit" field's value of the UserPermissions entity. -// If the UserPermissions object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserPermissionsMutation) OldCanEdit(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCanEdit is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCanEdit requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCanEdit: %w", err) - } - return oldValue.CanEdit, nil -} - -// ResetCanEdit resets all changes to the "CanEdit" field. -func (m *UserPermissionsMutation) ResetCanEdit() { - m._CanEdit = nil -} - // SetAdmin sets the "Admin" field. func (m *UserPermissionsMutation) SetAdmin(b bool) { m._Admin = &b @@ -7417,6 +9109,42 @@ func (m *UserPermissionsMutation) ResetCanCreatePublic() { m._CanCreatePublic = nil } +// SetCanEdit sets the "CanEdit" field. +func (m *UserPermissionsMutation) SetCanEdit(b bool) { + m._CanEdit = &b +} + +// CanEdit returns the value of the "CanEdit" field in the mutation. +func (m *UserPermissionsMutation) CanEdit() (r bool, exists bool) { + v := m._CanEdit + if v == nil { + return + } + return *v, true +} + +// OldCanEdit returns the old "CanEdit" field's value of the UserPermissions entity. +// If the UserPermissions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserPermissionsMutation) OldCanEdit(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCanEdit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCanEdit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCanEdit: %w", err) + } + return oldValue.CanEdit, nil +} + +// ResetCanEdit resets all changes to the "CanEdit" field. +func (m *UserPermissionsMutation) ResetCanEdit() { + m._CanEdit = nil +} + // ClearUser clears the "user" edge to the User entity. func (m *UserPermissionsMutation) ClearUser() { m.cleareduser = true @@ -7478,19 +9206,25 @@ func (m *UserPermissionsMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserPermissionsMutation) Fields() []string { - fields := make([]string, 0, 4) + fields := make([]string, 0, 6) + if m.create_time != nil { + fields = append(fields, userpermissions.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, userpermissions.FieldUpdateTime) + } if m.user != nil { fields = append(fields, userpermissions.FieldUserID) } - if m._CanEdit != nil { - fields = append(fields, userpermissions.FieldCanEdit) - } if m._Admin != nil { fields = append(fields, userpermissions.FieldAdmin) } if m._CanCreatePublic != nil { fields = append(fields, userpermissions.FieldCanCreatePublic) } + if m._CanEdit != nil { + fields = append(fields, userpermissions.FieldCanEdit) + } return fields } @@ -7499,14 +9233,18 @@ func (m *UserPermissionsMutation) Fields() []string { // schema. func (m *UserPermissionsMutation) Field(name string) (ent.Value, bool) { switch name { + case userpermissions.FieldCreateTime: + return m.CreateTime() + case userpermissions.FieldUpdateTime: + return m.UpdateTime() case userpermissions.FieldUserID: return m.UserID() - case userpermissions.FieldCanEdit: - return m.CanEdit() case userpermissions.FieldAdmin: return m.Admin() case userpermissions.FieldCanCreatePublic: return m.CanCreatePublic() + case userpermissions.FieldCanEdit: + return m.CanEdit() } return nil, false } @@ -7516,14 +9254,18 @@ func (m *UserPermissionsMutation) Field(name string) (ent.Value, bool) { // database failed. func (m *UserPermissionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { + case userpermissions.FieldCreateTime: + return m.OldCreateTime(ctx) + case userpermissions.FieldUpdateTime: + return m.OldUpdateTime(ctx) case userpermissions.FieldUserID: return m.OldUserID(ctx) - case userpermissions.FieldCanEdit: - return m.OldCanEdit(ctx) case userpermissions.FieldAdmin: return m.OldAdmin(ctx) case userpermissions.FieldCanCreatePublic: return m.OldCanCreatePublic(ctx) + case userpermissions.FieldCanEdit: + return m.OldCanEdit(ctx) } return nil, fmt.Errorf("unknown UserPermissions field %s", name) } @@ -7533,19 +9275,26 @@ func (m *UserPermissionsMutation) OldField(ctx context.Context, name string) (en // type. func (m *UserPermissionsMutation) SetField(name string, value ent.Value) error { switch name { - case userpermissions.FieldUserID: - v, ok := value.(ksuid.ID) + case userpermissions.FieldCreateTime: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetCreateTime(v) return nil - case userpermissions.FieldCanEdit: - v, ok := value.(bool) + case userpermissions.FieldUpdateTime: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCanEdit(v) + m.SetUpdateTime(v) + return nil + case userpermissions.FieldUserID: + v, ok := value.(ksuid.ID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) return nil case userpermissions.FieldAdmin: v, ok := value.(bool) @@ -7561,6 +9310,13 @@ func (m *UserPermissionsMutation) SetField(name string, value ent.Value) error { } m.SetCanCreatePublic(v) return nil + case userpermissions.FieldCanEdit: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCanEdit(v) + return nil } return fmt.Errorf("unknown UserPermissions field %s", name) } @@ -7619,18 +9375,24 @@ func (m *UserPermissionsMutation) ClearField(name string) error { // It returns an error if the field is not defined in the schema. func (m *UserPermissionsMutation) ResetField(name string) error { switch name { + case userpermissions.FieldCreateTime: + m.ResetCreateTime() + return nil + case userpermissions.FieldUpdateTime: + m.ResetUpdateTime() + return nil case userpermissions.FieldUserID: m.ResetUserID() return nil - case userpermissions.FieldCanEdit: - m.ResetCanEdit() - return nil case userpermissions.FieldAdmin: m.ResetAdmin() return nil case userpermissions.FieldCanCreatePublic: m.ResetCanCreatePublic() return nil + case userpermissions.FieldCanEdit: + m.ResetCanEdit() + return nil } return fmt.Errorf("unknown UserPermissions field %s", name) } diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go index a9f3bdea..c5abfb16 100644 --- a/internal/ent/predicate/predicate.go +++ b/internal/ent/predicate/predicate.go @@ -12,6 +12,9 @@ type Author func(*sql.Selector) // Book is the predicate function for book builders. type Book func(*sql.Selector) +// BookFile is the predicate function for bookfile builders. +type BookFile func(*sql.Selector) + // Identifier is the predicate function for identifier builders. type Identifier func(*sql.Selector) diff --git a/internal/ent/privacy/privacy.go b/internal/ent/privacy/privacy.go index 0c7c0348..bd510d8a 100644 --- a/internal/ent/privacy/privacy.go +++ b/internal/ent/privacy/privacy.go @@ -158,6 +158,30 @@ func (f BookMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BookMutation", m) } +// The BookFileQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type BookFileQueryRuleFunc func(context.Context, *ent.BookFileQuery) error + +// EvalQuery return f(ctx, q). +func (f BookFileQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.BookFileQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.BookFileQuery", q) +} + +// The BookFileMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type BookFileMutationRuleFunc func(context.Context, *ent.BookFileMutation) error + +// EvalMutation calls f(ctx, m). +func (f BookFileMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.BookFileMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.BookFileMutation", m) +} + // The IdentifierQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. type IdentifierQueryRuleFunc func(context.Context, *ent.IdentifierQuery) error @@ -413,6 +437,8 @@ func queryFilter(q ent.Query) (Filter, error) { return q.Filter(), nil case *ent.BookQuery: return q.Filter(), nil + case *ent.BookFileQuery: + return q.Filter(), nil case *ent.IdentifierQuery: return q.Filter(), nil case *ent.LanguageQuery: @@ -442,6 +468,8 @@ func mutationFilter(m ent.Mutation) (Filter, error) { return m.Filter(), nil case *ent.BookMutation: return m.Filter(), nil + case *ent.BookFileMutation: + return m.Filter(), nil case *ent.IdentifierMutation: return m.Filter(), nil case *ent.LanguageMutation: diff --git a/internal/ent/publisher.go b/internal/ent/publisher.go index 200385f6..94d86efd 100644 --- a/internal/ent/publisher.go +++ b/internal/ent/publisher.go @@ -7,6 +7,7 @@ import ( "lybbrio/internal/ent/publisher" "lybbrio/internal/ent/schema/ksuid" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -17,6 +18,10 @@ type Publisher struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Name holds the value of the "name" field. @@ -58,6 +63,8 @@ func (*Publisher) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case publisher.FieldID, publisher.FieldName: values[i] = new(sql.NullString) + case publisher.FieldCreateTime, publisher.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -79,6 +86,18 @@ func (pu *Publisher) assignValues(columns []string, values []any) error { } else if value.Valid { pu.ID = ksuid.ID(value.String) } + case publisher.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + pu.CreateTime = value.Time + } + case publisher.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + pu.UpdateTime = value.Time + } case publisher.FieldCalibreID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[i]) @@ -132,6 +151,12 @@ func (pu *Publisher) String() string { var builder strings.Builder builder.WriteString("Publisher(") builder.WriteString(fmt.Sprintf("id=%v, ", pu.ID)) + builder.WriteString("create_time=") + builder.WriteString(pu.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(pu.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", pu.CalibreID)) builder.WriteString(", ") diff --git a/internal/ent/publisher/publisher.go b/internal/ent/publisher/publisher.go index 1efbffd8..bedc8cdd 100644 --- a/internal/ent/publisher/publisher.go +++ b/internal/ent/publisher/publisher.go @@ -4,6 +4,7 @@ package publisher import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "publisher" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldName holds the string denoting the name field in the database. @@ -33,6 +38,8 @@ const ( // Columns holds all SQL columns for publisher fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldName, } @@ -61,6 +68,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error // DefaultID holds the default value on creation for the "id" field. @@ -75,6 +88,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() diff --git a/internal/ent/publisher/where.go b/internal/ent/publisher/where.go index 697000ef..ecdcaaf3 100644 --- a/internal/ent/publisher/where.go +++ b/internal/ent/publisher/where.go @@ -5,6 +5,7 @@ package publisher import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Publisher { return predicate.Publisher(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Publisher { return predicate.Publisher(sql.FieldEQ(FieldCalibreID, v)) @@ -65,6 +76,86 @@ func Name(v string) predicate.Publisher { return predicate.Publisher(sql.FieldEQ(FieldName, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Publisher { + return predicate.Publisher(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Publisher { return predicate.Publisher(sql.FieldEQ(FieldCalibreID, v)) diff --git a/internal/ent/publisher_create.go b/internal/ent/publisher_create.go index 942b5256..37394cba 100644 --- a/internal/ent/publisher_create.go +++ b/internal/ent/publisher_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/book" "lybbrio/internal/ent/publisher" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,6 +25,34 @@ type PublisherCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (pc *PublisherCreate) SetCreateTime(t time.Time) *PublisherCreate { + pc.mutation.SetCreateTime(t) + return pc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (pc *PublisherCreate) SetNillableCreateTime(t *time.Time) *PublisherCreate { + if t != nil { + pc.SetCreateTime(*t) + } + return pc +} + +// SetUpdateTime sets the "update_time" field. +func (pc *PublisherCreate) SetUpdateTime(t time.Time) *PublisherCreate { + pc.mutation.SetUpdateTime(t) + return pc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (pc *PublisherCreate) SetNillableUpdateTime(t *time.Time) *PublisherCreate { + if t != nil { + pc.SetUpdateTime(*t) + } + return pc +} + // SetCalibreID sets the "calibre_id" field. func (pc *PublisherCreate) SetCalibreID(i int64) *PublisherCreate { pc.mutation.SetCalibreID(i) @@ -110,6 +139,20 @@ func (pc *PublisherCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (pc *PublisherCreate) defaults() error { + if _, ok := pc.mutation.CreateTime(); !ok { + if publisher.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized publisher.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := publisher.DefaultCreateTime() + pc.mutation.SetCreateTime(v) + } + if _, ok := pc.mutation.UpdateTime(); !ok { + if publisher.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized publisher.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := publisher.DefaultUpdateTime() + pc.mutation.SetUpdateTime(v) + } if _, ok := pc.mutation.ID(); !ok { if publisher.DefaultID == nil { return fmt.Errorf("ent: uninitialized publisher.DefaultID (forgotten import ent/runtime?)") @@ -122,6 +165,12 @@ func (pc *PublisherCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (pc *PublisherCreate) check() error { + if _, ok := pc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Publisher.create_time"`)} + } + if _, ok := pc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Publisher.update_time"`)} + } if _, ok := pc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Publisher.name"`)} } @@ -166,6 +215,14 @@ func (pc *PublisherCreate) createSpec() (*Publisher, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := pc.mutation.CreateTime(); ok { + _spec.SetField(publisher.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := pc.mutation.UpdateTime(); ok { + _spec.SetField(publisher.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := pc.mutation.CalibreID(); ok { _spec.SetField(publisher.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -197,7 +254,7 @@ func (pc *PublisherCreate) createSpec() (*Publisher, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Publisher.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -206,7 +263,7 @@ func (pc *PublisherCreate) createSpec() (*Publisher, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.PublisherUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (pc *PublisherCreate) OnConflict(opts ...sql.ConflictOption) *PublisherUpsertOne { @@ -242,6 +299,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *PublisherUpsert) SetUpdateTime(v time.Time) *PublisherUpsert { + u.Set(publisher.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *PublisherUpsert) UpdateUpdateTime() *PublisherUpsert { + u.SetExcluded(publisher.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *PublisherUpsert) SetCalibreID(v int64) *PublisherUpsert { u.Set(publisher.FieldCalibreID, v) @@ -295,6 +364,9 @@ func (u *PublisherUpsertOne) UpdateNewValues() *PublisherUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(publisher.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(publisher.FieldCreateTime) + } })) return u } @@ -326,6 +398,20 @@ func (u *PublisherUpsertOne) Update(set func(*PublisherUpsert)) *PublisherUpsert return u } +// SetUpdateTime sets the "update_time" field. +func (u *PublisherUpsertOne) SetUpdateTime(v time.Time) *PublisherUpsertOne { + return u.Update(func(s *PublisherUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *PublisherUpsertOne) UpdateUpdateTime() *PublisherUpsertOne { + return u.Update(func(s *PublisherUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *PublisherUpsertOne) SetCalibreID(v int64) *PublisherUpsertOne { return u.Update(func(s *PublisherUpsert) { @@ -504,7 +590,7 @@ func (pcb *PublisherCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.PublisherUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (pcb *PublisherCreateBulk) OnConflict(opts ...sql.ConflictOption) *PublisherUpsertBulk { @@ -551,6 +637,9 @@ func (u *PublisherUpsertBulk) UpdateNewValues() *PublisherUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(publisher.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(publisher.FieldCreateTime) + } } })) return u @@ -583,6 +672,20 @@ func (u *PublisherUpsertBulk) Update(set func(*PublisherUpsert)) *PublisherUpser return u } +// SetUpdateTime sets the "update_time" field. +func (u *PublisherUpsertBulk) SetUpdateTime(v time.Time) *PublisherUpsertBulk { + return u.Update(func(s *PublisherUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *PublisherUpsertBulk) UpdateUpdateTime() *PublisherUpsertBulk { + return u.Update(func(s *PublisherUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *PublisherUpsertBulk) SetCalibreID(v int64) *PublisherUpsertBulk { return u.Update(func(s *PublisherUpsert) { diff --git a/internal/ent/publisher_query.go b/internal/ent/publisher_query.go index ddcadf76..4cebaf47 100644 --- a/internal/ent/publisher_query.go +++ b/internal/ent/publisher_query.go @@ -303,12 +303,12 @@ func (pq *PublisherQuery) WithBooks(opts ...func(*BookQuery)) *PublisherQuery { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Publisher.Query(). -// GroupBy(publisher.FieldCalibreID). +// GroupBy(publisher.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (pq *PublisherQuery) GroupBy(field string, fields ...string) *PublisherGroupBy { @@ -326,11 +326,11 @@ func (pq *PublisherQuery) GroupBy(field string, fields ...string) *PublisherGrou // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Publisher.Query(). -// Select(publisher.FieldCalibreID). +// Select(publisher.FieldCreateTime). // Scan(ctx, &v) func (pq *PublisherQuery) Select(fields ...string) *PublisherSelect { pq.ctx.Fields = append(pq.ctx.Fields, fields...) diff --git a/internal/ent/publisher_update.go b/internal/ent/publisher_update.go index 2cd65276..a2f4c7d7 100644 --- a/internal/ent/publisher_update.go +++ b/internal/ent/publisher_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/publisher" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (pu *PublisherUpdate) Where(ps ...predicate.Publisher) *PublisherUpdate { return pu } +// SetUpdateTime sets the "update_time" field. +func (pu *PublisherUpdate) SetUpdateTime(t time.Time) *PublisherUpdate { + pu.mutation.SetUpdateTime(t) + return pu +} + // SetCalibreID sets the "calibre_id" field. func (pu *PublisherUpdate) SetCalibreID(i int64) *PublisherUpdate { pu.mutation.ResetCalibreID() @@ -113,6 +120,9 @@ func (pu *PublisherUpdate) RemoveBooks(b ...*Book) *PublisherUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PublisherUpdate) Save(ctx context.Context) (int, error) { + if err := pu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) } @@ -138,6 +148,18 @@ func (pu *PublisherUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (pu *PublisherUpdate) defaults() error { + if _, ok := pu.mutation.UpdateTime(); !ok { + if publisher.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized publisher.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := publisher.UpdateDefaultUpdateTime() + pu.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (pu *PublisherUpdate) check() error { if v, ok := pu.mutation.Name(); ok { @@ -160,6 +182,9 @@ func (pu *PublisherUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := pu.mutation.UpdateTime(); ok { + _spec.SetField(publisher.FieldUpdateTime, field.TypeTime, value) + } if value, ok := pu.mutation.CalibreID(); ok { _spec.SetField(publisher.FieldCalibreID, field.TypeInt64, value) } @@ -237,6 +262,12 @@ type PublisherUpdateOne struct { mutation *PublisherMutation } +// SetUpdateTime sets the "update_time" field. +func (puo *PublisherUpdateOne) SetUpdateTime(t time.Time) *PublisherUpdateOne { + puo.mutation.SetUpdateTime(t) + return puo +} + // SetCalibreID sets the "calibre_id" field. func (puo *PublisherUpdateOne) SetCalibreID(i int64) *PublisherUpdateOne { puo.mutation.ResetCalibreID() @@ -334,6 +365,9 @@ func (puo *PublisherUpdateOne) Select(field string, fields ...string) *Publisher // Save executes the query and returns the updated Publisher entity. func (puo *PublisherUpdateOne) Save(ctx context.Context) (*Publisher, error) { + if err := puo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) } @@ -359,6 +393,18 @@ func (puo *PublisherUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (puo *PublisherUpdateOne) defaults() error { + if _, ok := puo.mutation.UpdateTime(); !ok { + if publisher.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized publisher.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := publisher.UpdateDefaultUpdateTime() + puo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (puo *PublisherUpdateOne) check() error { if v, ok := puo.mutation.Name(); ok { @@ -398,6 +444,9 @@ func (puo *PublisherUpdateOne) sqlSave(ctx context.Context) (_node *Publisher, e } } } + if value, ok := puo.mutation.UpdateTime(); ok { + _spec.SetField(publisher.FieldUpdateTime, field.TypeTime, value) + } if value, ok := puo.mutation.CalibreID(); ok { _spec.SetField(publisher.FieldCalibreID, field.TypeInt64, value) } diff --git a/internal/ent/runtime/runtime.go b/internal/ent/runtime/runtime.go index 9f2b9565..ef337d72 100644 --- a/internal/ent/runtime/runtime.go +++ b/internal/ent/runtime/runtime.go @@ -6,6 +6,7 @@ import ( "context" "lybbrio/internal/ent/author" "lybbrio/internal/ent/book" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/identifier" "lybbrio/internal/ent/language" "lybbrio/internal/ent/publisher" @@ -28,7 +29,7 @@ import ( // to their package variables. func init() { authorMixin := schema.Author{}.Mixin() - author.Policy = privacy.NewPolicies(authorMixin[0], schema.Author{}) + author.Policy = privacy.NewPolicies(authorMixin[1], schema.Author{}) author.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := author.Policy.EvalMutation(ctx, m); err != nil { @@ -37,20 +38,32 @@ func init() { return next.Mutate(ctx, m) }) } - authorMixinFields2 := authorMixin[2].Fields() - _ = authorMixinFields2 + authorMixinFields0 := authorMixin[0].Fields() + _ = authorMixinFields0 + authorMixinFields3 := authorMixin[3].Fields() + _ = authorMixinFields3 authorFields := schema.Author{}.Fields() _ = authorFields + // authorDescCreateTime is the schema descriptor for create_time field. + authorDescCreateTime := authorMixinFields0[0].Descriptor() + // author.DefaultCreateTime holds the default value on creation for the create_time field. + author.DefaultCreateTime = authorDescCreateTime.Default.(func() time.Time) + // authorDescUpdateTime is the schema descriptor for update_time field. + authorDescUpdateTime := authorMixinFields0[1].Descriptor() + // author.DefaultUpdateTime holds the default value on creation for the update_time field. + author.DefaultUpdateTime = authorDescUpdateTime.Default.(func() time.Time) + // author.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + author.UpdateDefaultUpdateTime = authorDescUpdateTime.UpdateDefault.(func() time.Time) // authorDescName is the schema descriptor for name field. authorDescName := authorFields[0].Descriptor() // author.NameValidator is a validator for the "name" field. It is called by the builders before save. author.NameValidator = authorDescName.Validators[0].(func(string) error) // authorDescID is the schema descriptor for id field. - authorDescID := authorMixinFields2[0].Descriptor() + authorDescID := authorMixinFields3[0].Descriptor() // author.DefaultID holds the default value on creation for the id field. author.DefaultID = authorDescID.Default.(func() ksuid.ID) bookMixin := schema.Book{}.Mixin() - book.Policy = privacy.NewPolicies(bookMixin[0], schema.Book{}) + book.Policy = privacy.NewPolicies(bookMixin[1], schema.Book{}) book.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := book.Policy.EvalMutation(ctx, m); err != nil { @@ -59,10 +72,22 @@ func init() { return next.Mutate(ctx, m) }) } - bookMixinFields2 := bookMixin[2].Fields() - _ = bookMixinFields2 + bookMixinFields0 := bookMixin[0].Fields() + _ = bookMixinFields0 + bookMixinFields3 := bookMixin[3].Fields() + _ = bookMixinFields3 bookFields := schema.Book{}.Fields() _ = bookFields + // bookDescCreateTime is the schema descriptor for create_time field. + bookDescCreateTime := bookMixinFields0[0].Descriptor() + // book.DefaultCreateTime holds the default value on creation for the create_time field. + book.DefaultCreateTime = bookDescCreateTime.Default.(func() time.Time) + // bookDescUpdateTime is the schema descriptor for update_time field. + bookDescUpdateTime := bookMixinFields0[1].Descriptor() + // book.DefaultUpdateTime holds the default value on creation for the update_time field. + book.DefaultUpdateTime = bookDescUpdateTime.Default.(func() time.Time) + // book.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + book.UpdateDefaultUpdateTime = bookDescUpdateTime.UpdateDefault.(func() time.Time) // bookDescTitle is the schema descriptor for title field. bookDescTitle := bookFields[0].Descriptor() // book.TitleValidator is a validator for the "title" field. It is called by the builders before save. @@ -72,11 +97,53 @@ func init() { // book.PathValidator is a validator for the "path" field. It is called by the builders before save. book.PathValidator = bookDescPath.Validators[0].(func(string) error) // bookDescID is the schema descriptor for id field. - bookDescID := bookMixinFields2[0].Descriptor() + bookDescID := bookMixinFields3[0].Descriptor() // book.DefaultID holds the default value on creation for the id field. book.DefaultID = bookDescID.Default.(func() ksuid.ID) + bookfileMixin := schema.BookFile{}.Mixin() + bookfile.Policy = privacy.NewPolicies(bookfileMixin[1], schema.BookFile{}) + bookfile.Hooks[0] = func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if err := bookfile.Policy.EvalMutation(ctx, m); err != nil { + return nil, err + } + return next.Mutate(ctx, m) + }) + } + bookfileMixinFields0 := bookfileMixin[0].Fields() + _ = bookfileMixinFields0 + bookfileMixinFields2 := bookfileMixin[2].Fields() + _ = bookfileMixinFields2 + bookfileFields := schema.BookFile{}.Fields() + _ = bookfileFields + // bookfileDescCreateTime is the schema descriptor for create_time field. + bookfileDescCreateTime := bookfileMixinFields0[0].Descriptor() + // bookfile.DefaultCreateTime holds the default value on creation for the create_time field. + bookfile.DefaultCreateTime = bookfileDescCreateTime.Default.(func() time.Time) + // bookfileDescUpdateTime is the schema descriptor for update_time field. + bookfileDescUpdateTime := bookfileMixinFields0[1].Descriptor() + // bookfile.DefaultUpdateTime holds the default value on creation for the update_time field. + bookfile.DefaultUpdateTime = bookfileDescUpdateTime.Default.(func() time.Time) + // bookfile.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + bookfile.UpdateDefaultUpdateTime = bookfileDescUpdateTime.UpdateDefault.(func() time.Time) + // bookfileDescName is the schema descriptor for name field. + bookfileDescName := bookfileFields[0].Descriptor() + // bookfile.NameValidator is a validator for the "name" field. It is called by the builders before save. + bookfile.NameValidator = bookfileDescName.Validators[0].(func(string) error) + // bookfileDescPath is the schema descriptor for path field. + bookfileDescPath := bookfileFields[1].Descriptor() + // bookfile.PathValidator is a validator for the "path" field. It is called by the builders before save. + bookfile.PathValidator = bookfileDescPath.Validators[0].(func(string) error) + // bookfileDescSize is the schema descriptor for size field. + bookfileDescSize := bookfileFields[2].Descriptor() + // bookfile.SizeValidator is a validator for the "size" field. It is called by the builders before save. + bookfile.SizeValidator = bookfileDescSize.Validators[0].(func(int64) error) + // bookfileDescID is the schema descriptor for id field. + bookfileDescID := bookfileMixinFields2[0].Descriptor() + // bookfile.DefaultID holds the default value on creation for the id field. + bookfile.DefaultID = bookfileDescID.Default.(func() ksuid.ID) identifierMixin := schema.Identifier{}.Mixin() - identifier.Policy = privacy.NewPolicies(identifierMixin[0], schema.Identifier{}) + identifier.Policy = privacy.NewPolicies(identifierMixin[1], schema.Identifier{}) identifier.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := identifier.Policy.EvalMutation(ctx, m); err != nil { @@ -85,10 +152,22 @@ func init() { return next.Mutate(ctx, m) }) } - identifierMixinFields2 := identifierMixin[2].Fields() - _ = identifierMixinFields2 + identifierMixinFields0 := identifierMixin[0].Fields() + _ = identifierMixinFields0 + identifierMixinFields3 := identifierMixin[3].Fields() + _ = identifierMixinFields3 identifierFields := schema.Identifier{}.Fields() _ = identifierFields + // identifierDescCreateTime is the schema descriptor for create_time field. + identifierDescCreateTime := identifierMixinFields0[0].Descriptor() + // identifier.DefaultCreateTime holds the default value on creation for the create_time field. + identifier.DefaultCreateTime = identifierDescCreateTime.Default.(func() time.Time) + // identifierDescUpdateTime is the schema descriptor for update_time field. + identifierDescUpdateTime := identifierMixinFields0[1].Descriptor() + // identifier.DefaultUpdateTime holds the default value on creation for the update_time field. + identifier.DefaultUpdateTime = identifierDescUpdateTime.Default.(func() time.Time) + // identifier.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + identifier.UpdateDefaultUpdateTime = identifierDescUpdateTime.UpdateDefault.(func() time.Time) // identifierDescType is the schema descriptor for type field. identifierDescType := identifierFields[0].Descriptor() // identifier.TypeValidator is a validator for the "type" field. It is called by the builders before save. @@ -98,11 +177,11 @@ func init() { // identifier.ValueValidator is a validator for the "value" field. It is called by the builders before save. identifier.ValueValidator = identifierDescValue.Validators[0].(func(string) error) // identifierDescID is the schema descriptor for id field. - identifierDescID := identifierMixinFields2[0].Descriptor() + identifierDescID := identifierMixinFields3[0].Descriptor() // identifier.DefaultID holds the default value on creation for the id field. identifier.DefaultID = identifierDescID.Default.(func() ksuid.ID) languageMixin := schema.Language{}.Mixin() - language.Policy = privacy.NewPolicies(languageMixin[0], schema.Language{}) + language.Policy = privacy.NewPolicies(languageMixin[1], schema.Language{}) language.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := language.Policy.EvalMutation(ctx, m); err != nil { @@ -111,20 +190,32 @@ func init() { return next.Mutate(ctx, m) }) } - languageMixinFields2 := languageMixin[2].Fields() - _ = languageMixinFields2 + languageMixinFields0 := languageMixin[0].Fields() + _ = languageMixinFields0 + languageMixinFields3 := languageMixin[3].Fields() + _ = languageMixinFields3 languageFields := schema.Language{}.Fields() _ = languageFields + // languageDescCreateTime is the schema descriptor for create_time field. + languageDescCreateTime := languageMixinFields0[0].Descriptor() + // language.DefaultCreateTime holds the default value on creation for the create_time field. + language.DefaultCreateTime = languageDescCreateTime.Default.(func() time.Time) + // languageDescUpdateTime is the schema descriptor for update_time field. + languageDescUpdateTime := languageMixinFields0[1].Descriptor() + // language.DefaultUpdateTime holds the default value on creation for the update_time field. + language.DefaultUpdateTime = languageDescUpdateTime.Default.(func() time.Time) + // language.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + language.UpdateDefaultUpdateTime = languageDescUpdateTime.UpdateDefault.(func() time.Time) // languageDescCode is the schema descriptor for code field. languageDescCode := languageFields[0].Descriptor() // language.CodeValidator is a validator for the "code" field. It is called by the builders before save. language.CodeValidator = languageDescCode.Validators[0].(func(string) error) // languageDescID is the schema descriptor for id field. - languageDescID := languageMixinFields2[0].Descriptor() + languageDescID := languageMixinFields3[0].Descriptor() // language.DefaultID holds the default value on creation for the id field. language.DefaultID = languageDescID.Default.(func() ksuid.ID) publisherMixin := schema.Publisher{}.Mixin() - publisher.Policy = privacy.NewPolicies(publisherMixin[0], schema.Publisher{}) + publisher.Policy = privacy.NewPolicies(publisherMixin[1], schema.Publisher{}) publisher.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := publisher.Policy.EvalMutation(ctx, m); err != nil { @@ -133,20 +224,32 @@ func init() { return next.Mutate(ctx, m) }) } - publisherMixinFields2 := publisherMixin[2].Fields() - _ = publisherMixinFields2 + publisherMixinFields0 := publisherMixin[0].Fields() + _ = publisherMixinFields0 + publisherMixinFields3 := publisherMixin[3].Fields() + _ = publisherMixinFields3 publisherFields := schema.Publisher{}.Fields() _ = publisherFields + // publisherDescCreateTime is the schema descriptor for create_time field. + publisherDescCreateTime := publisherMixinFields0[0].Descriptor() + // publisher.DefaultCreateTime holds the default value on creation for the create_time field. + publisher.DefaultCreateTime = publisherDescCreateTime.Default.(func() time.Time) + // publisherDescUpdateTime is the schema descriptor for update_time field. + publisherDescUpdateTime := publisherMixinFields0[1].Descriptor() + // publisher.DefaultUpdateTime holds the default value on creation for the update_time field. + publisher.DefaultUpdateTime = publisherDescUpdateTime.Default.(func() time.Time) + // publisher.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + publisher.UpdateDefaultUpdateTime = publisherDescUpdateTime.UpdateDefault.(func() time.Time) // publisherDescName is the schema descriptor for name field. publisherDescName := publisherFields[0].Descriptor() // publisher.NameValidator is a validator for the "name" field. It is called by the builders before save. publisher.NameValidator = publisherDescName.Validators[0].(func(string) error) // publisherDescID is the schema descriptor for id field. - publisherDescID := publisherMixinFields2[0].Descriptor() + publisherDescID := publisherMixinFields3[0].Descriptor() // publisher.DefaultID holds the default value on creation for the id field. publisher.DefaultID = publisherDescID.Default.(func() ksuid.ID) seriesMixin := schema.Series{}.Mixin() - series.Policy = privacy.NewPolicies(seriesMixin[0], schema.Series{}) + series.Policy = privacy.NewPolicies(seriesMixin[1], schema.Series{}) series.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := series.Policy.EvalMutation(ctx, m); err != nil { @@ -155,10 +258,22 @@ func init() { return next.Mutate(ctx, m) }) } - seriesMixinFields2 := seriesMixin[2].Fields() - _ = seriesMixinFields2 + seriesMixinFields0 := seriesMixin[0].Fields() + _ = seriesMixinFields0 + seriesMixinFields3 := seriesMixin[3].Fields() + _ = seriesMixinFields3 seriesFields := schema.Series{}.Fields() _ = seriesFields + // seriesDescCreateTime is the schema descriptor for create_time field. + seriesDescCreateTime := seriesMixinFields0[0].Descriptor() + // series.DefaultCreateTime holds the default value on creation for the create_time field. + series.DefaultCreateTime = seriesDescCreateTime.Default.(func() time.Time) + // seriesDescUpdateTime is the schema descriptor for update_time field. + seriesDescUpdateTime := seriesMixinFields0[1].Descriptor() + // series.DefaultUpdateTime holds the default value on creation for the update_time field. + series.DefaultUpdateTime = seriesDescUpdateTime.Default.(func() time.Time) + // series.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + series.UpdateDefaultUpdateTime = seriesDescUpdateTime.UpdateDefault.(func() time.Time) // seriesDescName is the schema descriptor for name field. seriesDescName := seriesFields[0].Descriptor() // series.NameValidator is a validator for the "name" field. It is called by the builders before save. @@ -168,11 +283,11 @@ func init() { // series.SortValidator is a validator for the "sort" field. It is called by the builders before save. series.SortValidator = seriesDescSort.Validators[0].(func(string) error) // seriesDescID is the schema descriptor for id field. - seriesDescID := seriesMixinFields2[0].Descriptor() + seriesDescID := seriesMixinFields3[0].Descriptor() // series.DefaultID holds the default value on creation for the id field. series.DefaultID = seriesDescID.Default.(func() ksuid.ID) shelfMixin := schema.Shelf{}.Mixin() - shelf.Policy = privacy.NewPolicies(shelfMixin[0], shelfMixin[1], schema.Shelf{}) + shelf.Policy = privacy.NewPolicies(shelfMixin[1], shelfMixin[2], schema.Shelf{}) shelf.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := shelf.Policy.EvalMutation(ctx, m); err != nil { @@ -181,14 +296,26 @@ func init() { return next.Mutate(ctx, m) }) } - shelfMixinFields1 := shelfMixin[1].Fields() - _ = shelfMixinFields1 + shelfMixinFields0 := shelfMixin[0].Fields() + _ = shelfMixinFields0 shelfMixinFields2 := shelfMixin[2].Fields() _ = shelfMixinFields2 + shelfMixinFields3 := shelfMixin[3].Fields() + _ = shelfMixinFields3 shelfFields := schema.Shelf{}.Fields() _ = shelfFields + // shelfDescCreateTime is the schema descriptor for create_time field. + shelfDescCreateTime := shelfMixinFields0[0].Descriptor() + // shelf.DefaultCreateTime holds the default value on creation for the create_time field. + shelf.DefaultCreateTime = shelfDescCreateTime.Default.(func() time.Time) + // shelfDescUpdateTime is the schema descriptor for update_time field. + shelfDescUpdateTime := shelfMixinFields0[1].Descriptor() + // shelf.DefaultUpdateTime holds the default value on creation for the update_time field. + shelf.DefaultUpdateTime = shelfDescUpdateTime.Default.(func() time.Time) + // shelf.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + shelf.UpdateDefaultUpdateTime = shelfDescUpdateTime.UpdateDefault.(func() time.Time) // shelfDescPublic is the schema descriptor for public field. - shelfDescPublic := shelfMixinFields1[0].Descriptor() + shelfDescPublic := shelfMixinFields2[0].Descriptor() // shelf.DefaultPublic holds the default value on creation for the public field. shelf.DefaultPublic = shelfDescPublic.Default.(bool) // shelfDescName is the schema descriptor for name field. @@ -196,7 +323,7 @@ func init() { // shelf.NameValidator is a validator for the "name" field. It is called by the builders before save. shelf.NameValidator = shelfDescName.Validators[0].(func(string) error) // shelfDescID is the schema descriptor for id field. - shelfDescID := shelfMixinFields2[0].Descriptor() + shelfDescID := shelfMixinFields3[0].Descriptor() // shelf.DefaultID holds the default value on creation for the id field. shelf.DefaultID = shelfDescID.Default.(func() ksuid.ID) tagMixin := schema.Tag{}.Mixin() @@ -260,7 +387,7 @@ func init() { // task.DefaultID holds the default value on creation for the id field. task.DefaultID = taskDescID.Default.(func() ksuid.ID) userMixin := schema.User{}.Mixin() - user.Policy = privacy.NewPolicies(userMixin[0], schema.User{}) + user.Policy = privacy.NewPolicies(userMixin[1], schema.User{}) user.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := user.Policy.EvalMutation(ctx, m); err != nil { @@ -269,10 +396,22 @@ func init() { return next.Mutate(ctx, m) }) } - userMixinFields1 := userMixin[1].Fields() - _ = userMixinFields1 + userMixinFields0 := userMixin[0].Fields() + _ = userMixinFields0 + userMixinFields2 := userMixin[2].Fields() + _ = userMixinFields2 userFields := schema.User{}.Fields() _ = userFields + // userDescCreateTime is the schema descriptor for create_time field. + userDescCreateTime := userMixinFields0[0].Descriptor() + // user.DefaultCreateTime holds the default value on creation for the create_time field. + user.DefaultCreateTime = userDescCreateTime.Default.(func() time.Time) + // userDescUpdateTime is the schema descriptor for update_time field. + userDescUpdateTime := userMixinFields0[1].Descriptor() + // user.DefaultUpdateTime holds the default value on creation for the update_time field. + user.DefaultUpdateTime = userDescUpdateTime.Default.(func() time.Time) + // user.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + user.UpdateDefaultUpdateTime = userDescUpdateTime.UpdateDefault.(func() time.Time) // userDescUsername is the schema descriptor for username field. userDescUsername := userFields[0].Descriptor() // user.UsernameValidator is a validator for the "username" field. It is called by the builders before save. @@ -282,11 +421,11 @@ func init() { // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. user.EmailValidator = userDescEmail.Validators[0].(func(string) error) // userDescID is the schema descriptor for id field. - userDescID := userMixinFields1[0].Descriptor() + userDescID := userMixinFields2[0].Descriptor() // user.DefaultID holds the default value on creation for the id field. user.DefaultID = userDescID.Default.(func() ksuid.ID) userpermissionsMixin := schema.UserPermissions{}.Mixin() - userpermissions.Policy = privacy.NewPolicies(userpermissionsMixin[0], schema.UserPermissions{}) + userpermissions.Policy = privacy.NewPolicies(userpermissionsMixin[1], schema.UserPermissions{}) userpermissions.Hooks[0] = func(next ent.Mutator) ent.Mutator { return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { if err := userpermissions.Policy.EvalMutation(ctx, m); err != nil { @@ -295,24 +434,36 @@ func init() { return next.Mutate(ctx, m) }) } - userpermissionsMixinFields1 := userpermissionsMixin[1].Fields() - _ = userpermissionsMixinFields1 + userpermissionsMixinFields0 := userpermissionsMixin[0].Fields() + _ = userpermissionsMixinFields0 + userpermissionsMixinFields2 := userpermissionsMixin[2].Fields() + _ = userpermissionsMixinFields2 userpermissionsFields := schema.UserPermissions{}.Fields() _ = userpermissionsFields - // userpermissionsDescCanEdit is the schema descriptor for CanEdit field. - userpermissionsDescCanEdit := userpermissionsFields[1].Descriptor() - // userpermissions.DefaultCanEdit holds the default value on creation for the CanEdit field. - userpermissions.DefaultCanEdit = userpermissionsDescCanEdit.Default.(bool) + // userpermissionsDescCreateTime is the schema descriptor for create_time field. + userpermissionsDescCreateTime := userpermissionsMixinFields0[0].Descriptor() + // userpermissions.DefaultCreateTime holds the default value on creation for the create_time field. + userpermissions.DefaultCreateTime = userpermissionsDescCreateTime.Default.(func() time.Time) + // userpermissionsDescUpdateTime is the schema descriptor for update_time field. + userpermissionsDescUpdateTime := userpermissionsMixinFields0[1].Descriptor() + // userpermissions.DefaultUpdateTime holds the default value on creation for the update_time field. + userpermissions.DefaultUpdateTime = userpermissionsDescUpdateTime.Default.(func() time.Time) + // userpermissions.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + userpermissions.UpdateDefaultUpdateTime = userpermissionsDescUpdateTime.UpdateDefault.(func() time.Time) // userpermissionsDescAdmin is the schema descriptor for Admin field. - userpermissionsDescAdmin := userpermissionsFields[2].Descriptor() + userpermissionsDescAdmin := userpermissionsFields[1].Descriptor() // userpermissions.DefaultAdmin holds the default value on creation for the Admin field. userpermissions.DefaultAdmin = userpermissionsDescAdmin.Default.(bool) // userpermissionsDescCanCreatePublic is the schema descriptor for CanCreatePublic field. - userpermissionsDescCanCreatePublic := userpermissionsFields[3].Descriptor() + userpermissionsDescCanCreatePublic := userpermissionsFields[2].Descriptor() // userpermissions.DefaultCanCreatePublic holds the default value on creation for the CanCreatePublic field. userpermissions.DefaultCanCreatePublic = userpermissionsDescCanCreatePublic.Default.(bool) + // userpermissionsDescCanEdit is the schema descriptor for CanEdit field. + userpermissionsDescCanEdit := userpermissionsFields[3].Descriptor() + // userpermissions.DefaultCanEdit holds the default value on creation for the CanEdit field. + userpermissions.DefaultCanEdit = userpermissionsDescCanEdit.Default.(bool) // userpermissionsDescID is the schema descriptor for id field. - userpermissionsDescID := userpermissionsMixinFields1[0].Descriptor() + userpermissionsDescID := userpermissionsMixinFields2[0].Descriptor() // userpermissions.DefaultID holds the default value on creation for the id field. userpermissions.DefaultID = userpermissionsDescID.Default.(func() ksuid.ID) } diff --git a/internal/ent/schema/author.go b/internal/ent/schema/author.go index a158ca4c..044d1f41 100644 --- a/internal/ent/schema/author.go +++ b/internal/ent/schema/author.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Author holds the schema definition for the Author entity. @@ -27,6 +28,7 @@ func (Author) Annotations() []schema.Annotation { func (Author) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("atr"), diff --git a/internal/ent/schema/book.go b/internal/ent/schema/book.go index 5fa86773..c462902e 100644 --- a/internal/ent/schema/book.go +++ b/internal/ent/schema/book.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Book holds the schema definition for the Book entity. @@ -27,6 +28,7 @@ func (Book) Annotations() []schema.Annotation { func (Book) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("bok"), @@ -74,6 +76,11 @@ func (Book) Edges() []ent.Edge { Ref("books"), edge.From("shelf", Shelf.Type). Ref("books"), // TODO: will need privacy on this edge. + edge.From("files", BookFile.Type). + Ref("book"). + Annotations( + entgql.OrderField("FILES_COUNT"), + ), } } diff --git a/internal/ent/schema/bookfile.go b/internal/ent/schema/bookfile.go new file mode 100644 index 00000000..ef6cb093 --- /dev/null +++ b/internal/ent/schema/bookfile.go @@ -0,0 +1,61 @@ +package schema + +import ( + "lybbrio/internal/ent/schema/filetype" + "lybbrio/internal/ent/schema/ksuid" + + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" +) + +// BookFile holds the schema definition for the BookFile entity. +type BookFile struct { + ent.Schema +} + +func (BookFile) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.QueryField(), + } +} + +func (BookFile) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + BaseMixin{}, + ksuid.MixinWithPrefix("fil"), + } +} + +// Fields of the BookFile. +func (BookFile) Fields() []ent.Field { + ret := []ent.Field{ + field.Text("name"). + NotEmpty(), + field.Text("path"). + NotEmpty(). + Unique(), + field.Int64("size"). + Positive(). + Comment("Size in bytes"), + } + values := []string{} + for _, format := range filetype.All() { + values = append(values, format.String()) + } + return append(ret, field.Enum("format"). + Values(values...)) +} + +// Edges of the BookFile. +func (BookFile) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("book", Book.Type). + Unique(). + Required(), + } +} diff --git a/internal/ent/schema/filetype/filetype.go b/internal/ent/schema/filetype/filetype.go new file mode 100644 index 00000000..5b14168f --- /dev/null +++ b/internal/ent/schema/filetype/filetype.go @@ -0,0 +1,54 @@ +package filetype + +import "strings" + +type FileType int + +const ( + Unknown FileType = iota + EPUB + KEPUB + // AZW3 + // PDF + // CBC + // CBR + // CB7 + // CBZ + // CBT + + count // Keep this at the end. +) + +func (f FileType) String() string { + switch f { + case EPUB: + return "EPUB" + case KEPUB: + return "KEPUB" + } + return "" +} + +func FromString(s string) FileType { + switch s { + case EPUB.String(): + return EPUB + case KEPUB.String(): + return KEPUB + default: + return Unknown + } +} + +func FromExtension(s string) FileType { + s = strings.Replace(strings.ToUpper(s), ".", "", 1) + return FromString(s) +} + +func All() []FileType { + ret := make([]FileType, 0, count) + for i := EPUB; i < count; i++ { + ret = append(ret, i) + } + return ret +} diff --git a/internal/ent/schema/identifier.go b/internal/ent/schema/identifier.go index d90789a0..637bf6d8 100644 --- a/internal/ent/schema/identifier.go +++ b/internal/ent/schema/identifier.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Identifier holds the schema definition for the Identifier entity. @@ -27,6 +28,7 @@ func (Identifier) Annotations() []schema.Annotation { func (Identifier) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("idn"), diff --git a/internal/ent/schema/language.go b/internal/ent/schema/language.go index bbf83fa9..0fd2103d 100644 --- a/internal/ent/schema/language.go +++ b/internal/ent/schema/language.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Language holds the schema definition for the Language entity. @@ -27,6 +28,7 @@ func (Language) Annotations() []schema.Annotation { func (Language) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("lng"), diff --git a/internal/ent/schema/mixin.go b/internal/ent/schema/mixin.go index 88bdf6f4..766e48bb 100644 --- a/internal/ent/schema/mixin.go +++ b/internal/ent/schema/mixin.go @@ -33,12 +33,6 @@ func (BaseMixin) Policy() ent.Policy { } } -func (BaseMixin) Mixin() []ent.Mixin { - return []ent.Mixin{ - mixin.Time{}, - } -} - type UserScopedMixin struct { mixin.Schema } diff --git a/internal/ent/schema/publisher.go b/internal/ent/schema/publisher.go index 1d29d1e9..e427c055 100644 --- a/internal/ent/schema/publisher.go +++ b/internal/ent/schema/publisher.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Publisher holds the schema definition for the Publisher entity. @@ -27,6 +28,7 @@ func (Publisher) Annotations() []schema.Annotation { func (Publisher) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("pub"), diff --git a/internal/ent/schema/series.go b/internal/ent/schema/series.go index b3341aba..c1ed6013 100644 --- a/internal/ent/schema/series.go +++ b/internal/ent/schema/series.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Series holds the schema definition for the Series entity. @@ -27,6 +28,7 @@ func (Series) Annotations() []schema.Annotation { func (Series) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, CalibreMixin{}, ksuid.MixinWithPrefix("srs"), diff --git a/internal/ent/schema/shelf.go b/internal/ent/schema/shelf.go index 1b68fd91..5d828be9 100644 --- a/internal/ent/schema/shelf.go +++ b/internal/ent/schema/shelf.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // Shelf holds the schema definition for the Shelf entity. @@ -28,6 +29,7 @@ func (Shelf) Annotations() []schema.Annotation { func (Shelf) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, PublicableUserScopedMixin{}, ksuid.MixinWithPrefix("shf"), diff --git a/internal/ent/schema/user.go b/internal/ent/schema/user.go index ef8d592c..1a910512 100644 --- a/internal/ent/schema/user.go +++ b/internal/ent/schema/user.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" ) // User holds the schema definition for the User entity. @@ -29,6 +30,7 @@ func (User) Annotations() []schema.Annotation { func (User) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, ksuid.MixinWithPrefix("usr"), } diff --git a/internal/ent/schema/userpermissions.go b/internal/ent/schema/userpermissions.go index 9fb2ebd2..c727a1dd 100644 --- a/internal/ent/schema/userpermissions.go +++ b/internal/ent/schema/userpermissions.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" ) // UserPermissions holds the schema definition for the UserPermissions entity. @@ -18,6 +19,7 @@ type UserPermissions struct { func (UserPermissions) Mixin() []ent.Mixin { return []ent.Mixin{ + mixin.Time{}, BaseMixin{}, ksuid.MixinWithPrefix("prm"), } diff --git a/internal/ent/series.go b/internal/ent/series.go index bbe722fb..b69b286f 100644 --- a/internal/ent/series.go +++ b/internal/ent/series.go @@ -7,6 +7,7 @@ import ( "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/series" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -17,6 +18,10 @@ type Series struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // CalibreID holds the value of the "calibre_id" field. CalibreID int64 `json:"calibre_id,omitempty"` // Name holds the value of the "name" field. @@ -60,6 +65,8 @@ func (*Series) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case series.FieldID, series.FieldName, series.FieldSort: values[i] = new(sql.NullString) + case series.FieldCreateTime, series.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -81,6 +88,18 @@ func (s *Series) assignValues(columns []string, values []any) error { } else if value.Valid { s.ID = ksuid.ID(value.String) } + case series.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + s.CreateTime = value.Time + } + case series.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + s.UpdateTime = value.Time + } case series.FieldCalibreID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field calibre_id", values[i]) @@ -140,6 +159,12 @@ func (s *Series) String() string { var builder strings.Builder builder.WriteString("Series(") builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString("create_time=") + builder.WriteString(s.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(s.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("calibre_id=") builder.WriteString(fmt.Sprintf("%v", s.CalibreID)) builder.WriteString(", ") diff --git a/internal/ent/series/series.go b/internal/ent/series/series.go index c2688468..efa8109d 100644 --- a/internal/ent/series/series.go +++ b/internal/ent/series/series.go @@ -4,6 +4,7 @@ package series import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "series" // 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" // FieldCalibreID holds the string denoting the calibre_id field in the database. FieldCalibreID = "calibre_id" // FieldName holds the string denoting the name field in the database. @@ -35,6 +40,8 @@ const ( // Columns holds all SQL columns for series fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldCalibreID, FieldName, FieldSort, @@ -64,6 +71,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error // SortValidator is a validator for the "sort" field. It is called by the builders before save. @@ -80,6 +93,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByCalibreID orders the results by the calibre_id field. func ByCalibreID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCalibreID, opts...).ToFunc() diff --git a/internal/ent/series/where.go b/internal/ent/series/where.go index 800dd1ac..6a0b8a4c 100644 --- a/internal/ent/series/where.go +++ b/internal/ent/series/where.go @@ -5,6 +5,7 @@ package series import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Series { return predicate.Series(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Series { + return predicate.Series(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Series { + return predicate.Series(sql.FieldEQ(FieldUpdateTime, v)) +} + // CalibreID applies equality check predicate on the "calibre_id" field. It's identical to CalibreIDEQ. func CalibreID(v int64) predicate.Series { return predicate.Series(sql.FieldEQ(FieldCalibreID, v)) @@ -70,6 +81,86 @@ func Sort(v string) predicate.Series { return predicate.Series(sql.FieldEQ(FieldSort, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Series { + return predicate.Series(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Series { + return predicate.Series(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Series { + return predicate.Series(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Series { + return predicate.Series(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Series { + return predicate.Series(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Series { + return predicate.Series(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Series { + return predicate.Series(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Series { + return predicate.Series(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Series { + return predicate.Series(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Series { + return predicate.Series(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Series { + return predicate.Series(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Series { + return predicate.Series(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Series { + return predicate.Series(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Series { + return predicate.Series(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Series { + return predicate.Series(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Series { + return predicate.Series(sql.FieldLTE(FieldUpdateTime, v)) +} + // CalibreIDEQ applies the EQ predicate on the "calibre_id" field. func CalibreIDEQ(v int64) predicate.Series { return predicate.Series(sql.FieldEQ(FieldCalibreID, v)) diff --git a/internal/ent/series_create.go b/internal/ent/series_create.go index 6cbf27da..ec5eb4e4 100644 --- a/internal/ent/series_create.go +++ b/internal/ent/series_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/book" "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/series" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,6 +25,34 @@ type SeriesCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (sc *SeriesCreate) SetCreateTime(t time.Time) *SeriesCreate { + sc.mutation.SetCreateTime(t) + return sc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (sc *SeriesCreate) SetNillableCreateTime(t *time.Time) *SeriesCreate { + if t != nil { + sc.SetCreateTime(*t) + } + return sc +} + +// SetUpdateTime sets the "update_time" field. +func (sc *SeriesCreate) SetUpdateTime(t time.Time) *SeriesCreate { + sc.mutation.SetUpdateTime(t) + return sc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (sc *SeriesCreate) SetNillableUpdateTime(t *time.Time) *SeriesCreate { + if t != nil { + sc.SetUpdateTime(*t) + } + return sc +} + // SetCalibreID sets the "calibre_id" field. func (sc *SeriesCreate) SetCalibreID(i int64) *SeriesCreate { sc.mutation.SetCalibreID(i) @@ -116,6 +145,20 @@ func (sc *SeriesCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (sc *SeriesCreate) defaults() error { + if _, ok := sc.mutation.CreateTime(); !ok { + if series.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized series.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := series.DefaultCreateTime() + sc.mutation.SetCreateTime(v) + } + if _, ok := sc.mutation.UpdateTime(); !ok { + if series.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized series.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := series.DefaultUpdateTime() + sc.mutation.SetUpdateTime(v) + } if _, ok := sc.mutation.ID(); !ok { if series.DefaultID == nil { return fmt.Errorf("ent: uninitialized series.DefaultID (forgotten import ent/runtime?)") @@ -128,6 +171,12 @@ func (sc *SeriesCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (sc *SeriesCreate) check() error { + if _, ok := sc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Series.create_time"`)} + } + if _, ok := sc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Series.update_time"`)} + } if _, ok := sc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Series.name"`)} } @@ -180,6 +229,14 @@ func (sc *SeriesCreate) createSpec() (*Series, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := sc.mutation.CreateTime(); ok { + _spec.SetField(series.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := sc.mutation.UpdateTime(); ok { + _spec.SetField(series.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := sc.mutation.CalibreID(); ok { _spec.SetField(series.FieldCalibreID, field.TypeInt64, value) _node.CalibreID = value @@ -215,7 +272,7 @@ func (sc *SeriesCreate) createSpec() (*Series, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Series.Create(). -// SetCalibreID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -224,7 +281,7 @@ func (sc *SeriesCreate) createSpec() (*Series, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.SeriesUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (sc *SeriesCreate) OnConflict(opts ...sql.ConflictOption) *SeriesUpsertOne { @@ -260,6 +317,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *SeriesUpsert) SetUpdateTime(v time.Time) *SeriesUpsert { + u.Set(series.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *SeriesUpsert) UpdateUpdateTime() *SeriesUpsert { + u.SetExcluded(series.FieldUpdateTime) + return u +} + // SetCalibreID sets the "calibre_id" field. func (u *SeriesUpsert) SetCalibreID(v int64) *SeriesUpsert { u.Set(series.FieldCalibreID, v) @@ -325,6 +394,9 @@ func (u *SeriesUpsertOne) UpdateNewValues() *SeriesUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(series.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(series.FieldCreateTime) + } })) return u } @@ -356,6 +428,20 @@ func (u *SeriesUpsertOne) Update(set func(*SeriesUpsert)) *SeriesUpsertOne { return u } +// SetUpdateTime sets the "update_time" field. +func (u *SeriesUpsertOne) SetUpdateTime(v time.Time) *SeriesUpsertOne { + return u.Update(func(s *SeriesUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *SeriesUpsertOne) UpdateUpdateTime() *SeriesUpsertOne { + return u.Update(func(s *SeriesUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *SeriesUpsertOne) SetCalibreID(v int64) *SeriesUpsertOne { return u.Update(func(s *SeriesUpsert) { @@ -548,7 +634,7 @@ func (scb *SeriesCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.SeriesUpsert) { -// SetCalibreID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (scb *SeriesCreateBulk) OnConflict(opts ...sql.ConflictOption) *SeriesUpsertBulk { @@ -595,6 +681,9 @@ func (u *SeriesUpsertBulk) UpdateNewValues() *SeriesUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(series.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(series.FieldCreateTime) + } } })) return u @@ -627,6 +716,20 @@ func (u *SeriesUpsertBulk) Update(set func(*SeriesUpsert)) *SeriesUpsertBulk { return u } +// SetUpdateTime sets the "update_time" field. +func (u *SeriesUpsertBulk) SetUpdateTime(v time.Time) *SeriesUpsertBulk { + return u.Update(func(s *SeriesUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *SeriesUpsertBulk) UpdateUpdateTime() *SeriesUpsertBulk { + return u.Update(func(s *SeriesUpsert) { + s.UpdateUpdateTime() + }) +} + // SetCalibreID sets the "calibre_id" field. func (u *SeriesUpsertBulk) SetCalibreID(v int64) *SeriesUpsertBulk { return u.Update(func(s *SeriesUpsert) { diff --git a/internal/ent/series_query.go b/internal/ent/series_query.go index 5e1d3e36..ef5aad7e 100644 --- a/internal/ent/series_query.go +++ b/internal/ent/series_query.go @@ -303,12 +303,12 @@ func (sq *SeriesQuery) WithBooks(opts ...func(*BookQuery)) *SeriesQuery { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Series.Query(). -// GroupBy(series.FieldCalibreID). +// GroupBy(series.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (sq *SeriesQuery) GroupBy(field string, fields ...string) *SeriesGroupBy { @@ -326,11 +326,11 @@ func (sq *SeriesQuery) GroupBy(field string, fields ...string) *SeriesGroupBy { // Example: // // var v []struct { -// CalibreID int64 `json:"calibre_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Series.Query(). -// Select(series.FieldCalibreID). +// Select(series.FieldCreateTime). // Scan(ctx, &v) func (sq *SeriesQuery) Select(fields ...string) *SeriesSelect { sq.ctx.Fields = append(sq.ctx.Fields, fields...) diff --git a/internal/ent/series_update.go b/internal/ent/series_update.go index 4f713de6..53c0dc64 100644 --- a/internal/ent/series_update.go +++ b/internal/ent/series_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/series" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (su *SeriesUpdate) Where(ps ...predicate.Series) *SeriesUpdate { return su } +// SetUpdateTime sets the "update_time" field. +func (su *SeriesUpdate) SetUpdateTime(t time.Time) *SeriesUpdate { + su.mutation.SetUpdateTime(t) + return su +} + // SetCalibreID sets the "calibre_id" field. func (su *SeriesUpdate) SetCalibreID(i int64) *SeriesUpdate { su.mutation.ResetCalibreID() @@ -127,6 +134,9 @@ func (su *SeriesUpdate) RemoveBooks(b ...*Book) *SeriesUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (su *SeriesUpdate) Save(ctx context.Context) (int, error) { + if err := su.defaults(); err != nil { + return 0, err + } return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) } @@ -152,6 +162,18 @@ func (su *SeriesUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (su *SeriesUpdate) defaults() error { + if _, ok := su.mutation.UpdateTime(); !ok { + if series.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized series.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := series.UpdateDefaultUpdateTime() + su.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (su *SeriesUpdate) check() error { if v, ok := su.mutation.Name(); ok { @@ -179,6 +201,9 @@ func (su *SeriesUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := su.mutation.UpdateTime(); ok { + _spec.SetField(series.FieldUpdateTime, field.TypeTime, value) + } if value, ok := su.mutation.CalibreID(); ok { _spec.SetField(series.FieldCalibreID, field.TypeInt64, value) } @@ -259,6 +284,12 @@ type SeriesUpdateOne struct { mutation *SeriesMutation } +// SetUpdateTime sets the "update_time" field. +func (suo *SeriesUpdateOne) SetUpdateTime(t time.Time) *SeriesUpdateOne { + suo.mutation.SetUpdateTime(t) + return suo +} + // SetCalibreID sets the "calibre_id" field. func (suo *SeriesUpdateOne) SetCalibreID(i int64) *SeriesUpdateOne { suo.mutation.ResetCalibreID() @@ -370,6 +401,9 @@ func (suo *SeriesUpdateOne) Select(field string, fields ...string) *SeriesUpdate // Save executes the query and returns the updated Series entity. func (suo *SeriesUpdateOne) Save(ctx context.Context) (*Series, error) { + if err := suo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) } @@ -395,6 +429,18 @@ func (suo *SeriesUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (suo *SeriesUpdateOne) defaults() error { + if _, ok := suo.mutation.UpdateTime(); !ok { + if series.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized series.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := series.UpdateDefaultUpdateTime() + suo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (suo *SeriesUpdateOne) check() error { if v, ok := suo.mutation.Name(); ok { @@ -439,6 +485,9 @@ func (suo *SeriesUpdateOne) sqlSave(ctx context.Context) (_node *Series, err err } } } + if value, ok := suo.mutation.UpdateTime(); ok { + _spec.SetField(series.FieldUpdateTime, field.TypeTime, value) + } if value, ok := suo.mutation.CalibreID(); ok { _spec.SetField(series.FieldCalibreID, field.TypeInt64, value) } diff --git a/internal/ent/shelf.go b/internal/ent/shelf.go index c2f487ac..e9bd1afd 100644 --- a/internal/ent/shelf.go +++ b/internal/ent/shelf.go @@ -8,6 +8,7 @@ import ( "lybbrio/internal/ent/shelf" "lybbrio/internal/ent/user" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -18,6 +19,10 @@ type Shelf struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // Public holds the value of the "public" field. Public bool `json:"public,omitempty"` // UserID holds the value of the "user_id" field. @@ -78,6 +83,8 @@ func (*Shelf) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case shelf.FieldID, shelf.FieldUserID, shelf.FieldName, shelf.FieldDescription: values[i] = new(sql.NullString) + case shelf.FieldCreateTime, shelf.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -99,6 +106,18 @@ func (s *Shelf) assignValues(columns []string, values []any) error { } else if value.Valid { s.ID = ksuid.ID(value.String) } + case shelf.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + s.CreateTime = value.Time + } + case shelf.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + s.UpdateTime = value.Time + } case shelf.FieldPublic: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field public", values[i]) @@ -169,6 +188,12 @@ func (s *Shelf) String() string { var builder strings.Builder builder.WriteString("Shelf(") builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString("create_time=") + builder.WriteString(s.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(s.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("public=") builder.WriteString(fmt.Sprintf("%v", s.Public)) builder.WriteString(", ") diff --git a/internal/ent/shelf/shelf.go b/internal/ent/shelf/shelf.go index 45a42015..71a633d3 100644 --- a/internal/ent/shelf/shelf.go +++ b/internal/ent/shelf/shelf.go @@ -4,6 +4,7 @@ package shelf import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "shelf" // 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" // FieldPublic holds the string denoting the public field in the database. FieldPublic = "public" // FieldUserID holds the string denoting the user_id field in the database. @@ -46,6 +51,8 @@ const ( // Columns holds all SQL columns for shelf fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldPublic, FieldUserID, FieldName, @@ -76,6 +83,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // DefaultPublic holds the default value on creation for the "public" field. DefaultPublic bool // NameValidator is a validator for the "name" field. It is called by the builders before save. @@ -92,6 +105,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByPublic orders the results by the public field. func ByPublic(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPublic, opts...).ToFunc() diff --git a/internal/ent/shelf/where.go b/internal/ent/shelf/where.go index 53d7beac..4174e1ad 100644 --- a/internal/ent/shelf/where.go +++ b/internal/ent/shelf/where.go @@ -5,6 +5,7 @@ package shelf import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.Shelf { return predicate.Shelf(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldEQ(FieldUpdateTime, v)) +} + // Public applies equality check predicate on the "public" field. It's identical to PublicEQ. func Public(v bool) predicate.Shelf { return predicate.Shelf(sql.FieldEQ(FieldPublic, v)) @@ -76,6 +87,86 @@ func Description(v string) predicate.Shelf { return predicate.Shelf(sql.FieldEQ(FieldDescription, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Shelf { + return predicate.Shelf(sql.FieldLTE(FieldUpdateTime, v)) +} + // PublicEQ applies the EQ predicate on the "public" field. func PublicEQ(v bool) predicate.Shelf { return predicate.Shelf(sql.FieldEQ(FieldPublic, v)) diff --git a/internal/ent/shelf_create.go b/internal/ent/shelf_create.go index a5aa204d..93d4da64 100644 --- a/internal/ent/shelf_create.go +++ b/internal/ent/shelf_create.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/shelf" "lybbrio/internal/ent/user" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -25,6 +26,34 @@ type ShelfCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (sc *ShelfCreate) SetCreateTime(t time.Time) *ShelfCreate { + sc.mutation.SetCreateTime(t) + return sc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (sc *ShelfCreate) SetNillableCreateTime(t *time.Time) *ShelfCreate { + if t != nil { + sc.SetCreateTime(*t) + } + return sc +} + +// SetUpdateTime sets the "update_time" field. +func (sc *ShelfCreate) SetUpdateTime(t time.Time) *ShelfCreate { + sc.mutation.SetUpdateTime(t) + return sc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (sc *ShelfCreate) SetNillableUpdateTime(t *time.Time) *ShelfCreate { + if t != nil { + sc.SetUpdateTime(*t) + } + return sc +} + // SetPublic sets the "public" field. func (sc *ShelfCreate) SetPublic(b bool) *ShelfCreate { sc.mutation.SetPublic(b) @@ -136,6 +165,20 @@ func (sc *ShelfCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (sc *ShelfCreate) defaults() error { + if _, ok := sc.mutation.CreateTime(); !ok { + if shelf.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized shelf.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := shelf.DefaultCreateTime() + sc.mutation.SetCreateTime(v) + } + if _, ok := sc.mutation.UpdateTime(); !ok { + if shelf.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized shelf.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := shelf.DefaultUpdateTime() + sc.mutation.SetUpdateTime(v) + } if _, ok := sc.mutation.Public(); !ok { v := shelf.DefaultPublic sc.mutation.SetPublic(v) @@ -152,6 +195,12 @@ func (sc *ShelfCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (sc *ShelfCreate) check() error { + if _, ok := sc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Shelf.create_time"`)} + } + if _, ok := sc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Shelf.update_time"`)} + } if _, ok := sc.mutation.Public(); !ok { return &ValidationError{Name: "public", err: errors.New(`ent: missing required field "Shelf.public"`)} } @@ -205,6 +254,14 @@ func (sc *ShelfCreate) createSpec() (*Shelf, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := sc.mutation.CreateTime(); ok { + _spec.SetField(shelf.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := sc.mutation.UpdateTime(); ok { + _spec.SetField(shelf.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := sc.mutation.Public(); ok { _spec.SetField(shelf.FieldPublic, field.TypeBool, value) _node.Public = value @@ -257,7 +314,7 @@ func (sc *ShelfCreate) createSpec() (*Shelf, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.Shelf.Create(). -// SetPublic(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -266,7 +323,7 @@ func (sc *ShelfCreate) createSpec() (*Shelf, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.ShelfUpsert) { -// SetPublic(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (sc *ShelfCreate) OnConflict(opts ...sql.ConflictOption) *ShelfUpsertOne { @@ -302,6 +359,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *ShelfUpsert) SetUpdateTime(v time.Time) *ShelfUpsert { + u.Set(shelf.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ShelfUpsert) UpdateUpdateTime() *ShelfUpsert { + u.SetExcluded(shelf.FieldUpdateTime) + return u +} + // SetPublic sets the "public" field. func (u *ShelfUpsert) SetPublic(v bool) *ShelfUpsert { u.Set(shelf.FieldPublic, v) @@ -361,6 +430,9 @@ func (u *ShelfUpsertOne) UpdateNewValues() *ShelfUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(shelf.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(shelf.FieldCreateTime) + } if _, exists := u.create.mutation.UserID(); exists { s.SetIgnore(shelf.FieldUserID) } @@ -395,6 +467,20 @@ func (u *ShelfUpsertOne) Update(set func(*ShelfUpsert)) *ShelfUpsertOne { return u } +// SetUpdateTime sets the "update_time" field. +func (u *ShelfUpsertOne) SetUpdateTime(v time.Time) *ShelfUpsertOne { + return u.Update(func(s *ShelfUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ShelfUpsertOne) UpdateUpdateTime() *ShelfUpsertOne { + return u.Update(func(s *ShelfUpsert) { + s.UpdateUpdateTime() + }) +} + // SetPublic sets the "public" field. func (u *ShelfUpsertOne) SetPublic(v bool) *ShelfUpsertOne { return u.Update(func(s *ShelfUpsert) { @@ -580,7 +666,7 @@ func (scb *ShelfCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.ShelfUpsert) { -// SetPublic(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (scb *ShelfCreateBulk) OnConflict(opts ...sql.ConflictOption) *ShelfUpsertBulk { @@ -627,6 +713,9 @@ func (u *ShelfUpsertBulk) UpdateNewValues() *ShelfUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(shelf.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(shelf.FieldCreateTime) + } if _, exists := b.mutation.UserID(); exists { s.SetIgnore(shelf.FieldUserID) } @@ -662,6 +751,20 @@ func (u *ShelfUpsertBulk) Update(set func(*ShelfUpsert)) *ShelfUpsertBulk { return u } +// SetUpdateTime sets the "update_time" field. +func (u *ShelfUpsertBulk) SetUpdateTime(v time.Time) *ShelfUpsertBulk { + return u.Update(func(s *ShelfUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *ShelfUpsertBulk) UpdateUpdateTime() *ShelfUpsertBulk { + return u.Update(func(s *ShelfUpsert) { + s.UpdateUpdateTime() + }) +} + // SetPublic sets the "public" field. func (u *ShelfUpsertBulk) SetPublic(v bool) *ShelfUpsertBulk { return u.Update(func(s *ShelfUpsert) { diff --git a/internal/ent/shelf_query.go b/internal/ent/shelf_query.go index 9509830f..ea410d2e 100644 --- a/internal/ent/shelf_query.go +++ b/internal/ent/shelf_query.go @@ -339,12 +339,12 @@ func (sq *ShelfQuery) WithBooks(opts ...func(*BookQuery)) *ShelfQuery { // Example: // // var v []struct { -// Public bool `json:"public,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.Shelf.Query(). -// GroupBy(shelf.FieldPublic). +// GroupBy(shelf.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (sq *ShelfQuery) GroupBy(field string, fields ...string) *ShelfGroupBy { @@ -362,11 +362,11 @@ func (sq *ShelfQuery) GroupBy(field string, fields ...string) *ShelfGroupBy { // Example: // // var v []struct { -// Public bool `json:"public,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.Shelf.Query(). -// Select(shelf.FieldPublic). +// Select(shelf.FieldCreateTime). // Scan(ctx, &v) func (sq *ShelfQuery) Select(fields ...string) *ShelfSelect { sq.ctx.Fields = append(sq.ctx.Fields, fields...) diff --git a/internal/ent/shelf_update.go b/internal/ent/shelf_update.go index 47dd559d..f982dad7 100644 --- a/internal/ent/shelf_update.go +++ b/internal/ent/shelf_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/shelf" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (su *ShelfUpdate) Where(ps ...predicate.Shelf) *ShelfUpdate { return su } +// SetUpdateTime sets the "update_time" field. +func (su *ShelfUpdate) SetUpdateTime(t time.Time) *ShelfUpdate { + su.mutation.SetUpdateTime(t) + return su +} + // SetPublic sets the "public" field. func (su *ShelfUpdate) SetPublic(b bool) *ShelfUpdate { su.mutation.SetPublic(b) @@ -120,6 +127,9 @@ func (su *ShelfUpdate) RemoveBooks(b ...*Book) *ShelfUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (su *ShelfUpdate) Save(ctx context.Context) (int, error) { + if err := su.defaults(); err != nil { + return 0, err + } return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) } @@ -145,6 +155,18 @@ func (su *ShelfUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (su *ShelfUpdate) defaults() error { + if _, ok := su.mutation.UpdateTime(); !ok { + if shelf.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized shelf.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := shelf.UpdateDefaultUpdateTime() + su.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (su *ShelfUpdate) check() error { if v, ok := su.mutation.Name(); ok { @@ -170,6 +192,9 @@ func (su *ShelfUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := su.mutation.UpdateTime(); ok { + _spec.SetField(shelf.FieldUpdateTime, field.TypeTime, value) + } if value, ok := su.mutation.Public(); ok { _spec.SetField(shelf.FieldPublic, field.TypeBool, value) } @@ -247,6 +272,12 @@ type ShelfUpdateOne struct { mutation *ShelfMutation } +// SetUpdateTime sets the "update_time" field. +func (suo *ShelfUpdateOne) SetUpdateTime(t time.Time) *ShelfUpdateOne { + suo.mutation.SetUpdateTime(t) + return suo +} + // SetPublic sets the "public" field. func (suo *ShelfUpdateOne) SetPublic(b bool) *ShelfUpdateOne { suo.mutation.SetPublic(b) @@ -351,6 +382,9 @@ func (suo *ShelfUpdateOne) Select(field string, fields ...string) *ShelfUpdateOn // Save executes the query and returns the updated Shelf entity. func (suo *ShelfUpdateOne) Save(ctx context.Context) (*Shelf, error) { + if err := suo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) } @@ -376,6 +410,18 @@ func (suo *ShelfUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (suo *ShelfUpdateOne) defaults() error { + if _, ok := suo.mutation.UpdateTime(); !ok { + if shelf.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized shelf.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := shelf.UpdateDefaultUpdateTime() + suo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (suo *ShelfUpdateOne) check() error { if v, ok := suo.mutation.Name(); ok { @@ -418,6 +464,9 @@ func (suo *ShelfUpdateOne) sqlSave(ctx context.Context) (_node *Shelf, err error } } } + if value, ok := suo.mutation.UpdateTime(); ok { + _spec.SetField(shelf.FieldUpdateTime, field.TypeTime, value) + } if value, ok := suo.mutation.Public(); ok { _spec.SetField(shelf.FieldPublic, field.TypeBool, value) } diff --git a/internal/ent/tx.go b/internal/ent/tx.go index c72b2171..ffca01ab 100644 --- a/internal/ent/tx.go +++ b/internal/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { Author *AuthorClient // Book is the client for interacting with the Book builders. Book *BookClient + // BookFile is the client for interacting with the BookFile builders. + BookFile *BookFileClient // Identifier is the client for interacting with the Identifier builders. Identifier *IdentifierClient // Language is the client for interacting with the Language builders. @@ -167,6 +169,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.Author = NewAuthorClient(tx.config) tx.Book = NewBookClient(tx.config) + tx.BookFile = NewBookFileClient(tx.config) tx.Identifier = NewIdentifierClient(tx.config) tx.Language = NewLanguageClient(tx.config) tx.Publisher = NewPublisherClient(tx.config) diff --git a/internal/ent/user.go b/internal/ent/user.go index f63374a8..8de0bb50 100644 --- a/internal/ent/user.go +++ b/internal/ent/user.go @@ -8,6 +8,7 @@ import ( "lybbrio/internal/ent/user" "lybbrio/internal/ent/userpermissions" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -18,6 +19,10 @@ type User struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // Username holds the value of the "username" field. Username string `json:"username,omitempty"` // PasswordHash holds the value of the "password_hash" field. @@ -74,6 +79,8 @@ func (*User) scanValues(columns []string) ([]any, error) { switch columns[i] { case user.FieldID, user.FieldUsername, user.FieldPasswordHash, user.FieldEmail: values[i] = new(sql.NullString) + case user.FieldCreateTime, user.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -95,6 +102,18 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.ID = ksuid.ID(value.String) } + case user.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + u.CreateTime = value.Time + } + case user.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + u.UpdateTime = value.Time + } case user.FieldUsername: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field username", values[i]) @@ -159,6 +178,12 @@ func (u *User) String() string { var builder strings.Builder builder.WriteString("User(") builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) + builder.WriteString("create_time=") + builder.WriteString(u.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(u.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("username=") builder.WriteString(u.Username) builder.WriteString(", ") diff --git a/internal/ent/user/user.go b/internal/ent/user/user.go index 2ffdf0ca..e5426fe1 100644 --- a/internal/ent/user/user.go +++ b/internal/ent/user/user.go @@ -4,6 +4,7 @@ package user import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,6 +16,10 @@ const ( Label = "user" // 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" // FieldUsername holds the string denoting the username field in the database. FieldUsername = "username" // FieldPasswordHash holds the string denoting the password_hash field in the database. @@ -46,6 +51,8 @@ const ( // Columns holds all SQL columns for user fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldUsername, FieldPasswordHash, FieldEmail, @@ -69,6 +76,12 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy + // 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 // UsernameValidator is a validator for the "username" field. It is called by the builders before save. UsernameValidator func(string) error // EmailValidator is a validator for the "email" field. It is called by the builders before save. @@ -85,6 +98,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByUsername orders the results by the username field. func ByUsername(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUsername, opts...).ToFunc() diff --git a/internal/ent/user/where.go b/internal/ent/user/where.go index 94d2637e..1c831610 100644 --- a/internal/ent/user/where.go +++ b/internal/ent/user/where.go @@ -5,6 +5,7 @@ package user import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,6 +56,16 @@ func IDLTE(id ksuid.ID) predicate.User { return predicate.User(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + // Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. func Username(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldUsername, v)) @@ -70,6 +81,86 @@ func Email(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldEmail, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdateTime, v)) +} + // UsernameEQ applies the EQ predicate on the "username" field. func UsernameEQ(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldUsername, v)) diff --git a/internal/ent/user_create.go b/internal/ent/user_create.go index bb4e0832..e9032653 100644 --- a/internal/ent/user_create.go +++ b/internal/ent/user_create.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/shelf" "lybbrio/internal/ent/user" "lybbrio/internal/ent/userpermissions" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -25,6 +26,34 @@ type UserCreate struct { conflict []sql.ConflictOption } +// SetCreateTime sets the "create_time" field. +func (uc *UserCreate) SetCreateTime(t time.Time) *UserCreate { + uc.mutation.SetCreateTime(t) + return uc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (uc *UserCreate) SetNillableCreateTime(t *time.Time) *UserCreate { + if t != nil { + uc.SetCreateTime(*t) + } + return uc +} + +// SetUpdateTime sets the "update_time" field. +func (uc *UserCreate) SetUpdateTime(t time.Time) *UserCreate { + uc.mutation.SetUpdateTime(t) + return uc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (uc *UserCreate) SetNillableUpdateTime(t *time.Time) *UserCreate { + if t != nil { + uc.SetUpdateTime(*t) + } + return uc +} + // SetUsername sets the "username" field. func (uc *UserCreate) SetUsername(s string) *UserCreate { uc.mutation.SetUsername(s) @@ -128,6 +157,20 @@ func (uc *UserCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (uc *UserCreate) defaults() error { + if _, ok := uc.mutation.CreateTime(); !ok { + if user.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized user.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := user.DefaultCreateTime() + uc.mutation.SetCreateTime(v) + } + if _, ok := uc.mutation.UpdateTime(); !ok { + if user.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized user.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := user.DefaultUpdateTime() + uc.mutation.SetUpdateTime(v) + } if _, ok := uc.mutation.ID(); !ok { if user.DefaultID == nil { return fmt.Errorf("ent: uninitialized user.DefaultID (forgotten import ent/runtime?)") @@ -140,6 +183,12 @@ func (uc *UserCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (uc *UserCreate) check() error { + if _, ok := uc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "User.create_time"`)} + } + if _, ok := uc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "User.update_time"`)} + } if _, ok := uc.mutation.Username(); !ok { return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} } @@ -195,6 +244,14 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _node.ID = id _spec.ID.Value = id } + if value, ok := uc.mutation.CreateTime(); ok { + _spec.SetField(user.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := uc.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } if value, ok := uc.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) _node.Username = value @@ -246,7 +303,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // of the `INSERT` statement. For example: // // client.User.Create(). -// SetUsername(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -255,7 +312,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.UserUpsert) { -// SetUsername(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (uc *UserCreate) OnConflict(opts ...sql.ConflictOption) *UserUpsertOne { @@ -291,6 +348,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *UserUpsert) SetUpdateTime(v time.Time) *UserUpsert { + u.Set(user.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserUpsert) UpdateUpdateTime() *UserUpsert { + u.SetExcluded(user.FieldUpdateTime) + return u +} + // SetUsername sets the "username" field. func (u *UserUpsert) SetUsername(v string) *UserUpsert { u.Set(user.FieldUsername, v) @@ -350,6 +419,9 @@ func (u *UserUpsertOne) UpdateNewValues() *UserUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(user.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(user.FieldCreateTime) + } })) return u } @@ -381,6 +453,20 @@ func (u *UserUpsertOne) Update(set func(*UserUpsert)) *UserUpsertOne { return u } +// SetUpdateTime sets the "update_time" field. +func (u *UserUpsertOne) SetUpdateTime(v time.Time) *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserUpsertOne) UpdateUpdateTime() *UserUpsertOne { + return u.Update(func(s *UserUpsert) { + s.UpdateUpdateTime() + }) +} + // SetUsername sets the "username" field. func (u *UserUpsertOne) SetUsername(v string) *UserUpsertOne { return u.Update(func(s *UserUpsert) { @@ -566,7 +652,7 @@ func (ucb *UserCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.UserUpsert) { -// SetUsername(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (ucb *UserCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserUpsertBulk { @@ -613,6 +699,9 @@ func (u *UserUpsertBulk) UpdateNewValues() *UserUpsertBulk { if _, exists := b.mutation.ID(); exists { s.SetIgnore(user.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(user.FieldCreateTime) + } } })) return u @@ -645,6 +734,20 @@ func (u *UserUpsertBulk) Update(set func(*UserUpsert)) *UserUpsertBulk { return u } +// SetUpdateTime sets the "update_time" field. +func (u *UserUpsertBulk) SetUpdateTime(v time.Time) *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserUpsertBulk) UpdateUpdateTime() *UserUpsertBulk { + return u.Update(func(s *UserUpsert) { + s.UpdateUpdateTime() + }) +} + // SetUsername sets the "username" field. func (u *UserUpsertBulk) SetUsername(v string) *UserUpsertBulk { return u.Update(func(s *UserUpsert) { diff --git a/internal/ent/user_query.go b/internal/ent/user_query.go index 2bb46c2d..78c264a0 100644 --- a/internal/ent/user_query.go +++ b/internal/ent/user_query.go @@ -339,12 +339,12 @@ func (uq *UserQuery) WithUserPermissions(opts ...func(*UserPermissionsQuery)) *U // Example: // // var v []struct { -// Username string `json:"username,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.User.Query(). -// GroupBy(user.FieldUsername). +// GroupBy(user.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { @@ -362,11 +362,11 @@ func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { // Example: // // var v []struct { -// Username string `json:"username,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.User.Query(). -// Select(user.FieldUsername). +// Select(user.FieldCreateTime). // Scan(ctx, &v) func (uq *UserQuery) Select(fields ...string) *UserSelect { uq.ctx.Fields = append(uq.ctx.Fields, fields...) diff --git a/internal/ent/user_update.go b/internal/ent/user_update.go index 71a01810..ac84668e 100644 --- a/internal/ent/user_update.go +++ b/internal/ent/user_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/shelf" "lybbrio/internal/ent/user" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { return uu } +// SetUpdateTime sets the "update_time" field. +func (uu *UserUpdate) SetUpdateTime(t time.Time) *UserUpdate { + uu.mutation.SetUpdateTime(t) + return uu +} + // SetUsername sets the "username" field. func (uu *UserUpdate) SetUsername(s string) *UserUpdate { uu.mutation.SetUsername(s) @@ -120,6 +127,9 @@ func (uu *UserUpdate) RemoveShelves(s ...*Shelf) *UserUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { + if err := uu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) } @@ -145,6 +155,18 @@ func (uu *UserUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (uu *UserUpdate) defaults() error { + if _, ok := uu.mutation.UpdateTime(); !ok { + if user.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := user.UpdateDefaultUpdateTime() + uu.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (uu *UserUpdate) check() error { if v, ok := uu.mutation.Username(); ok { @@ -175,6 +197,9 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } + if value, ok := uu.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + } if value, ok := uu.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } @@ -252,6 +277,12 @@ type UserUpdateOne struct { mutation *UserMutation } +// SetUpdateTime sets the "update_time" field. +func (uuo *UserUpdateOne) SetUpdateTime(t time.Time) *UserUpdateOne { + uuo.mutation.SetUpdateTime(t) + return uuo +} + // SetUsername sets the "username" field. func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { uuo.mutation.SetUsername(s) @@ -356,6 +387,9 @@ func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne // Save executes the query and returns the updated User entity. func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { + if err := uuo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) } @@ -381,6 +415,18 @@ func (uuo *UserUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (uuo *UserUpdateOne) defaults() error { + if _, ok := uuo.mutation.UpdateTime(); !ok { + if user.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := user.UpdateDefaultUpdateTime() + uuo.mutation.SetUpdateTime(v) + } + return nil +} + // check runs all checks and user-defined validators on the builder. func (uuo *UserUpdateOne) check() error { if v, ok := uuo.mutation.Username(); ok { @@ -428,6 +474,9 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } } } + if value, ok := uuo.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + } if value, ok := uuo.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } diff --git a/internal/ent/userpermissions.go b/internal/ent/userpermissions.go index 570591bf..fcd88416 100644 --- a/internal/ent/userpermissions.go +++ b/internal/ent/userpermissions.go @@ -8,6 +8,7 @@ import ( "lybbrio/internal/ent/user" "lybbrio/internal/ent/userpermissions" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -18,14 +19,18 @@ type UserPermissions struct { config `json:"-"` // ID of the ent. ID ksuid.ID `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"` // UserID holds the value of the "user_id" field. UserID ksuid.ID `json:"user_id,omitempty"` - // CanEdit holds the value of the "CanEdit" field. - CanEdit bool `json:"CanEdit,omitempty"` // Admin holds the value of the "Admin" field. Admin bool `json:"Admin,omitempty"` // CanCreatePublic holds the value of the "CanCreatePublic" field. CanCreatePublic bool `json:"CanCreatePublic,omitempty"` + // CanEdit holds the value of the "CanEdit" field. + CanEdit bool `json:"CanEdit,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserPermissionsQuery when eager-loading is set. Edges UserPermissionsEdges `json:"edges"` @@ -61,10 +66,12 @@ func (*UserPermissions) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case userpermissions.FieldCanEdit, userpermissions.FieldAdmin, userpermissions.FieldCanCreatePublic: + case userpermissions.FieldAdmin, userpermissions.FieldCanCreatePublic, userpermissions.FieldCanEdit: values[i] = new(sql.NullBool) case userpermissions.FieldID, userpermissions.FieldUserID: values[i] = new(sql.NullString) + case userpermissions.FieldCreateTime, userpermissions.FieldUpdateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -86,18 +93,24 @@ func (up *UserPermissions) assignValues(columns []string, values []any) error { } else if value.Valid { up.ID = ksuid.ID(value.String) } + case userpermissions.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + up.CreateTime = value.Time + } + case userpermissions.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + up.UpdateTime = value.Time + } case userpermissions.FieldUserID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { up.UserID = ksuid.ID(value.String) } - case userpermissions.FieldCanEdit: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field CanEdit", values[i]) - } else if value.Valid { - up.CanEdit = value.Bool - } case userpermissions.FieldAdmin: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field Admin", values[i]) @@ -110,6 +123,12 @@ func (up *UserPermissions) assignValues(columns []string, values []any) error { } else if value.Valid { up.CanCreatePublic = value.Bool } + case userpermissions.FieldCanEdit: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field CanEdit", values[i]) + } else if value.Valid { + up.CanEdit = value.Bool + } default: up.selectValues.Set(columns[i], values[i]) } @@ -151,17 +170,23 @@ func (up *UserPermissions) String() string { var builder strings.Builder builder.WriteString("UserPermissions(") builder.WriteString(fmt.Sprintf("id=%v, ", up.ID)) + builder.WriteString("create_time=") + builder.WriteString(up.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(up.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("user_id=") builder.WriteString(fmt.Sprintf("%v", up.UserID)) builder.WriteString(", ") - builder.WriteString("CanEdit=") - builder.WriteString(fmt.Sprintf("%v", up.CanEdit)) - builder.WriteString(", ") builder.WriteString("Admin=") builder.WriteString(fmt.Sprintf("%v", up.Admin)) builder.WriteString(", ") builder.WriteString("CanCreatePublic=") builder.WriteString(fmt.Sprintf("%v", up.CanCreatePublic)) + builder.WriteString(", ") + builder.WriteString("CanEdit=") + builder.WriteString(fmt.Sprintf("%v", up.CanEdit)) builder.WriteByte(')') return builder.String() } diff --git a/internal/ent/userpermissions/userpermissions.go b/internal/ent/userpermissions/userpermissions.go index 89a10a24..b08bff91 100644 --- a/internal/ent/userpermissions/userpermissions.go +++ b/internal/ent/userpermissions/userpermissions.go @@ -4,6 +4,7 @@ package userpermissions import ( "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -15,14 +16,18 @@ const ( Label = "user_permissions" // 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" // FieldUserID holds the string denoting the user_id field in the database. FieldUserID = "user_id" - // FieldCanEdit holds the string denoting the canedit field in the database. - FieldCanEdit = "can_edit" // FieldAdmin holds the string denoting the admin field in the database. FieldAdmin = "admin" // FieldCanCreatePublic holds the string denoting the cancreatepublic field in the database. FieldCanCreatePublic = "can_create_public" + // FieldCanEdit holds the string denoting the canedit field in the database. + FieldCanEdit = "can_edit" // EdgeUser holds the string denoting the user edge name in mutations. EdgeUser = "user" // Table holds the table name of the userpermissions in the database. @@ -39,10 +44,12 @@ const ( // Columns holds all SQL columns for userpermissions fields. var Columns = []string{ FieldID, + FieldCreateTime, + FieldUpdateTime, FieldUserID, - FieldCanEdit, FieldAdmin, FieldCanCreatePublic, + FieldCanEdit, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -63,12 +70,18 @@ func ValidColumn(column string) bool { var ( Hooks [1]ent.Hook Policy ent.Policy - // DefaultCanEdit holds the default value on creation for the "CanEdit" field. - DefaultCanEdit bool + // 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 // DefaultAdmin holds the default value on creation for the "Admin" field. DefaultAdmin bool // DefaultCanCreatePublic holds the default value on creation for the "CanCreatePublic" field. DefaultCanCreatePublic bool + // DefaultCanEdit holds the default value on creation for the "CanEdit" field. + DefaultCanEdit bool // DefaultID holds the default value on creation for the "id" field. DefaultID func() ksuid.ID ) @@ -81,16 +94,21 @@ func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + // ByUserID orders the results by the user_id field. func ByUserID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUserID, opts...).ToFunc() } -// ByCanEdit orders the results by the CanEdit field. -func ByCanEdit(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCanEdit, opts...).ToFunc() -} - // ByAdmin orders the results by the Admin field. func ByAdmin(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldAdmin, opts...).ToFunc() @@ -101,6 +119,11 @@ func ByCanCreatePublic(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCanCreatePublic, opts...).ToFunc() } +// ByCanEdit orders the results by the CanEdit field. +func ByCanEdit(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCanEdit, opts...).ToFunc() +} + // ByUserField orders the results by user field. func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/internal/ent/userpermissions/where.go b/internal/ent/userpermissions/where.go index 07153c65..79467c18 100644 --- a/internal/ent/userpermissions/where.go +++ b/internal/ent/userpermissions/where.go @@ -5,6 +5,7 @@ package userpermissions import ( "lybbrio/internal/ent/predicate" "lybbrio/internal/ent/schema/ksuid" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -55,17 +56,22 @@ func IDLTE(id ksuid.ID) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldLTE(FieldID, id)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldUpdateTime, v)) +} + // UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. func UserID(v ksuid.ID) predicate.UserPermissions { vc := string(v) return predicate.UserPermissions(sql.FieldEQ(FieldUserID, vc)) } -// CanEdit applies equality check predicate on the "CanEdit" field. It's identical to CanEditEQ. -func CanEdit(v bool) predicate.UserPermissions { - return predicate.UserPermissions(sql.FieldEQ(FieldCanEdit, v)) -} - // Admin applies equality check predicate on the "Admin" field. It's identical to AdminEQ. func Admin(v bool) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldEQ(FieldAdmin, v)) @@ -76,6 +82,91 @@ func CanCreatePublic(v bool) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldEQ(FieldCanCreatePublic, v)) } +// CanEdit applies equality check predicate on the "CanEdit" field. It's identical to CanEditEQ. +func CanEdit(v bool) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldCanEdit, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldLTE(FieldUpdateTime, v)) +} + // UserIDEQ applies the EQ predicate on the "user_id" field. func UserIDEQ(v ksuid.ID) predicate.UserPermissions { vc := string(v) @@ -170,16 +261,6 @@ func UserIDContainsFold(v ksuid.ID) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldContainsFold(FieldUserID, vc)) } -// CanEditEQ applies the EQ predicate on the "CanEdit" field. -func CanEditEQ(v bool) predicate.UserPermissions { - return predicate.UserPermissions(sql.FieldEQ(FieldCanEdit, v)) -} - -// CanEditNEQ applies the NEQ predicate on the "CanEdit" field. -func CanEditNEQ(v bool) predicate.UserPermissions { - return predicate.UserPermissions(sql.FieldNEQ(FieldCanEdit, v)) -} - // AdminEQ applies the EQ predicate on the "Admin" field. func AdminEQ(v bool) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldEQ(FieldAdmin, v)) @@ -200,6 +281,16 @@ func CanCreatePublicNEQ(v bool) predicate.UserPermissions { return predicate.UserPermissions(sql.FieldNEQ(FieldCanCreatePublic, v)) } +// CanEditEQ applies the EQ predicate on the "CanEdit" field. +func CanEditEQ(v bool) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldEQ(FieldCanEdit, v)) +} + +// CanEditNEQ applies the NEQ predicate on the "CanEdit" field. +func CanEditNEQ(v bool) predicate.UserPermissions { + return predicate.UserPermissions(sql.FieldNEQ(FieldCanEdit, v)) +} + // HasUser applies the HasEdge predicate on the "user" edge. func HasUser() predicate.UserPermissions { return predicate.UserPermissions(func(s *sql.Selector) { diff --git a/internal/ent/userpermissions_create.go b/internal/ent/userpermissions_create.go index 99cd55e5..41f7eb2a 100644 --- a/internal/ent/userpermissions_create.go +++ b/internal/ent/userpermissions_create.go @@ -9,6 +9,7 @@ import ( "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/user" "lybbrio/internal/ent/userpermissions" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" @@ -24,30 +25,44 @@ type UserPermissionsCreate struct { conflict []sql.ConflictOption } -// SetUserID sets the "user_id" field. -func (upc *UserPermissionsCreate) SetUserID(k ksuid.ID) *UserPermissionsCreate { - upc.mutation.SetUserID(k) +// SetCreateTime sets the "create_time" field. +func (upc *UserPermissionsCreate) SetCreateTime(t time.Time) *UserPermissionsCreate { + upc.mutation.SetCreateTime(t) return upc } -// SetNillableUserID sets the "user_id" field if the given value is not nil. -func (upc *UserPermissionsCreate) SetNillableUserID(k *ksuid.ID) *UserPermissionsCreate { - if k != nil { - upc.SetUserID(*k) +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (upc *UserPermissionsCreate) SetNillableCreateTime(t *time.Time) *UserPermissionsCreate { + if t != nil { + upc.SetCreateTime(*t) } return upc } -// SetCanEdit sets the "CanEdit" field. -func (upc *UserPermissionsCreate) SetCanEdit(b bool) *UserPermissionsCreate { - upc.mutation.SetCanEdit(b) +// SetUpdateTime sets the "update_time" field. +func (upc *UserPermissionsCreate) SetUpdateTime(t time.Time) *UserPermissionsCreate { + upc.mutation.SetUpdateTime(t) return upc } -// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. -func (upc *UserPermissionsCreate) SetNillableCanEdit(b *bool) *UserPermissionsCreate { - if b != nil { - upc.SetCanEdit(*b) +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (upc *UserPermissionsCreate) SetNillableUpdateTime(t *time.Time) *UserPermissionsCreate { + if t != nil { + upc.SetUpdateTime(*t) + } + return upc +} + +// SetUserID sets the "user_id" field. +func (upc *UserPermissionsCreate) SetUserID(k ksuid.ID) *UserPermissionsCreate { + upc.mutation.SetUserID(k) + return upc +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (upc *UserPermissionsCreate) SetNillableUserID(k *ksuid.ID) *UserPermissionsCreate { + if k != nil { + upc.SetUserID(*k) } return upc } @@ -80,6 +95,20 @@ func (upc *UserPermissionsCreate) SetNillableCanCreatePublic(b *bool) *UserPermi return upc } +// SetCanEdit sets the "CanEdit" field. +func (upc *UserPermissionsCreate) SetCanEdit(b bool) *UserPermissionsCreate { + upc.mutation.SetCanEdit(b) + return upc +} + +// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. +func (upc *UserPermissionsCreate) SetNillableCanEdit(b *bool) *UserPermissionsCreate { + if b != nil { + upc.SetCanEdit(*b) + } + return upc +} + // SetID sets the "id" field. func (upc *UserPermissionsCreate) SetID(k ksuid.ID) *UserPermissionsCreate { upc.mutation.SetID(k) @@ -136,9 +165,19 @@ func (upc *UserPermissionsCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (upc *UserPermissionsCreate) defaults() error { - if _, ok := upc.mutation.CanEdit(); !ok { - v := userpermissions.DefaultCanEdit - upc.mutation.SetCanEdit(v) + if _, ok := upc.mutation.CreateTime(); !ok { + if userpermissions.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized userpermissions.DefaultCreateTime (forgotten import ent/runtime?)") + } + v := userpermissions.DefaultCreateTime() + upc.mutation.SetCreateTime(v) + } + if _, ok := upc.mutation.UpdateTime(); !ok { + if userpermissions.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized userpermissions.DefaultUpdateTime (forgotten import ent/runtime?)") + } + v := userpermissions.DefaultUpdateTime() + upc.mutation.SetUpdateTime(v) } if _, ok := upc.mutation.Admin(); !ok { v := userpermissions.DefaultAdmin @@ -148,6 +187,10 @@ func (upc *UserPermissionsCreate) defaults() error { v := userpermissions.DefaultCanCreatePublic upc.mutation.SetCanCreatePublic(v) } + if _, ok := upc.mutation.CanEdit(); !ok { + v := userpermissions.DefaultCanEdit + upc.mutation.SetCanEdit(v) + } if _, ok := upc.mutation.ID(); !ok { if userpermissions.DefaultID == nil { return fmt.Errorf("ent: uninitialized userpermissions.DefaultID (forgotten import ent/runtime?)") @@ -160,8 +203,11 @@ func (upc *UserPermissionsCreate) defaults() error { // check runs all checks and user-defined validators on the builder. func (upc *UserPermissionsCreate) check() error { - if _, ok := upc.mutation.CanEdit(); !ok { - return &ValidationError{Name: "CanEdit", err: errors.New(`ent: missing required field "UserPermissions.CanEdit"`)} + if _, ok := upc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "UserPermissions.create_time"`)} + } + if _, ok := upc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "UserPermissions.update_time"`)} } if _, ok := upc.mutation.Admin(); !ok { return &ValidationError{Name: "Admin", err: errors.New(`ent: missing required field "UserPermissions.Admin"`)} @@ -169,6 +215,9 @@ func (upc *UserPermissionsCreate) check() error { if _, ok := upc.mutation.CanCreatePublic(); !ok { return &ValidationError{Name: "CanCreatePublic", err: errors.New(`ent: missing required field "UserPermissions.CanCreatePublic"`)} } + if _, ok := upc.mutation.CanEdit(); !ok { + return &ValidationError{Name: "CanEdit", err: errors.New(`ent: missing required field "UserPermissions.CanEdit"`)} + } return nil } @@ -205,9 +254,13 @@ func (upc *UserPermissionsCreate) createSpec() (*UserPermissions, *sqlgraph.Crea _node.ID = id _spec.ID.Value = id } - if value, ok := upc.mutation.CanEdit(); ok { - _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) - _node.CanEdit = value + if value, ok := upc.mutation.CreateTime(); ok { + _spec.SetField(userpermissions.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := upc.mutation.UpdateTime(); ok { + _spec.SetField(userpermissions.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value } if value, ok := upc.mutation.Admin(); ok { _spec.SetField(userpermissions.FieldAdmin, field.TypeBool, value) @@ -217,6 +270,10 @@ func (upc *UserPermissionsCreate) createSpec() (*UserPermissions, *sqlgraph.Crea _spec.SetField(userpermissions.FieldCanCreatePublic, field.TypeBool, value) _node.CanCreatePublic = value } + if value, ok := upc.mutation.CanEdit(); ok { + _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) + _node.CanEdit = value + } if nodes := upc.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, @@ -241,7 +298,7 @@ func (upc *UserPermissionsCreate) createSpec() (*UserPermissions, *sqlgraph.Crea // of the `INSERT` statement. For example: // // client.UserPermissions.Create(). -// SetUserID(v). +// SetCreateTime(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. @@ -250,7 +307,7 @@ func (upc *UserPermissionsCreate) createSpec() (*UserPermissions, *sqlgraph.Crea // // Override some of the fields with custom // // update values. // Update(func(u *ent.UserPermissionsUpsert) { -// SetUserID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (upc *UserPermissionsCreate) OnConflict(opts ...sql.ConflictOption) *UserPermissionsUpsertOne { @@ -286,6 +343,18 @@ type ( } ) +// SetUpdateTime sets the "update_time" field. +func (u *UserPermissionsUpsert) SetUpdateTime(v time.Time) *UserPermissionsUpsert { + u.Set(userpermissions.FieldUpdateTime, v) + return u +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserPermissionsUpsert) UpdateUpdateTime() *UserPermissionsUpsert { + u.SetExcluded(userpermissions.FieldUpdateTime) + return u +} + // SetUserID sets the "user_id" field. func (u *UserPermissionsUpsert) SetUserID(v ksuid.ID) *UserPermissionsUpsert { u.Set(userpermissions.FieldUserID, v) @@ -304,18 +373,6 @@ func (u *UserPermissionsUpsert) ClearUserID() *UserPermissionsUpsert { return u } -// SetCanEdit sets the "CanEdit" field. -func (u *UserPermissionsUpsert) SetCanEdit(v bool) *UserPermissionsUpsert { - u.Set(userpermissions.FieldCanEdit, v) - return u -} - -// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. -func (u *UserPermissionsUpsert) UpdateCanEdit() *UserPermissionsUpsert { - u.SetExcluded(userpermissions.FieldCanEdit) - return u -} - // SetAdmin sets the "Admin" field. func (u *UserPermissionsUpsert) SetAdmin(v bool) *UserPermissionsUpsert { u.Set(userpermissions.FieldAdmin, v) @@ -340,6 +397,18 @@ func (u *UserPermissionsUpsert) UpdateCanCreatePublic() *UserPermissionsUpsert { return u } +// SetCanEdit sets the "CanEdit" field. +func (u *UserPermissionsUpsert) SetCanEdit(v bool) *UserPermissionsUpsert { + u.Set(userpermissions.FieldCanEdit, v) + return u +} + +// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. +func (u *UserPermissionsUpsert) UpdateCanEdit() *UserPermissionsUpsert { + u.SetExcluded(userpermissions.FieldCanEdit) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -357,6 +426,9 @@ func (u *UserPermissionsUpsertOne) UpdateNewValues() *UserPermissionsUpsertOne { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(userpermissions.FieldID) } + if _, exists := u.create.mutation.CreateTime(); exists { + s.SetIgnore(userpermissions.FieldCreateTime) + } })) return u } @@ -388,6 +460,20 @@ func (u *UserPermissionsUpsertOne) Update(set func(*UserPermissionsUpsert)) *Use return u } +// SetUpdateTime sets the "update_time" field. +func (u *UserPermissionsUpsertOne) SetUpdateTime(v time.Time) *UserPermissionsUpsertOne { + return u.Update(func(s *UserPermissionsUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserPermissionsUpsertOne) UpdateUpdateTime() *UserPermissionsUpsertOne { + return u.Update(func(s *UserPermissionsUpsert) { + s.UpdateUpdateTime() + }) +} + // SetUserID sets the "user_id" field. func (u *UserPermissionsUpsertOne) SetUserID(v ksuid.ID) *UserPermissionsUpsertOne { return u.Update(func(s *UserPermissionsUpsert) { @@ -409,20 +495,6 @@ func (u *UserPermissionsUpsertOne) ClearUserID() *UserPermissionsUpsertOne { }) } -// SetCanEdit sets the "CanEdit" field. -func (u *UserPermissionsUpsertOne) SetCanEdit(v bool) *UserPermissionsUpsertOne { - return u.Update(func(s *UserPermissionsUpsert) { - s.SetCanEdit(v) - }) -} - -// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. -func (u *UserPermissionsUpsertOne) UpdateCanEdit() *UserPermissionsUpsertOne { - return u.Update(func(s *UserPermissionsUpsert) { - s.UpdateCanEdit() - }) -} - // SetAdmin sets the "Admin" field. func (u *UserPermissionsUpsertOne) SetAdmin(v bool) *UserPermissionsUpsertOne { return u.Update(func(s *UserPermissionsUpsert) { @@ -451,6 +523,20 @@ func (u *UserPermissionsUpsertOne) UpdateCanCreatePublic() *UserPermissionsUpser }) } +// SetCanEdit sets the "CanEdit" field. +func (u *UserPermissionsUpsertOne) SetCanEdit(v bool) *UserPermissionsUpsertOne { + return u.Update(func(s *UserPermissionsUpsert) { + s.SetCanEdit(v) + }) +} + +// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. +func (u *UserPermissionsUpsertOne) UpdateCanEdit() *UserPermissionsUpsertOne { + return u.Update(func(s *UserPermissionsUpsert) { + s.UpdateCanEdit() + }) +} + // Exec executes the query. func (u *UserPermissionsUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -587,7 +673,7 @@ func (upcb *UserPermissionsCreateBulk) ExecX(ctx context.Context) { // // Override some of the fields with custom // // update values. // Update(func(u *ent.UserPermissionsUpsert) { -// SetUserID(v+v). +// SetCreateTime(v+v). // }). // Exec(ctx) func (upcb *UserPermissionsCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserPermissionsUpsertBulk { @@ -634,6 +720,9 @@ func (u *UserPermissionsUpsertBulk) UpdateNewValues() *UserPermissionsUpsertBulk if _, exists := b.mutation.ID(); exists { s.SetIgnore(userpermissions.FieldID) } + if _, exists := b.mutation.CreateTime(); exists { + s.SetIgnore(userpermissions.FieldCreateTime) + } } })) return u @@ -666,6 +755,20 @@ func (u *UserPermissionsUpsertBulk) Update(set func(*UserPermissionsUpsert)) *Us return u } +// SetUpdateTime sets the "update_time" field. +func (u *UserPermissionsUpsertBulk) SetUpdateTime(v time.Time) *UserPermissionsUpsertBulk { + return u.Update(func(s *UserPermissionsUpsert) { + s.SetUpdateTime(v) + }) +} + +// UpdateUpdateTime sets the "update_time" field to the value that was provided on create. +func (u *UserPermissionsUpsertBulk) UpdateUpdateTime() *UserPermissionsUpsertBulk { + return u.Update(func(s *UserPermissionsUpsert) { + s.UpdateUpdateTime() + }) +} + // SetUserID sets the "user_id" field. func (u *UserPermissionsUpsertBulk) SetUserID(v ksuid.ID) *UserPermissionsUpsertBulk { return u.Update(func(s *UserPermissionsUpsert) { @@ -687,20 +790,6 @@ func (u *UserPermissionsUpsertBulk) ClearUserID() *UserPermissionsUpsertBulk { }) } -// SetCanEdit sets the "CanEdit" field. -func (u *UserPermissionsUpsertBulk) SetCanEdit(v bool) *UserPermissionsUpsertBulk { - return u.Update(func(s *UserPermissionsUpsert) { - s.SetCanEdit(v) - }) -} - -// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. -func (u *UserPermissionsUpsertBulk) UpdateCanEdit() *UserPermissionsUpsertBulk { - return u.Update(func(s *UserPermissionsUpsert) { - s.UpdateCanEdit() - }) -} - // SetAdmin sets the "Admin" field. func (u *UserPermissionsUpsertBulk) SetAdmin(v bool) *UserPermissionsUpsertBulk { return u.Update(func(s *UserPermissionsUpsert) { @@ -729,6 +818,20 @@ func (u *UserPermissionsUpsertBulk) UpdateCanCreatePublic() *UserPermissionsUpse }) } +// SetCanEdit sets the "CanEdit" field. +func (u *UserPermissionsUpsertBulk) SetCanEdit(v bool) *UserPermissionsUpsertBulk { + return u.Update(func(s *UserPermissionsUpsert) { + s.SetCanEdit(v) + }) +} + +// UpdateCanEdit sets the "CanEdit" field to the value that was provided on create. +func (u *UserPermissionsUpsertBulk) UpdateCanEdit() *UserPermissionsUpsertBulk { + return u.Update(func(s *UserPermissionsUpsert) { + s.UpdateCanEdit() + }) +} + // Exec executes the query. func (u *UserPermissionsUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/internal/ent/userpermissions_query.go b/internal/ent/userpermissions_query.go index 31dedac0..3d1fd90c 100644 --- a/internal/ent/userpermissions_query.go +++ b/internal/ent/userpermissions_query.go @@ -301,12 +301,12 @@ func (upq *UserPermissionsQuery) WithUser(opts ...func(*UserQuery)) *UserPermiss // Example: // // var v []struct { -// UserID ksuid.ID `json:"user_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // Count int `json:"count,omitempty"` // } // // client.UserPermissions.Query(). -// GroupBy(userpermissions.FieldUserID). +// GroupBy(userpermissions.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) func (upq *UserPermissionsQuery) GroupBy(field string, fields ...string) *UserPermissionsGroupBy { @@ -324,11 +324,11 @@ func (upq *UserPermissionsQuery) GroupBy(field string, fields ...string) *UserPe // Example: // // var v []struct { -// UserID ksuid.ID `json:"user_id,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` // } // // client.UserPermissions.Query(). -// Select(userpermissions.FieldUserID). +// Select(userpermissions.FieldCreateTime). // Scan(ctx, &v) func (upq *UserPermissionsQuery) Select(fields ...string) *UserPermissionsSelect { upq.ctx.Fields = append(upq.ctx.Fields, fields...) diff --git a/internal/ent/userpermissions_update.go b/internal/ent/userpermissions_update.go index c378a2dd..7ffa1c2e 100644 --- a/internal/ent/userpermissions_update.go +++ b/internal/ent/userpermissions_update.go @@ -10,6 +10,7 @@ import ( "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/user" "lybbrio/internal/ent/userpermissions" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -29,6 +30,12 @@ func (upu *UserPermissionsUpdate) Where(ps ...predicate.UserPermissions) *UserPe return upu } +// SetUpdateTime sets the "update_time" field. +func (upu *UserPermissionsUpdate) SetUpdateTime(t time.Time) *UserPermissionsUpdate { + upu.mutation.SetUpdateTime(t) + return upu +} + // SetUserID sets the "user_id" field. func (upu *UserPermissionsUpdate) SetUserID(k ksuid.ID) *UserPermissionsUpdate { upu.mutation.SetUserID(k) @@ -49,20 +56,6 @@ func (upu *UserPermissionsUpdate) ClearUserID() *UserPermissionsUpdate { return upu } -// SetCanEdit sets the "CanEdit" field. -func (upu *UserPermissionsUpdate) SetCanEdit(b bool) *UserPermissionsUpdate { - upu.mutation.SetCanEdit(b) - return upu -} - -// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. -func (upu *UserPermissionsUpdate) SetNillableCanEdit(b *bool) *UserPermissionsUpdate { - if b != nil { - upu.SetCanEdit(*b) - } - return upu -} - // SetAdmin sets the "Admin" field. func (upu *UserPermissionsUpdate) SetAdmin(b bool) *UserPermissionsUpdate { upu.mutation.SetAdmin(b) @@ -91,6 +84,20 @@ func (upu *UserPermissionsUpdate) SetNillableCanCreatePublic(b *bool) *UserPermi return upu } +// SetCanEdit sets the "CanEdit" field. +func (upu *UserPermissionsUpdate) SetCanEdit(b bool) *UserPermissionsUpdate { + upu.mutation.SetCanEdit(b) + return upu +} + +// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. +func (upu *UserPermissionsUpdate) SetNillableCanEdit(b *bool) *UserPermissionsUpdate { + if b != nil { + upu.SetCanEdit(*b) + } + return upu +} + // SetUser sets the "user" edge to the User entity. func (upu *UserPermissionsUpdate) SetUser(u *User) *UserPermissionsUpdate { return upu.SetUserID(u.ID) @@ -109,6 +116,9 @@ func (upu *UserPermissionsUpdate) ClearUser() *UserPermissionsUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (upu *UserPermissionsUpdate) Save(ctx context.Context) (int, error) { + if err := upu.defaults(); err != nil { + return 0, err + } return withHooks(ctx, upu.sqlSave, upu.mutation, upu.hooks) } @@ -134,6 +144,18 @@ func (upu *UserPermissionsUpdate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (upu *UserPermissionsUpdate) defaults() error { + if _, ok := upu.mutation.UpdateTime(); !ok { + if userpermissions.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized userpermissions.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := userpermissions.UpdateDefaultUpdateTime() + upu.mutation.SetUpdateTime(v) + } + return nil +} + func (upu *UserPermissionsUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec := sqlgraph.NewUpdateSpec(userpermissions.Table, userpermissions.Columns, sqlgraph.NewFieldSpec(userpermissions.FieldID, field.TypeString)) if ps := upu.mutation.predicates; len(ps) > 0 { @@ -143,8 +165,8 @@ func (upu *UserPermissionsUpdate) sqlSave(ctx context.Context) (n int, err error } } } - if value, ok := upu.mutation.CanEdit(); ok { - _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) + if value, ok := upu.mutation.UpdateTime(); ok { + _spec.SetField(userpermissions.FieldUpdateTime, field.TypeTime, value) } if value, ok := upu.mutation.Admin(); ok { _spec.SetField(userpermissions.FieldAdmin, field.TypeBool, value) @@ -152,6 +174,9 @@ func (upu *UserPermissionsUpdate) sqlSave(ctx context.Context) (n int, err error if value, ok := upu.mutation.CanCreatePublic(); ok { _spec.SetField(userpermissions.FieldCanCreatePublic, field.TypeBool, value) } + if value, ok := upu.mutation.CanEdit(); ok { + _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) + } if upu.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, @@ -201,6 +226,12 @@ type UserPermissionsUpdateOne struct { mutation *UserPermissionsMutation } +// SetUpdateTime sets the "update_time" field. +func (upuo *UserPermissionsUpdateOne) SetUpdateTime(t time.Time) *UserPermissionsUpdateOne { + upuo.mutation.SetUpdateTime(t) + return upuo +} + // SetUserID sets the "user_id" field. func (upuo *UserPermissionsUpdateOne) SetUserID(k ksuid.ID) *UserPermissionsUpdateOne { upuo.mutation.SetUserID(k) @@ -221,20 +252,6 @@ func (upuo *UserPermissionsUpdateOne) ClearUserID() *UserPermissionsUpdateOne { return upuo } -// SetCanEdit sets the "CanEdit" field. -func (upuo *UserPermissionsUpdateOne) SetCanEdit(b bool) *UserPermissionsUpdateOne { - upuo.mutation.SetCanEdit(b) - return upuo -} - -// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. -func (upuo *UserPermissionsUpdateOne) SetNillableCanEdit(b *bool) *UserPermissionsUpdateOne { - if b != nil { - upuo.SetCanEdit(*b) - } - return upuo -} - // SetAdmin sets the "Admin" field. func (upuo *UserPermissionsUpdateOne) SetAdmin(b bool) *UserPermissionsUpdateOne { upuo.mutation.SetAdmin(b) @@ -263,6 +280,20 @@ func (upuo *UserPermissionsUpdateOne) SetNillableCanCreatePublic(b *bool) *UserP return upuo } +// SetCanEdit sets the "CanEdit" field. +func (upuo *UserPermissionsUpdateOne) SetCanEdit(b bool) *UserPermissionsUpdateOne { + upuo.mutation.SetCanEdit(b) + return upuo +} + +// SetNillableCanEdit sets the "CanEdit" field if the given value is not nil. +func (upuo *UserPermissionsUpdateOne) SetNillableCanEdit(b *bool) *UserPermissionsUpdateOne { + if b != nil { + upuo.SetCanEdit(*b) + } + return upuo +} + // SetUser sets the "user" edge to the User entity. func (upuo *UserPermissionsUpdateOne) SetUser(u *User) *UserPermissionsUpdateOne { return upuo.SetUserID(u.ID) @@ -294,6 +325,9 @@ func (upuo *UserPermissionsUpdateOne) Select(field string, fields ...string) *Us // Save executes the query and returns the updated UserPermissions entity. func (upuo *UserPermissionsUpdateOne) Save(ctx context.Context) (*UserPermissions, error) { + if err := upuo.defaults(); err != nil { + return nil, err + } return withHooks(ctx, upuo.sqlSave, upuo.mutation, upuo.hooks) } @@ -319,6 +353,18 @@ func (upuo *UserPermissionsUpdateOne) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (upuo *UserPermissionsUpdateOne) defaults() error { + if _, ok := upuo.mutation.UpdateTime(); !ok { + if userpermissions.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized userpermissions.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } + v := userpermissions.UpdateDefaultUpdateTime() + upuo.mutation.SetUpdateTime(v) + } + return nil +} + func (upuo *UserPermissionsUpdateOne) sqlSave(ctx context.Context) (_node *UserPermissions, err error) { _spec := sqlgraph.NewUpdateSpec(userpermissions.Table, userpermissions.Columns, sqlgraph.NewFieldSpec(userpermissions.FieldID, field.TypeString)) id, ok := upuo.mutation.ID() @@ -345,8 +391,8 @@ func (upuo *UserPermissionsUpdateOne) sqlSave(ctx context.Context) (_node *UserP } } } - if value, ok := upuo.mutation.CanEdit(); ok { - _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) + if value, ok := upuo.mutation.UpdateTime(); ok { + _spec.SetField(userpermissions.FieldUpdateTime, field.TypeTime, value) } if value, ok := upuo.mutation.Admin(); ok { _spec.SetField(userpermissions.FieldAdmin, field.TypeBool, value) @@ -354,6 +400,9 @@ func (upuo *UserPermissionsUpdateOne) sqlSave(ctx context.Context) (_node *UserP if value, ok := upuo.mutation.CanCreatePublic(); ok { _spec.SetField(userpermissions.FieldCanCreatePublic, field.TypeBool, value) } + if value, ok := upuo.mutation.CanEdit(); ok { + _spec.SetField(userpermissions.FieldCanEdit, field.TypeBool, value) + } if upuo.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2O, diff --git a/internal/graph/ent.graphql b/internal/graph/ent.graphql index c87b6e25..e2456961 100644 --- a/internal/graph/ent.graphql +++ b/internal/graph/ent.graphql @@ -2,6 +2,8 @@ directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | I directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Author implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! sort: String! @@ -71,6 +73,24 @@ input AuthorWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -132,6 +152,8 @@ input AuthorWhereInput { } type Book implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int title: String! sort: String! @@ -147,6 +169,7 @@ type Book implements Node { tags: [Tag!] language: [Language!] shelf: [Shelf!] + files: [BookFile!] } """A connection to a list of items.""" type BookConnection { @@ -164,6 +187,110 @@ type BookEdge { """A cursor for use in pagination.""" cursor: Cursor! } +type BookFile implements Node { + id: ID! + createTime: Time! + updateTime: Time! + name: String! + path: String! + """Size in bytes""" + size: Int! + format: BookFileFormat! + book: Book! +} +"""BookFileFormat is enum for the field format""" +enum BookFileFormat @goModel(model: "lybbrio/internal/ent/bookfile.Format") { + AZW3 + EPUB + KEPUB + PDF + CBC + CBR + CB7 + CBZ + CBT +} +""" +BookFileWhereInput is used for filtering BookFile objects. +Input was generated by ent. +""" +input BookFileWhereInput { + not: BookFileWhereInput + and: [BookFileWhereInput!] + or: [BookFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """format field predicates""" + format: BookFileFormat + formatNEQ: BookFileFormat + formatIn: [BookFileFormat!] + formatNotIn: [BookFileFormat!] + """book edge predicates""" + hasBook: Boolean + hasBookWith: [BookWhereInput!] +} """Ordering options for Book connections""" input BookOrder { """The ordering direction.""" @@ -177,6 +304,7 @@ enum BookOrderField { NAME PUB_DATE ISBN + FILES_COUNT } """ BookWhereInput is used for filtering Book objects. @@ -195,6 +323,24 @@ input BookWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -323,12 +469,17 @@ input BookWhereInput { """shelf edge predicates""" hasShelf: Boolean hasShelfWith: [ShelfWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [BookFileWhereInput!] } """ CreateAuthorInput is used for create Author object. Input was generated by ent. """ input CreateAuthorInput { + createTime: Time + updateTime: Time calibreID: Int name: String! sort: String! @@ -340,6 +491,8 @@ CreateBookInput is used for create Book object. Input was generated by ent. """ input CreateBookInput { + createTime: Time + updateTime: Time calibreID: Int title: String! sort: String! @@ -355,12 +508,15 @@ input CreateBookInput { tagIDs: [ID!] languageIDs: [ID!] shelfIDs: [ID!] + fileIDs: [ID!] } """ CreateIdentifierInput is used for create Identifier object. Input was generated by ent. """ input CreateIdentifierInput { + createTime: Time + updateTime: Time calibreID: Int type: String! value: String! @@ -371,6 +527,8 @@ CreateLanguageInput is used for create Language object. Input was generated by ent. """ input CreateLanguageInput { + createTime: Time + updateTime: Time calibreID: Int code: String! bookIDs: [ID!] @@ -380,6 +538,8 @@ CreatePublisherInput is used for create Publisher object. Input was generated by ent. """ input CreatePublisherInput { + createTime: Time + updateTime: Time calibreID: Int name: String! bookIDs: [ID!] @@ -389,6 +549,8 @@ CreateSeriesInput is used for create Series object. Input was generated by ent. """ input CreateSeriesInput { + createTime: Time + updateTime: Time calibreID: Int name: String! sort: String! @@ -408,6 +570,8 @@ CreateUserInput is used for create User object. Input was generated by ent. """ input CreateUserInput { + createTime: Time + updateTime: Time username: String! passwordHash: String email: String! @@ -421,6 +585,8 @@ https://relay.dev/graphql/connections.htm#sec-Cursor scalar Cursor type Identifier implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int type: String! value: String! @@ -471,6 +637,24 @@ input IdentifierWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -516,6 +700,8 @@ input IdentifierWhereInput { } type Language implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int code: String! books( @@ -582,6 +768,24 @@ input LanguageWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -642,6 +846,8 @@ type PageInfo { } type Publisher implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! books( @@ -709,6 +915,24 @@ input PublisherWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -787,6 +1011,7 @@ type Query { """Filtering options for Books returned from the connection.""" where: BookWhereInput ): BookConnection! + bookFiles: [BookFile!]! identifiers( """Returns the elements in the list that come after the specified cursor.""" after: Cursor @@ -924,6 +1149,8 @@ type Query { } type Series implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! sort: String! @@ -973,6 +1200,24 @@ input SeriesWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -1018,6 +1263,8 @@ input SeriesWhereInput { } type Shelf implements Node { id: ID! + createTime: Time! + updateTime: Time! public: Boolean! userID: ID! name: String! @@ -1088,6 +1335,24 @@ input ShelfWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """public field predicates""" public: Boolean publicNEQ: Boolean @@ -1414,6 +1679,7 @@ UpdateAuthorInput is used for update Author object. Input was generated by ent. """ input UpdateAuthorInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -1429,6 +1695,7 @@ UpdateBookInput is used for update Book object. Input was generated by ent. """ input UpdateBookInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean title: String @@ -1463,12 +1730,16 @@ input UpdateBookInput { addShelfIDs: [ID!] removeShelfIDs: [ID!] clearShelf: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean } """ UpdateIdentifierInput is used for update Identifier object. Input was generated by ent. """ input UpdateIdentifierInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean type: String @@ -1480,6 +1751,7 @@ UpdateLanguageInput is used for update Language object. Input was generated by ent. """ input UpdateLanguageInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean code: String @@ -1492,6 +1764,7 @@ UpdatePublisherInput is used for update Publisher object. Input was generated by ent. """ input UpdatePublisherInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -1504,6 +1777,7 @@ UpdateSeriesInput is used for update Series object. Input was generated by ent. """ input UpdateSeriesInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -1517,6 +1791,7 @@ UpdateShelfInput is used for update Shelf object. Input was generated by ent. """ input UpdateShelfInput { + updateTime: Time public: Boolean name: String description: String @@ -1542,6 +1817,7 @@ UpdateUserInput is used for update User object. Input was generated by ent. """ input UpdateUserInput { + updateTime: Time username: String passwordHash: String clearPasswordHash: Boolean @@ -1552,6 +1828,8 @@ input UpdateUserInput { } type User implements Node { id: ID! + createTime: Time! + updateTime: Time! username: String! email: String! shelves: [Shelf!] @@ -1570,10 +1848,12 @@ enum UserOrderField { } type UserPermissions implements Node { id: ID! + createTime: Time! + updateTime: Time! userID: ID - canedit: Boolean! @goField(name: "CanEdit", forceResolver: false) admin: Boolean! cancreatepublic: Boolean! @goField(name: "CanCreatePublic", forceResolver: false) + canedit: Boolean! @goField(name: "CanEdit", forceResolver: false) user: User } """ @@ -1593,6 +1873,24 @@ input UserPermissionsWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """user_id field predicates""" userID: ID userIDNEQ: ID @@ -1609,15 +1907,15 @@ input UserPermissionsWhereInput { userIDNotNil: Boolean userIDEqualFold: ID userIDContainsFold: ID - """CanEdit field predicates""" - canedit: Boolean - caneditNEQ: Boolean """Admin field predicates""" admin: Boolean adminNEQ: Boolean """CanCreatePublic field predicates""" cancreatepublic: Boolean cancreatepublicNEQ: Boolean + """CanEdit field predicates""" + canedit: Boolean + caneditNEQ: Boolean """user edge predicates""" hasUser: Boolean hasUserWith: [UserWhereInput!] @@ -1639,6 +1937,24 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """username field predicates""" username: String usernameNEQ: String diff --git a/internal/graph/ent.resolvers.go b/internal/graph/ent.resolvers.go index 14c16f3a..eac41455 100644 --- a/internal/graph/ent.resolvers.go +++ b/internal/graph/ent.resolvers.go @@ -6,6 +6,7 @@ package graph import ( "context" + "fmt" "lybbrio/internal/ent" "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/graph/generated" @@ -41,6 +42,11 @@ func (r *queryResolver) Books(ctx context.Context, after *entgql.Cursor[ksuid.ID ) } +// BookFiles is the resolver for the bookFiles field. +func (r *queryResolver) BookFiles(ctx context.Context) ([]*ent.BookFile, error) { + panic(fmt.Errorf("not implemented: BookFiles - bookFiles")) +} + // Identifiers is the resolver for the identifiers field. func (r *queryResolver) Identifiers(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.IdentifierOrder, where *ent.IdentifierWhereInput) (*ent.IdentifierConnection, error) { return r.client.Identifier.Query(). diff --git a/internal/graph/generated/generated.go b/internal/graph/generated/generated.go index 552d1ce1..ccca2a47 100644 --- a/internal/graph/generated/generated.go +++ b/internal/graph/generated/generated.go @@ -9,6 +9,7 @@ import ( "fmt" "lybbrio" "lybbrio/internal/ent" + "lybbrio/internal/ent/bookfile" "lybbrio/internal/ent/schema/ksuid" "lybbrio/internal/ent/schema/task_enums" "strconv" @@ -52,12 +53,14 @@ type DirectiveRoot struct { type ComplexityRoot struct { Author struct { - Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int - CalibreID func(childComplexity int) int - ID func(childComplexity int) int - Link func(childComplexity int) int - Name func(childComplexity int) int - Sort func(childComplexity int) int + Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int + CalibreID func(childComplexity int) int + CreateTime func(childComplexity int) int + ID func(childComplexity int) int + Link func(childComplexity int) int + Name func(childComplexity int) int + Sort func(childComplexity int) int + UpdateTime func(childComplexity int) int } AuthorConnection struct { @@ -74,7 +77,9 @@ type ComplexityRoot struct { Book struct { Authors func(childComplexity int) int CalibreID func(childComplexity int) int + CreateTime func(childComplexity int) int Description func(childComplexity int) int + Files func(childComplexity int) int ID func(childComplexity int) int Identifiers func(childComplexity int) int Isbn func(childComplexity int) int @@ -88,6 +93,7 @@ type ComplexityRoot struct { Sort func(childComplexity int) int Tags func(childComplexity int) int Title func(childComplexity int) int + UpdateTime func(childComplexity int) int } BookConnection struct { @@ -101,12 +107,25 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + BookFile struct { + Book func(childComplexity int) int + CreateTime func(childComplexity int) int + Format func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + Path func(childComplexity int) int + Size func(childComplexity int) int + UpdateTime func(childComplexity int) int + } + Identifier struct { - Book func(childComplexity int) int - CalibreID func(childComplexity int) int - ID func(childComplexity int) int - Type func(childComplexity int) int - Value func(childComplexity int) int + Book func(childComplexity int) int + CalibreID func(childComplexity int) int + CreateTime func(childComplexity int) int + ID func(childComplexity int) int + Type func(childComplexity int) int + UpdateTime func(childComplexity int) int + Value func(childComplexity int) int } IdentifierConnection struct { @@ -121,10 +140,12 @@ type ComplexityRoot struct { } Language struct { - Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int - CalibreID func(childComplexity int) int - Code func(childComplexity int) int - ID func(childComplexity int) int + Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int + CalibreID func(childComplexity int) int + Code func(childComplexity int) int + CreateTime func(childComplexity int) int + ID func(childComplexity int) int + UpdateTime func(childComplexity int) int } LanguageConnection struct { @@ -168,10 +189,12 @@ type ComplexityRoot struct { } Publisher struct { - Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int - CalibreID func(childComplexity int) int - ID func(childComplexity int) int - Name func(childComplexity int) int + Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int + CalibreID func(childComplexity int) int + CreateTime func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + UpdateTime func(childComplexity int) int } PublisherConnection struct { @@ -187,6 +210,7 @@ type ComplexityRoot struct { Query struct { Authors func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.AuthorOrder, where *ent.AuthorWhereInput) int + BookFiles func(childComplexity int) int Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int Identifiers func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.IdentifierOrder, where *ent.IdentifierWhereInput) int Languages func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.LanguageOrder, where *ent.LanguageWhereInput) int @@ -202,11 +226,13 @@ type ComplexityRoot struct { } Series struct { - Books func(childComplexity int) int - CalibreID func(childComplexity int) int - ID func(childComplexity int) int - Name func(childComplexity int) int - Sort func(childComplexity int) int + Books func(childComplexity int) int + CalibreID func(childComplexity int) int + CreateTime func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int + Sort func(childComplexity int) int + UpdateTime func(childComplexity int) int } SeriesConnection struct { @@ -222,10 +248,12 @@ type ComplexityRoot struct { Shelf struct { Books func(childComplexity int, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) int + CreateTime func(childComplexity int) int Description func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Public func(childComplexity int) int + UpdateTime func(childComplexity int) int User func(childComplexity int) int UserID func(childComplexity int) int } @@ -285,9 +313,11 @@ type ComplexityRoot struct { } User struct { + CreateTime func(childComplexity int) int Email func(childComplexity int) int ID func(childComplexity int) int Shelves func(childComplexity int) int + UpdateTime func(childComplexity int) int UserPermissions func(childComplexity int) int Username func(childComplexity int) int } @@ -296,7 +326,9 @@ type ComplexityRoot struct { Admin func(childComplexity int) int CanCreatePublic func(childComplexity int) int CanEdit func(childComplexity int) int + CreateTime func(childComplexity int) int ID func(childComplexity int) int + UpdateTime func(childComplexity int) int User func(childComplexity int) int UserID func(childComplexity int) int } @@ -328,6 +360,7 @@ type QueryResolver interface { Nodes(ctx context.Context, ids []ksuid.ID) ([]ent.Noder, error) Authors(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.AuthorOrder, where *ent.AuthorWhereInput) (*ent.AuthorConnection, error) Books(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.BookOrder, where *ent.BookWhereInput) (*ent.BookConnection, error) + BookFiles(ctx context.Context) ([]*ent.BookFile, error) Identifiers(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.IdentifierOrder, where *ent.IdentifierWhereInput) (*ent.IdentifierConnection, error) Languages(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.LanguageOrder, where *ent.LanguageWhereInput) (*ent.LanguageConnection, error) Publishers(ctx context.Context, after *entgql.Cursor[ksuid.ID], first *int, before *entgql.Cursor[ksuid.ID], last *int, orderBy []*ent.PublisherOrder, where *ent.PublisherWhereInput) (*ent.PublisherConnection, error) @@ -377,6 +410,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Author.CalibreID(childComplexity), true + case "Author.createTime": + if e.complexity.Author.CreateTime == nil { + break + } + + return e.complexity.Author.CreateTime(childComplexity), true + case "Author.id": if e.complexity.Author.ID == nil { break @@ -405,6 +445,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Author.Sort(childComplexity), true + case "Author.updateTime": + if e.complexity.Author.UpdateTime == nil { + break + } + + return e.complexity.Author.UpdateTime(childComplexity), true + case "AuthorConnection.edges": if e.complexity.AuthorConnection.Edges == nil { break @@ -454,6 +501,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Book.CalibreID(childComplexity), true + case "Book.createTime": + if e.complexity.Book.CreateTime == nil { + break + } + + return e.complexity.Book.CreateTime(childComplexity), true + case "Book.description": if e.complexity.Book.Description == nil { break @@ -461,6 +515,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Book.Description(childComplexity), true + case "Book.files": + if e.complexity.Book.Files == nil { + break + } + + return e.complexity.Book.Files(childComplexity), true + case "Book.id": if e.complexity.Book.ID == nil { break @@ -552,6 +613,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Book.Title(childComplexity), true + case "Book.updateTime": + if e.complexity.Book.UpdateTime == nil { + break + } + + return e.complexity.Book.UpdateTime(childComplexity), true + case "BookConnection.edges": if e.complexity.BookConnection.Edges == nil { break @@ -587,6 +655,62 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BookEdge.Node(childComplexity), true + case "BookFile.book": + if e.complexity.BookFile.Book == nil { + break + } + + return e.complexity.BookFile.Book(childComplexity), true + + case "BookFile.createTime": + if e.complexity.BookFile.CreateTime == nil { + break + } + + return e.complexity.BookFile.CreateTime(childComplexity), true + + case "BookFile.format": + if e.complexity.BookFile.Format == nil { + break + } + + return e.complexity.BookFile.Format(childComplexity), true + + case "BookFile.id": + if e.complexity.BookFile.ID == nil { + break + } + + return e.complexity.BookFile.ID(childComplexity), true + + case "BookFile.name": + if e.complexity.BookFile.Name == nil { + break + } + + return e.complexity.BookFile.Name(childComplexity), true + + case "BookFile.path": + if e.complexity.BookFile.Path == nil { + break + } + + return e.complexity.BookFile.Path(childComplexity), true + + case "BookFile.size": + if e.complexity.BookFile.Size == nil { + break + } + + return e.complexity.BookFile.Size(childComplexity), true + + case "BookFile.updateTime": + if e.complexity.BookFile.UpdateTime == nil { + break + } + + return e.complexity.BookFile.UpdateTime(childComplexity), true + case "Identifier.book": if e.complexity.Identifier.Book == nil { break @@ -601,6 +725,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Identifier.CalibreID(childComplexity), true + case "Identifier.createTime": + if e.complexity.Identifier.CreateTime == nil { + break + } + + return e.complexity.Identifier.CreateTime(childComplexity), true + case "Identifier.id": if e.complexity.Identifier.ID == nil { break @@ -615,6 +746,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Identifier.Type(childComplexity), true + case "Identifier.updateTime": + if e.complexity.Identifier.UpdateTime == nil { + break + } + + return e.complexity.Identifier.UpdateTime(childComplexity), true + case "Identifier.value": if e.complexity.Identifier.Value == nil { break @@ -683,6 +821,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Language.Code(childComplexity), true + case "Language.createTime": + if e.complexity.Language.CreateTime == nil { + break + } + + return e.complexity.Language.CreateTime(childComplexity), true + case "Language.id": if e.complexity.Language.ID == nil { break @@ -690,6 +835,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Language.ID(childComplexity), true + case "Language.updateTime": + if e.complexity.Language.UpdateTime == nil { + break + } + + return e.complexity.Language.UpdateTime(childComplexity), true + case "LanguageConnection.edges": if e.complexity.LanguageConnection.Edges == nil { break @@ -1000,6 +1152,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Publisher.CalibreID(childComplexity), true + case "Publisher.createTime": + if e.complexity.Publisher.CreateTime == nil { + break + } + + return e.complexity.Publisher.CreateTime(childComplexity), true + case "Publisher.id": if e.complexity.Publisher.ID == nil { break @@ -1014,6 +1173,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Publisher.Name(childComplexity), true + case "Publisher.updateTime": + if e.complexity.Publisher.UpdateTime == nil { + break + } + + return e.complexity.Publisher.UpdateTime(childComplexity), true + case "PublisherConnection.edges": if e.complexity.PublisherConnection.Edges == nil { break @@ -1061,6 +1227,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Authors(childComplexity, args["after"].(*entgql.Cursor[ksuid.ID]), args["first"].(*int), args["before"].(*entgql.Cursor[ksuid.ID]), args["last"].(*int), args["orderBy"].([]*ent.AuthorOrder), args["where"].(*ent.AuthorWhereInput)), true + case "Query.bookFiles": + if e.complexity.Query.BookFiles == nil { + break + } + + return e.complexity.Query.BookFiles(childComplexity), true + case "Query.books": if e.complexity.Query.Books == nil { break @@ -1209,6 +1382,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Series.CalibreID(childComplexity), true + case "Series.createTime": + if e.complexity.Series.CreateTime == nil { + break + } + + return e.complexity.Series.CreateTime(childComplexity), true + case "Series.id": if e.complexity.Series.ID == nil { break @@ -1230,6 +1410,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Series.Sort(childComplexity), true + case "Series.updateTime": + if e.complexity.Series.UpdateTime == nil { + break + } + + return e.complexity.Series.UpdateTime(childComplexity), true + case "SeriesConnection.edges": if e.complexity.SeriesConnection.Edges == nil { break @@ -1277,6 +1464,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Shelf.Books(childComplexity, args["after"].(*entgql.Cursor[ksuid.ID]), args["first"].(*int), args["before"].(*entgql.Cursor[ksuid.ID]), args["last"].(*int), args["orderBy"].([]*ent.BookOrder), args["where"].(*ent.BookWhereInput)), true + case "Shelf.createTime": + if e.complexity.Shelf.CreateTime == nil { + break + } + + return e.complexity.Shelf.CreateTime(childComplexity), true + case "Shelf.description": if e.complexity.Shelf.Description == nil { break @@ -1305,6 +1499,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Shelf.Public(childComplexity), true + case "Shelf.updateTime": + if e.complexity.Shelf.UpdateTime == nil { + break + } + + return e.complexity.Shelf.UpdateTime(childComplexity), true + case "Shelf.user": if e.complexity.Shelf.User == nil { break @@ -1534,6 +1735,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TaskEdge.Node(childComplexity), true + case "User.createTime": + if e.complexity.User.CreateTime == nil { + break + } + + return e.complexity.User.CreateTime(childComplexity), true + case "User.email": if e.complexity.User.Email == nil { break @@ -1555,6 +1763,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Shelves(childComplexity), true + case "User.updateTime": + if e.complexity.User.UpdateTime == nil { + break + } + + return e.complexity.User.UpdateTime(childComplexity), true + case "User.userPermissions": if e.complexity.User.UserPermissions == nil { break @@ -1590,6 +1805,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserPermissions.CanEdit(childComplexity), true + case "UserPermissions.createTime": + if e.complexity.UserPermissions.CreateTime == nil { + break + } + + return e.complexity.UserPermissions.CreateTime(childComplexity), true + case "UserPermissions.id": if e.complexity.UserPermissions.ID == nil { break @@ -1597,6 +1819,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserPermissions.ID(childComplexity), true + case "UserPermissions.updateTime": + if e.complexity.UserPermissions.UpdateTime == nil { + break + } + + return e.complexity.UserPermissions.UpdateTime(childComplexity), true + case "UserPermissions.user": if e.complexity.UserPermissions.User == nil { break @@ -1621,6 +1850,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputAuthorOrder, ec.unmarshalInputAuthorWhereInput, + ec.unmarshalInputBookFileWhereInput, ec.unmarshalInputBookOrder, ec.unmarshalInputBookWhereInput, ec.unmarshalInputCreateAuthorInput, @@ -1760,6 +1990,8 @@ var sources = []*ast.Source{ directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION type Author implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! sort: String! @@ -1829,6 +2061,24 @@ input AuthorWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -1890,6 +2140,8 @@ input AuthorWhereInput { } type Book implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int title: String! sort: String! @@ -1905,6 +2157,7 @@ type Book implements Node { tags: [Tag!] language: [Language!] shelf: [Shelf!] + files: [BookFile!] } """A connection to a list of items.""" type BookConnection { @@ -1922,6 +2175,110 @@ type BookEdge { """A cursor for use in pagination.""" cursor: Cursor! } +type BookFile implements Node { + id: ID! + createTime: Time! + updateTime: Time! + name: String! + path: String! + """Size in bytes""" + size: Int! + format: BookFileFormat! + book: Book! +} +"""BookFileFormat is enum for the field format""" +enum BookFileFormat @goModel(model: "lybbrio/internal/ent/bookfile.Format") { + AZW3 + EPUB + KEPUB + PDF + CBC + CBR + CB7 + CBZ + CBT +} +""" +BookFileWhereInput is used for filtering BookFile objects. +Input was generated by ent. +""" +input BookFileWhereInput { + not: BookFileWhereInput + and: [BookFileWhereInput!] + or: [BookFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """format field predicates""" + format: BookFileFormat + formatNEQ: BookFileFormat + formatIn: [BookFileFormat!] + formatNotIn: [BookFileFormat!] + """book edge predicates""" + hasBook: Boolean + hasBookWith: [BookWhereInput!] +} """Ordering options for Book connections""" input BookOrder { """The ordering direction.""" @@ -1935,6 +2292,7 @@ enum BookOrderField { NAME PUB_DATE ISBN + FILES_COUNT } """ BookWhereInput is used for filtering Book objects. @@ -1953,6 +2311,24 @@ input BookWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -2081,12 +2457,17 @@ input BookWhereInput { """shelf edge predicates""" hasShelf: Boolean hasShelfWith: [ShelfWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [BookFileWhereInput!] } """ CreateAuthorInput is used for create Author object. Input was generated by ent. """ input CreateAuthorInput { + createTime: Time + updateTime: Time calibreID: Int name: String! sort: String! @@ -2098,6 +2479,8 @@ CreateBookInput is used for create Book object. Input was generated by ent. """ input CreateBookInput { + createTime: Time + updateTime: Time calibreID: Int title: String! sort: String! @@ -2113,12 +2496,15 @@ input CreateBookInput { tagIDs: [ID!] languageIDs: [ID!] shelfIDs: [ID!] + fileIDs: [ID!] } """ CreateIdentifierInput is used for create Identifier object. Input was generated by ent. """ input CreateIdentifierInput { + createTime: Time + updateTime: Time calibreID: Int type: String! value: String! @@ -2129,6 +2515,8 @@ CreateLanguageInput is used for create Language object. Input was generated by ent. """ input CreateLanguageInput { + createTime: Time + updateTime: Time calibreID: Int code: String! bookIDs: [ID!] @@ -2138,6 +2526,8 @@ CreatePublisherInput is used for create Publisher object. Input was generated by ent. """ input CreatePublisherInput { + createTime: Time + updateTime: Time calibreID: Int name: String! bookIDs: [ID!] @@ -2147,6 +2537,8 @@ CreateSeriesInput is used for create Series object. Input was generated by ent. """ input CreateSeriesInput { + createTime: Time + updateTime: Time calibreID: Int name: String! sort: String! @@ -2166,6 +2558,8 @@ CreateUserInput is used for create User object. Input was generated by ent. """ input CreateUserInput { + createTime: Time + updateTime: Time username: String! passwordHash: String email: String! @@ -2179,6 +2573,8 @@ https://relay.dev/graphql/connections.htm#sec-Cursor scalar Cursor type Identifier implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int type: String! value: String! @@ -2229,6 +2625,24 @@ input IdentifierWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -2274,6 +2688,8 @@ input IdentifierWhereInput { } type Language implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int code: String! books( @@ -2340,6 +2756,24 @@ input LanguageWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -2400,6 +2834,8 @@ type PageInfo { } type Publisher implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! books( @@ -2467,6 +2903,24 @@ input PublisherWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -2545,6 +2999,7 @@ type Query { """Filtering options for Books returned from the connection.""" where: BookWhereInput ): BookConnection! + bookFiles: [BookFile!]! identifiers( """Returns the elements in the list that come after the specified cursor.""" after: Cursor @@ -2682,6 +3137,8 @@ type Query { } type Series implements Node { id: ID! + createTime: Time! + updateTime: Time! calibreID: Int name: String! sort: String! @@ -2731,6 +3188,24 @@ input SeriesWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """calibre_id field predicates""" calibreID: Int calibreIDNEQ: Int @@ -2776,6 +3251,8 @@ input SeriesWhereInput { } type Shelf implements Node { id: ID! + createTime: Time! + updateTime: Time! public: Boolean! userID: ID! name: String! @@ -2846,6 +3323,24 @@ input ShelfWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """public field predicates""" public: Boolean publicNEQ: Boolean @@ -3172,6 +3667,7 @@ UpdateAuthorInput is used for update Author object. Input was generated by ent. """ input UpdateAuthorInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -3187,6 +3683,7 @@ UpdateBookInput is used for update Book object. Input was generated by ent. """ input UpdateBookInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean title: String @@ -3221,12 +3718,16 @@ input UpdateBookInput { addShelfIDs: [ID!] removeShelfIDs: [ID!] clearShelf: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean } """ UpdateIdentifierInput is used for update Identifier object. Input was generated by ent. """ input UpdateIdentifierInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean type: String @@ -3238,6 +3739,7 @@ UpdateLanguageInput is used for update Language object. Input was generated by ent. """ input UpdateLanguageInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean code: String @@ -3250,6 +3752,7 @@ UpdatePublisherInput is used for update Publisher object. Input was generated by ent. """ input UpdatePublisherInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -3262,6 +3765,7 @@ UpdateSeriesInput is used for update Series object. Input was generated by ent. """ input UpdateSeriesInput { + updateTime: Time calibreID: Int clearCalibreID: Boolean name: String @@ -3275,6 +3779,7 @@ UpdateShelfInput is used for update Shelf object. Input was generated by ent. """ input UpdateShelfInput { + updateTime: Time public: Boolean name: String description: String @@ -3300,6 +3805,7 @@ UpdateUserInput is used for update User object. Input was generated by ent. """ input UpdateUserInput { + updateTime: Time username: String passwordHash: String clearPasswordHash: Boolean @@ -3310,6 +3816,8 @@ input UpdateUserInput { } type User implements Node { id: ID! + createTime: Time! + updateTime: Time! username: String! email: String! shelves: [Shelf!] @@ -3328,10 +3836,12 @@ enum UserOrderField { } type UserPermissions implements Node { id: ID! + createTime: Time! + updateTime: Time! userID: ID - canedit: Boolean! @goField(name: "CanEdit", forceResolver: false) admin: Boolean! cancreatepublic: Boolean! @goField(name: "CanCreatePublic", forceResolver: false) + canedit: Boolean! @goField(name: "CanEdit", forceResolver: false) user: User } """ @@ -3351,6 +3861,24 @@ input UserPermissionsWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """user_id field predicates""" userID: ID userIDNEQ: ID @@ -3367,15 +3895,15 @@ input UserPermissionsWhereInput { userIDNotNil: Boolean userIDEqualFold: ID userIDContainsFold: ID - """CanEdit field predicates""" - canedit: Boolean - caneditNEQ: Boolean """Admin field predicates""" admin: Boolean adminNEQ: Boolean """CanCreatePublic field predicates""" cancreatepublic: Boolean cancreatepublicNEQ: Boolean + """CanEdit field predicates""" + canedit: Boolean + caneditNEQ: Boolean """user edge predicates""" hasUser: Boolean hasUserWith: [UserWhereInput!] @@ -3397,6 +3925,24 @@ input UserWhereInput { idGTE: ID idLT: ID idLTE: ID + """create_time field predicates""" + createTime: Time + createTimeNEQ: Time + createTimeIn: [Time!] + createTimeNotIn: [Time!] + createTimeGT: Time + createTimeGTE: Time + createTimeLT: Time + createTimeLTE: Time + """update_time field predicates""" + updateTime: Time + updateTimeNEQ: Time + updateTimeIn: [Time!] + updateTimeNotIn: [Time!] + updateTimeGT: Time + updateTimeGTE: Time + updateTimeLT: Time + updateTimeLTE: Time """username field predicates""" username: String usernameNEQ: String @@ -4824,6 +5370,94 @@ func (ec *executionContext) fieldContext_Author_id(ctx context.Context, field gr return fc, nil } +func (ec *executionContext) _Author_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Author) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Author_createTime(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreateTime, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Author_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Author", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Author_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Author) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Author_updateTime(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.UpdateTime, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Author_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Author", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Author_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Author) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Author_calibreID(ctx, field) if err != nil { @@ -5240,6 +5874,10 @@ func (ec *executionContext) fieldContext_AuthorEdge_node(ctx context.Context, fi switch field.Name { case "id": return ec.fieldContext_Author_id(ctx, field) + case "createTime": + return ec.fieldContext_Author_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Author_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Author_calibreID(ctx, field) case "name": @@ -5345,8 +5983,8 @@ func (ec *executionContext) fieldContext_Book_id(ctx context.Context, field grap return fc, nil } -func (ec *executionContext) _Book_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Book_calibreID(ctx, field) +func (ec *executionContext) _Book_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Book_createTime(ctx, field) if err != nil { return graphql.Null } @@ -5359,35 +5997,38 @@ func (ec *executionContext) _Book_calibreID(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CalibreID, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOInt2int64(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Book_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Book_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Book", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Book_title(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Book_title(ctx, field) +func (ec *executionContext) _Book_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Book_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -5400,7 +6041,92 @@ func (ec *executionContext) _Book_title(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Title, nil + return obj.UpdateTime, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Book_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Book", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Book_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Book_calibreID(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CalibreID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int64) + fc.Result = res + return ec.marshalOInt2int64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Book_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Book", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Book_title(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Book_title(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil }) if err != nil { ec.Error(ctx, err) @@ -5720,6 +6446,10 @@ func (ec *executionContext) fieldContext_Book_authors(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Author_id(ctx, field) + case "createTime": + return ec.fieldContext_Author_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Author_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Author_calibreID(ctx, field) case "name": @@ -5775,6 +6505,10 @@ func (ec *executionContext) fieldContext_Book_publisher(ctx context.Context, fie switch field.Name { case "id": return ec.fieldContext_Publisher_id(ctx, field) + case "createTime": + return ec.fieldContext_Publisher_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Publisher_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Publisher_calibreID(ctx, field) case "name": @@ -5826,6 +6560,10 @@ func (ec *executionContext) fieldContext_Book_series(ctx context.Context, field switch field.Name { case "id": return ec.fieldContext_Series_id(ctx, field) + case "createTime": + return ec.fieldContext_Series_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Series_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Series_calibreID(ctx, field) case "name": @@ -5879,6 +6617,10 @@ func (ec *executionContext) fieldContext_Book_identifiers(ctx context.Context, f switch field.Name { case "id": return ec.fieldContext_Identifier_id(ctx, field) + case "createTime": + return ec.fieldContext_Identifier_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Identifier_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Identifier_calibreID(ctx, field) case "type": @@ -5983,6 +6725,10 @@ func (ec *executionContext) fieldContext_Book_language(ctx context.Context, fiel switch field.Name { case "id": return ec.fieldContext_Language_id(ctx, field) + case "createTime": + return ec.fieldContext_Language_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Language_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Language_calibreID(ctx, field) case "code": @@ -6034,6 +6780,10 @@ func (ec *executionContext) fieldContext_Book_shelf(ctx context.Context, field g switch field.Name { case "id": return ec.fieldContext_Shelf_id(ctx, field) + case "createTime": + return ec.fieldContext_Shelf_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Shelf_updateTime(ctx, field) case "public": return ec.fieldContext_Shelf_public(ctx, field) case "userID": @@ -6053,6 +6803,65 @@ func (ec *executionContext) fieldContext_Book_shelf(ctx context.Context, field g return fc, nil } +func (ec *executionContext) _Book_files(ctx context.Context, field graphql.CollectedField, obj *ent.Book) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Book_files(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Files(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.BookFile) + fc.Result = res + return ec.marshalOBookFile2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Book_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Book", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_BookFile_id(ctx, field) + case "createTime": + return ec.fieldContext_BookFile_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_BookFile_updateTime(ctx, field) + case "name": + return ec.fieldContext_BookFile_name(ctx, field) + case "path": + return ec.fieldContext_BookFile_path(ctx, field) + case "size": + return ec.fieldContext_BookFile_size(ctx, field) + case "format": + return ec.fieldContext_BookFile_format(ctx, field) + case "book": + return ec.fieldContext_BookFile_book(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BookFile", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _BookConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.BookConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_BookConnection_edges(ctx, field) if err != nil { @@ -6236,6 +7045,10 @@ func (ec *executionContext) fieldContext_BookEdge_node(ctx context.Context, fiel switch field.Name { case "id": return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) case "calibreID": return ec.fieldContext_Book_calibreID(ctx, field) case "title": @@ -6266,6 +7079,8 @@ func (ec *executionContext) fieldContext_BookEdge_node(ctx context.Context, fiel return ec.fieldContext_Book_language(ctx, field) case "shelf": return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, @@ -6317,8 +7132,8 @@ func (ec *executionContext) fieldContext_BookEdge_cursor(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _Identifier_id(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Identifier_id(ctx, field) +func (ec *executionContext) _BookFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_id(ctx, field) if err != nil { return graphql.Null } @@ -6348,9 +7163,9 @@ func (ec *executionContext) _Identifier_id(ctx context.Context, field graphql.Co return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Identifier_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Identifier", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, @@ -6361,8 +7176,8 @@ func (ec *executionContext) fieldContext_Identifier_id(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Identifier_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Identifier_calibreID(ctx, field) +func (ec *executionContext) _BookFile_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_createTime(ctx, field) if err != nil { return graphql.Null } @@ -6375,35 +7190,38 @@ func (ec *executionContext) _Identifier_calibreID(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CalibreID, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(int64) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOInt2int64(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Identifier_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Identifier", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Identifier_type(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Identifier_type(ctx, field) +func (ec *executionContext) _BookFile_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -6416,7 +7234,7 @@ func (ec *executionContext) _Identifier_type(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -6428,26 +7246,26 @@ func (ec *executionContext) _Identifier_type(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Identifier_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Identifier", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Identifier_value(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Identifier_value(ctx, field) +func (ec *executionContext) _BookFile_name(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_name(ctx, field) if err != nil { return graphql.Null } @@ -6460,7 +7278,7 @@ func (ec *executionContext) _Identifier_value(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Value, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -6477,9 +7295,9 @@ func (ec *executionContext) _Identifier_value(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Identifier_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Identifier", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, @@ -6490,8 +7308,8 @@ func (ec *executionContext) fieldContext_Identifier_value(ctx context.Context, f return fc, nil } -func (ec *executionContext) _Identifier_book(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Identifier_book(ctx, field) +func (ec *executionContext) _BookFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_path(ctx, field) if err != nil { return graphql.Null } @@ -6504,7 +7322,7 @@ func (ec *executionContext) _Identifier_book(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Book(ctx) + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) @@ -6516,60 +7334,26 @@ func (ec *executionContext) _Identifier_book(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(*ent.Book) + res := resTmp.(string) fc.Result = res - return ec.marshalNBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Identifier_book(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Identifier", + Object: "BookFile", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Book_id(ctx, field) - case "calibreID": - return ec.fieldContext_Book_calibreID(ctx, field) - case "title": - return ec.fieldContext_Book_title(ctx, field) - case "sort": - return ec.fieldContext_Book_sort(ctx, field) - case "publishedDate": - return ec.fieldContext_Book_publishedDate(ctx, field) - case "path": - return ec.fieldContext_Book_path(ctx, field) - case "isbn": - return ec.fieldContext_Book_isbn(ctx, field) - case "description": - return ec.fieldContext_Book_description(ctx, field) - case "seriesIndex": - return ec.fieldContext_Book_seriesIndex(ctx, field) - case "authors": - return ec.fieldContext_Book_authors(ctx, field) - case "publisher": - return ec.fieldContext_Book_publisher(ctx, field) - case "series": - return ec.fieldContext_Book_series(ctx, field) - case "identifiers": - return ec.fieldContext_Book_identifiers(ctx, field) - case "tags": - return ec.fieldContext_Book_tags(ctx, field) - case "language": - return ec.fieldContext_Book_language(ctx, field) - case "shelf": - return ec.fieldContext_Book_shelf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _IdentifierConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IdentifierConnection_edges(ctx, field) +func (ec *executionContext) _BookFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_size(ctx, field) if err != nil { return graphql.Null } @@ -6582,41 +7366,38 @@ func (ec *executionContext) _IdentifierConnection_edges(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.Size, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.IdentifierEdge) + res := resTmp.(int64) fc.Result = res - return ec.marshalOIdentifierEdge2ᚕᚖlybbrioᚋinternalᚋentᚐIdentifierEdge(ctx, field.Selections, res) + return ec.marshalNInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IdentifierConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IdentifierConnection", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_IdentifierEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_IdentifierEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type IdentifierEdge", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _IdentifierConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IdentifierConnection_pageInfo(ctx, field) +func (ec *executionContext) _BookFile_format(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_format(ctx, field) if err != nil { return graphql.Null } @@ -6629,7 +7410,7 @@ func (ec *executionContext) _IdentifierConnection_pageInfo(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.Format, nil }) if err != nil { ec.Error(ctx, err) @@ -6641,36 +7422,26 @@ func (ec *executionContext) _IdentifierConnection_pageInfo(ctx context.Context, } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.(bookfile.Format) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNBookFileFormat2lybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IdentifierConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_format(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IdentifierConnection", + Object: "BookFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type BookFileFormat does not have child fields") }, } return fc, nil } -func (ec *executionContext) _IdentifierConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IdentifierConnection_totalCount(ctx, field) +func (ec *executionContext) _BookFile_book(ctx context.Context, field graphql.CollectedField, obj *ent.BookFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BookFile_book(ctx, field) if err != nil { return graphql.Null } @@ -6683,7 +7454,7 @@ func (ec *executionContext) _IdentifierConnection_totalCount(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.Book(ctx) }) if err != nil { ec.Error(ctx, err) @@ -6695,26 +7466,66 @@ func (ec *executionContext) _IdentifierConnection_totalCount(ctx context.Context } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*ent.Book) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IdentifierConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_BookFile_book(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IdentifierConnection", + Object: "BookFile", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Book_calibreID(ctx, field) + case "title": + return ec.fieldContext_Book_title(ctx, field) + case "sort": + return ec.fieldContext_Book_sort(ctx, field) + case "publishedDate": + return ec.fieldContext_Book_publishedDate(ctx, field) + case "path": + return ec.fieldContext_Book_path(ctx, field) + case "isbn": + return ec.fieldContext_Book_isbn(ctx, field) + case "description": + return ec.fieldContext_Book_description(ctx, field) + case "seriesIndex": + return ec.fieldContext_Book_seriesIndex(ctx, field) + case "authors": + return ec.fieldContext_Book_authors(ctx, field) + case "publisher": + return ec.fieldContext_Book_publisher(ctx, field) + case "series": + return ec.fieldContext_Book_series(ctx, field) + case "identifiers": + return ec.fieldContext_Book_identifiers(ctx, field) + case "tags": + return ec.fieldContext_Book_tags(ctx, field) + case "language": + return ec.fieldContext_Book_language(ctx, field) + case "shelf": + return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, } return fc, nil } -func (ec *executionContext) _IdentifierEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IdentifierEdge_node(ctx, field) +func (ec *executionContext) _Identifier_id(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_id(ctx, field) if err != nil { return graphql.Null } @@ -6727,47 +7538,38 @@ func (ec *executionContext) _IdentifierEdge_node(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Identifier) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IdentifierEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IdentifierEdge", + Object: "Identifier", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Identifier_id(ctx, field) - case "calibreID": - return ec.fieldContext_Identifier_calibreID(ctx, field) - case "type": - return ec.fieldContext_Identifier_type(ctx, field) - case "value": - return ec.fieldContext_Identifier_value(ctx, field) - case "book": - return ec.fieldContext_Identifier_book(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _IdentifierEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_IdentifierEdge_cursor(ctx, field) +func (ec *executionContext) _Identifier_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_createTime(ctx, field) if err != nil { return graphql.Null } @@ -6780,7 +7582,7 @@ func (ec *executionContext) _IdentifierEdge_cursor(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -6792,26 +7594,26 @@ func (ec *executionContext) _IdentifierEdge_cursor(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(entgql.Cursor[ksuid.ID]) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_IdentifierEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "IdentifierEdge", + Object: "Identifier", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Language_id(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Language_id(ctx, field) +func (ec *executionContext) _Identifier_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -6824,7 +7626,7 @@ func (ec *executionContext) _Language_id(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -6836,26 +7638,26 @@ func (ec *executionContext) _Language_id(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Language_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Language", + Object: "Identifier", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Language_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Language_calibreID(ctx, field) +func (ec *executionContext) _Identifier_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_calibreID(ctx, field) if err != nil { return graphql.Null } @@ -6882,9 +7684,9 @@ func (ec *executionContext) _Language_calibreID(ctx context.Context, field graph return ec.marshalOInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Language_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Language", + Object: "Identifier", Field: field, IsMethod: false, IsResolver: false, @@ -6895,8 +7697,8 @@ func (ec *executionContext) fieldContext_Language_calibreID(ctx context.Context, return fc, nil } -func (ec *executionContext) _Language_code(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Language_code(ctx, field) +func (ec *executionContext) _Identifier_type(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_type(ctx, field) if err != nil { return graphql.Null } @@ -6909,7 +7711,7 @@ func (ec *executionContext) _Language_code(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Code, nil + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) @@ -6926,9 +7728,9 @@ func (ec *executionContext) _Language_code(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Language_code(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Language", + Object: "Identifier", Field: field, IsMethod: false, IsResolver: false, @@ -6939,8 +7741,8 @@ func (ec *executionContext) fieldContext_Language_code(ctx context.Context, fiel return fc, nil } -func (ec *executionContext) _Language_books(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Language_books(ctx, field) +func (ec *executionContext) _Identifier_value(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_value(ctx, field) if err != nil { return graphql.Null } @@ -6953,7 +7755,7 @@ func (ec *executionContext) _Language_books(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) + return obj.Value, nil }) if err != nil { ec.Error(ctx, err) @@ -6965,45 +7767,26 @@ func (ec *executionContext) _Language_books(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(*ent.BookConnection) + res := resTmp.(string) fc.Result = res - return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Language_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Language", + Object: "Identifier", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BookConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BookConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BookConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Language_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _LanguageConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LanguageConnection_edges(ctx, field) +func (ec *executionContext) _Identifier_book(ctx context.Context, field graphql.CollectedField, obj *ent.Identifier) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Identifier_book(ctx, field) if err != nil { return graphql.Null } @@ -7016,41 +7799,78 @@ func (ec *executionContext) _LanguageConnection_edges(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.Book(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.LanguageEdge) + res := resTmp.(*ent.Book) fc.Result = res - return ec.marshalOLanguageEdge2ᚕᚖlybbrioᚋinternalᚋentᚐLanguageEdge(ctx, field.Selections, res) + return ec.marshalNBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LanguageConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Identifier_book(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LanguageConnection", + Object: "Identifier", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_LanguageEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_LanguageEdge_cursor(ctx, field) + case "id": + return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Book_calibreID(ctx, field) + case "title": + return ec.fieldContext_Book_title(ctx, field) + case "sort": + return ec.fieldContext_Book_sort(ctx, field) + case "publishedDate": + return ec.fieldContext_Book_publishedDate(ctx, field) + case "path": + return ec.fieldContext_Book_path(ctx, field) + case "isbn": + return ec.fieldContext_Book_isbn(ctx, field) + case "description": + return ec.fieldContext_Book_description(ctx, field) + case "seriesIndex": + return ec.fieldContext_Book_seriesIndex(ctx, field) + case "authors": + return ec.fieldContext_Book_authors(ctx, field) + case "publisher": + return ec.fieldContext_Book_publisher(ctx, field) + case "series": + return ec.fieldContext_Book_series(ctx, field) + case "identifiers": + return ec.fieldContext_Book_identifiers(ctx, field) + case "tags": + return ec.fieldContext_Book_tags(ctx, field) + case "language": + return ec.fieldContext_Book_language(ctx, field) + case "shelf": + return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type LanguageEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, } return fc, nil } -func (ec *executionContext) _LanguageConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LanguageConnection_pageInfo(ctx, field) +func (ec *executionContext) _IdentifierConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IdentifierConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -7063,39 +7883,86 @@ func (ec *executionContext) _LanguageConnection_pageInfo(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.([]*ent.IdentifierEdge) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalOIdentifierEdge2ᚕᚖlybbrioᚋinternalᚋentᚐIdentifierEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LanguageConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IdentifierConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LanguageConnection", + Object: "IdentifierConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "node": + return ec.fieldContext_IdentifierEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_IdentifierEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IdentifierEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _IdentifierConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IdentifierConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(entgql.PageInfo[ksuid.ID]) + fc.Result = res + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IdentifierConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IdentifierConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, @@ -7103,8 +7970,8 @@ func (ec *executionContext) fieldContext_LanguageConnection_pageInfo(ctx context return fc, nil } -func (ec *executionContext) _LanguageConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LanguageConnection_totalCount(ctx, field) +func (ec *executionContext) _IdentifierConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IdentifierConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -7134,9 +8001,9 @@ func (ec *executionContext) _LanguageConnection_totalCount(ctx context.Context, return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LanguageConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IdentifierConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LanguageConnection", + Object: "IdentifierConnection", Field: field, IsMethod: false, IsResolver: false, @@ -7147,8 +8014,8 @@ func (ec *executionContext) fieldContext_LanguageConnection_totalCount(ctx conte return fc, nil } -func (ec *executionContext) _LanguageEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LanguageEdge_node(ctx, field) +func (ec *executionContext) _IdentifierEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IdentifierEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -7170,36 +8037,42 @@ func (ec *executionContext) _LanguageEdge_node(ctx context.Context, field graphq if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Language) + res := resTmp.(*ent.Identifier) fc.Result = res - return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) + return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LanguageEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IdentifierEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LanguageEdge", + Object: "IdentifierEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Language_id(ctx, field) + return ec.fieldContext_Identifier_id(ctx, field) + case "createTime": + return ec.fieldContext_Identifier_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Identifier_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Language_calibreID(ctx, field) - case "code": - return ec.fieldContext_Language_code(ctx, field) - case "books": - return ec.fieldContext_Language_books(ctx, field) + return ec.fieldContext_Identifier_calibreID(ctx, field) + case "type": + return ec.fieldContext_Identifier_type(ctx, field) + case "value": + return ec.fieldContext_Identifier_value(ctx, field) + case "book": + return ec.fieldContext_Identifier_book(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) }, } return fc, nil } -func (ec *executionContext) _LanguageEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_LanguageEdge_cursor(ctx, field) +func (ec *executionContext) _IdentifierEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.IdentifierEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IdentifierEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -7229,9 +8102,9 @@ func (ec *executionContext) _LanguageEdge_cursor(ctx context.Context, field grap return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_LanguageEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_IdentifierEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "LanguageEdge", + Object: "IdentifierEdge", Field: field, IsMethod: false, IsResolver: false, @@ -7242,8 +8115,8 @@ func (ec *executionContext) fieldContext_LanguageEdge_cursor(ctx context.Context return fc, nil } -func (ec *executionContext) _Mutation_createBook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createBook(ctx, field) +func (ec *executionContext) _Language_id(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_id(ctx, field) if err != nil { return graphql.Null } @@ -7256,80 +8129,38 @@ func (ec *executionContext) _Mutation_createBook(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateBook(rctx, fc.Args["input"].(ent.CreateBookInput)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Book) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalOBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createBook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Book_id(ctx, field) - case "calibreID": - return ec.fieldContext_Book_calibreID(ctx, field) - case "title": - return ec.fieldContext_Book_title(ctx, field) - case "sort": - return ec.fieldContext_Book_sort(ctx, field) - case "publishedDate": - return ec.fieldContext_Book_publishedDate(ctx, field) - case "path": - return ec.fieldContext_Book_path(ctx, field) - case "isbn": - return ec.fieldContext_Book_isbn(ctx, field) - case "description": - return ec.fieldContext_Book_description(ctx, field) - case "seriesIndex": - return ec.fieldContext_Book_seriesIndex(ctx, field) - case "authors": - return ec.fieldContext_Book_authors(ctx, field) - case "publisher": - return ec.fieldContext_Book_publisher(ctx, field) - case "series": - return ec.fieldContext_Book_series(ctx, field) - case "identifiers": - return ec.fieldContext_Book_identifiers(ctx, field) - case "tags": - return ec.fieldContext_Book_tags(ctx, field) - case "language": - return ec.fieldContext_Book_language(ctx, field) - case "shelf": - return ec.fieldContext_Book_shelf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createBook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateBook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateBook(ctx, field) +func (ec *executionContext) _Language_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_createTime(ctx, field) if err != nil { return graphql.Null } @@ -7342,80 +8173,38 @@ func (ec *executionContext) _Mutation_updateBook(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateBook(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateBookInput)) + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Book) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateBook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Book_id(ctx, field) - case "calibreID": - return ec.fieldContext_Book_calibreID(ctx, field) - case "title": - return ec.fieldContext_Book_title(ctx, field) - case "sort": - return ec.fieldContext_Book_sort(ctx, field) - case "publishedDate": - return ec.fieldContext_Book_publishedDate(ctx, field) - case "path": - return ec.fieldContext_Book_path(ctx, field) - case "isbn": - return ec.fieldContext_Book_isbn(ctx, field) - case "description": - return ec.fieldContext_Book_description(ctx, field) - case "seriesIndex": - return ec.fieldContext_Book_seriesIndex(ctx, field) - case "authors": - return ec.fieldContext_Book_authors(ctx, field) - case "publisher": - return ec.fieldContext_Book_publisher(ctx, field) - case "series": - return ec.fieldContext_Book_series(ctx, field) - case "identifiers": - return ec.fieldContext_Book_identifiers(ctx, field) - case "tags": - return ec.fieldContext_Book_tags(ctx, field) - case "language": - return ec.fieldContext_Book_language(ctx, field) - case "shelf": - return ec.fieldContext_Book_shelf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateBook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createAuthor(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createAuthor(ctx, field) +func (ec *executionContext) _Language_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -7428,60 +8217,38 @@ func (ec *executionContext) _Mutation_createAuthor(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateAuthor(rctx, fc.Args["input"].(ent.CreateAuthorInput)) + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Author) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOAuthor2ᚖlybbrioᚋinternalᚋentᚐAuthor(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createAuthor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Author_id(ctx, field) - case "calibreID": - return ec.fieldContext_Author_calibreID(ctx, field) - case "name": - return ec.fieldContext_Author_name(ctx, field) - case "sort": - return ec.fieldContext_Author_sort(ctx, field) - case "link": - return ec.fieldContext_Author_link(ctx, field) - case "books": - return ec.fieldContext_Author_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Author", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createAuthor_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateAuthor(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateAuthor(ctx, field) +func (ec *executionContext) _Language_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_calibreID(ctx, field) if err != nil { return graphql.Null } @@ -7494,7 +8261,7 @@ func (ec *executionContext) _Mutation_updateAuthor(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateAuthor(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateAuthorInput)) + return obj.CalibreID, nil }) if err != nil { ec.Error(ctx, err) @@ -7503,51 +8270,26 @@ func (ec *executionContext) _Mutation_updateAuthor(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Author) + res := resTmp.(int64) fc.Result = res - return ec.marshalOAuthor2ᚖlybbrioᚋinternalᚋentᚐAuthor(ctx, field.Selections, res) + return ec.marshalOInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateAuthor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Author_id(ctx, field) - case "calibreID": - return ec.fieldContext_Author_calibreID(ctx, field) - case "name": - return ec.fieldContext_Author_name(ctx, field) - case "sort": - return ec.fieldContext_Author_sort(ctx, field) - case "link": - return ec.fieldContext_Author_link(ctx, field) - case "books": - return ec.fieldContext_Author_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Author", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAuthor_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_createShelf(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createShelf(ctx, field) +func (ec *executionContext) _Language_code(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_code(ctx, field) if err != nil { return graphql.Null } @@ -7560,62 +8302,38 @@ func (ec *executionContext) _Mutation_createShelf(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateShelf(rctx, fc.Args["input"].(lybbrio.CreateShelfInput)) + return obj.Code, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Shelf) + res := resTmp.(string) fc.Result = res - return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createShelf(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_code(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Shelf_id(ctx, field) - case "public": - return ec.fieldContext_Shelf_public(ctx, field) - case "userID": - return ec.fieldContext_Shelf_userID(ctx, field) - case "name": - return ec.fieldContext_Shelf_name(ctx, field) - case "description": - return ec.fieldContext_Shelf_description(ctx, field) - case "user": - return ec.fieldContext_Shelf_user(ctx, field) - case "books": - return ec.fieldContext_Shelf_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createShelf_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateShelf(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateShelf(ctx, field) +func (ec *executionContext) _Language_books(ctx context.Context, field graphql.CollectedField, obj *ent.Language) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Language_books(ctx, field) if err != nil { return graphql.Null } @@ -7628,44 +8346,39 @@ func (ec *executionContext) _Mutation_updateShelf(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateShelf(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateShelfInput)) + return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Shelf) + res := resTmp.(*ent.BookConnection) fc.Result = res - return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) + return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateShelf(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Language_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Language", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Shelf_id(ctx, field) - case "public": - return ec.fieldContext_Shelf_public(ctx, field) - case "userID": - return ec.fieldContext_Shelf_userID(ctx, field) - case "name": - return ec.fieldContext_Shelf_name(ctx, field) - case "description": - return ec.fieldContext_Shelf_description(ctx, field) - case "user": - return ec.fieldContext_Shelf_user(ctx, field) - case "books": - return ec.fieldContext_Shelf_books(ctx, field) + case "edges": + return ec.fieldContext_BookConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BookConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BookConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) }, } defer func() { @@ -7675,15 +8388,15 @@ func (ec *executionContext) fieldContext_Mutation_updateShelf(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateShelf_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Language_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createTag(ctx, field) +func (ec *executionContext) _LanguageConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LanguageConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -7696,7 +8409,7 @@ func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["input"].(ent.CreateTagInput)) + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) @@ -7705,47 +8418,32 @@ func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Tag) + res := resTmp.([]*ent.LanguageEdge) fc.Result = res - return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) + return ec.marshalOLanguageEdge2ᚕᚖlybbrioᚋinternalᚋentᚐLanguageEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LanguageConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "LanguageConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "calibreID": - return ec.fieldContext_Tag_calibreID(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "books": - return ec.fieldContext_Tag_books(ctx, field) + case "node": + return ec.fieldContext_LanguageEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_LanguageEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, fmt.Errorf("no field named %q was found under type LanguageEdge", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateTag(ctx, field) +func (ec *executionContext) _LanguageConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LanguageConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -7758,56 +8456,92 @@ func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateTagInput)) + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Tag) + res := resTmp.(entgql.PageInfo[ksuid.ID]) fc.Result = res - return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LanguageConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "LanguageConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "calibreID": - return ec.fieldContext_Tag_calibreID(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "books": - return ec.fieldContext_Tag_books(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } + return fc, nil +} + +func (ec *executionContext) _LanguageConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LanguageConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LanguageConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LanguageConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Mutation_createPublisher(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createPublisher(ctx, field) +func (ec *executionContext) _LanguageEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LanguageEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -7820,7 +8554,7 @@ func (ec *executionContext) _Mutation_createPublisher(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreatePublisher(rctx, fc.Args["input"].(ent.CreatePublisherInput)) + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -7829,47 +8563,84 @@ func (ec *executionContext) _Mutation_createPublisher(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Publisher) + res := resTmp.(*ent.Language) fc.Result = res - return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) + return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createPublisher(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_LanguageEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "LanguageEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Publisher_id(ctx, field) + return ec.fieldContext_Language_id(ctx, field) + case "createTime": + return ec.fieldContext_Language_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Language_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Publisher_calibreID(ctx, field) - case "name": - return ec.fieldContext_Publisher_name(ctx, field) + return ec.fieldContext_Language_calibreID(ctx, field) + case "code": + return ec.fieldContext_Language_code(ctx, field) case "books": - return ec.fieldContext_Publisher_books(ctx, field) + return ec.fieldContext_Language_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) }, } + return fc, nil +} + +func (ec *executionContext) _LanguageEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.LanguageEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LanguageEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createPublisher_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(entgql.Cursor[ksuid.ID]) + fc.Result = res + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LanguageEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LanguageEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Mutation_updatePublisher(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updatePublisher(ctx, field) +func (ec *executionContext) _Mutation_createBook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createBook(ctx, field) if err != nil { return graphql.Null } @@ -7882,7 +8653,7 @@ func (ec *executionContext) _Mutation_updatePublisher(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdatePublisher(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdatePublisherInput)) + return ec.resolvers.Mutation().CreateBook(rctx, fc.Args["input"].(ent.CreateBookInput)) }) if err != nil { ec.Error(ctx, err) @@ -7891,12 +8662,12 @@ func (ec *executionContext) _Mutation_updatePublisher(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Publisher) + res := resTmp.(*ent.Book) fc.Result = res - return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) + return ec.marshalOBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updatePublisher(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createBook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -7905,15 +8676,45 @@ func (ec *executionContext) fieldContext_Mutation_updatePublisher(ctx context.Co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Publisher_id(ctx, field) + return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Publisher_calibreID(ctx, field) - case "name": - return ec.fieldContext_Publisher_name(ctx, field) - case "books": - return ec.fieldContext_Publisher_books(ctx, field) + return ec.fieldContext_Book_calibreID(ctx, field) + case "title": + return ec.fieldContext_Book_title(ctx, field) + case "sort": + return ec.fieldContext_Book_sort(ctx, field) + case "publishedDate": + return ec.fieldContext_Book_publishedDate(ctx, field) + case "path": + return ec.fieldContext_Book_path(ctx, field) + case "isbn": + return ec.fieldContext_Book_isbn(ctx, field) + case "description": + return ec.fieldContext_Book_description(ctx, field) + case "seriesIndex": + return ec.fieldContext_Book_seriesIndex(ctx, field) + case "authors": + return ec.fieldContext_Book_authors(ctx, field) + case "publisher": + return ec.fieldContext_Book_publisher(ctx, field) + case "series": + return ec.fieldContext_Book_series(ctx, field) + case "identifiers": + return ec.fieldContext_Book_identifiers(ctx, field) + case "tags": + return ec.fieldContext_Book_tags(ctx, field) + case "language": + return ec.fieldContext_Book_language(ctx, field) + case "shelf": + return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, } defer func() { @@ -7923,15 +8724,15 @@ func (ec *executionContext) fieldContext_Mutation_updatePublisher(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updatePublisher_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createBook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createLanguage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createLanguage(ctx, field) +func (ec *executionContext) _Mutation_updateBook(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateBook(ctx, field) if err != nil { return graphql.Null } @@ -7944,7 +8745,7 @@ func (ec *executionContext) _Mutation_createLanguage(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateLanguage(rctx, fc.Args["input"].(ent.CreateLanguageInput)) + return ec.resolvers.Mutation().UpdateBook(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateBookInput)) }) if err != nil { ec.Error(ctx, err) @@ -7953,12 +8754,12 @@ func (ec *executionContext) _Mutation_createLanguage(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Language) + res := resTmp.(*ent.Book) fc.Result = res - return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) + return ec.marshalOBook2ᚖlybbrioᚋinternalᚋentᚐBook(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createLanguage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateBook(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -7967,15 +8768,45 @@ func (ec *executionContext) fieldContext_Mutation_createLanguage(ctx context.Con Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Language_id(ctx, field) + return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Language_calibreID(ctx, field) - case "code": - return ec.fieldContext_Language_code(ctx, field) - case "books": - return ec.fieldContext_Language_books(ctx, field) + return ec.fieldContext_Book_calibreID(ctx, field) + case "title": + return ec.fieldContext_Book_title(ctx, field) + case "sort": + return ec.fieldContext_Book_sort(ctx, field) + case "publishedDate": + return ec.fieldContext_Book_publishedDate(ctx, field) + case "path": + return ec.fieldContext_Book_path(ctx, field) + case "isbn": + return ec.fieldContext_Book_isbn(ctx, field) + case "description": + return ec.fieldContext_Book_description(ctx, field) + case "seriesIndex": + return ec.fieldContext_Book_seriesIndex(ctx, field) + case "authors": + return ec.fieldContext_Book_authors(ctx, field) + case "publisher": + return ec.fieldContext_Book_publisher(ctx, field) + case "series": + return ec.fieldContext_Book_series(ctx, field) + case "identifiers": + return ec.fieldContext_Book_identifiers(ctx, field) + case "tags": + return ec.fieldContext_Book_tags(ctx, field) + case "language": + return ec.fieldContext_Book_language(ctx, field) + case "shelf": + return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, } defer func() { @@ -7985,15 +8816,15 @@ func (ec *executionContext) fieldContext_Mutation_createLanguage(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createLanguage_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateBook_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateLanguage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateLanguage(ctx, field) +func (ec *executionContext) _Mutation_createAuthor(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createAuthor(ctx, field) if err != nil { return graphql.Null } @@ -8006,7 +8837,7 @@ func (ec *executionContext) _Mutation_updateLanguage(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateLanguage(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateLanguageInput)) + return ec.resolvers.Mutation().CreateAuthor(rctx, fc.Args["input"].(ent.CreateAuthorInput)) }) if err != nil { ec.Error(ctx, err) @@ -8015,12 +8846,12 @@ func (ec *executionContext) _Mutation_updateLanguage(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Language) + res := resTmp.(*ent.Author) fc.Result = res - return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) + return ec.marshalOAuthor2ᚖlybbrioᚋinternalᚋentᚐAuthor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateLanguage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createAuthor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8029,15 +8860,23 @@ func (ec *executionContext) fieldContext_Mutation_updateLanguage(ctx context.Con Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Language_id(ctx, field) + return ec.fieldContext_Author_id(ctx, field) + case "createTime": + return ec.fieldContext_Author_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Author_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Language_calibreID(ctx, field) - case "code": - return ec.fieldContext_Language_code(ctx, field) + return ec.fieldContext_Author_calibreID(ctx, field) + case "name": + return ec.fieldContext_Author_name(ctx, field) + case "sort": + return ec.fieldContext_Author_sort(ctx, field) + case "link": + return ec.fieldContext_Author_link(ctx, field) case "books": - return ec.fieldContext_Language_books(ctx, field) + return ec.fieldContext_Author_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Author", field.Name) }, } defer func() { @@ -8047,15 +8886,15 @@ func (ec *executionContext) fieldContext_Mutation_updateLanguage(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateLanguage_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createAuthor_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createSeries(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createSeries(ctx, field) +func (ec *executionContext) _Mutation_updateAuthor(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateAuthor(ctx, field) if err != nil { return graphql.Null } @@ -8068,7 +8907,7 @@ func (ec *executionContext) _Mutation_createSeries(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateSeries(rctx, fc.Args["input"].(ent.CreateSeriesInput)) + return ec.resolvers.Mutation().UpdateAuthor(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateAuthorInput)) }) if err != nil { ec.Error(ctx, err) @@ -8077,12 +8916,12 @@ func (ec *executionContext) _Mutation_createSeries(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Series) + res := resTmp.(*ent.Author) fc.Result = res - return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) + return ec.marshalOAuthor2ᚖlybbrioᚋinternalᚋentᚐAuthor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createSeries(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAuthor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8091,17 +8930,23 @@ func (ec *executionContext) fieldContext_Mutation_createSeries(ctx context.Conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Series_id(ctx, field) + return ec.fieldContext_Author_id(ctx, field) + case "createTime": + return ec.fieldContext_Author_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Author_updateTime(ctx, field) case "calibreID": - return ec.fieldContext_Series_calibreID(ctx, field) + return ec.fieldContext_Author_calibreID(ctx, field) case "name": - return ec.fieldContext_Series_name(ctx, field) + return ec.fieldContext_Author_name(ctx, field) case "sort": - return ec.fieldContext_Series_sort(ctx, field) + return ec.fieldContext_Author_sort(ctx, field) + case "link": + return ec.fieldContext_Author_link(ctx, field) case "books": - return ec.fieldContext_Series_books(ctx, field) + return ec.fieldContext_Author_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Author", field.Name) }, } defer func() { @@ -8111,15 +8956,15 @@ func (ec *executionContext) fieldContext_Mutation_createSeries(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createSeries_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAuthor_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateSeries(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateSeries(ctx, field) +func (ec *executionContext) _Mutation_createShelf(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createShelf(ctx, field) if err != nil { return graphql.Null } @@ -8132,7 +8977,7 @@ func (ec *executionContext) _Mutation_updateSeries(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateSeries(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateSeriesInput)) + return ec.resolvers.Mutation().CreateShelf(rctx, fc.Args["input"].(lybbrio.CreateShelfInput)) }) if err != nil { ec.Error(ctx, err) @@ -8141,12 +8986,12 @@ func (ec *executionContext) _Mutation_updateSeries(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Series) + res := resTmp.(*ent.Shelf) fc.Result = res - return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) + return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateSeries(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createShelf(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8155,17 +9000,25 @@ func (ec *executionContext) fieldContext_Mutation_updateSeries(ctx context.Conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Series_id(ctx, field) - case "calibreID": - return ec.fieldContext_Series_calibreID(ctx, field) + return ec.fieldContext_Shelf_id(ctx, field) + case "createTime": + return ec.fieldContext_Shelf_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Shelf_updateTime(ctx, field) + case "public": + return ec.fieldContext_Shelf_public(ctx, field) + case "userID": + return ec.fieldContext_Shelf_userID(ctx, field) case "name": - return ec.fieldContext_Series_name(ctx, field) - case "sort": - return ec.fieldContext_Series_sort(ctx, field) + return ec.fieldContext_Shelf_name(ctx, field) + case "description": + return ec.fieldContext_Shelf_description(ctx, field) + case "user": + return ec.fieldContext_Shelf_user(ctx, field) case "books": - return ec.fieldContext_Series_books(ctx, field) + return ec.fieldContext_Shelf_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) }, } defer func() { @@ -8175,15 +9028,15 @@ func (ec *executionContext) fieldContext_Mutation_updateSeries(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateSeries_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createShelf_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createIdentifier(ctx, field) +func (ec *executionContext) _Mutation_updateShelf(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateShelf(ctx, field) if err != nil { return graphql.Null } @@ -8196,7 +9049,7 @@ func (ec *executionContext) _Mutation_createIdentifier(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateIdentifier(rctx, fc.Args["input"].(ent.CreateIdentifierInput)) + return ec.resolvers.Mutation().UpdateShelf(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateShelfInput)) }) if err != nil { ec.Error(ctx, err) @@ -8205,12 +9058,12 @@ func (ec *executionContext) _Mutation_createIdentifier(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Identifier) + res := resTmp.(*ent.Shelf) fc.Result = res - return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) + return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateShelf(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8219,17 +9072,25 @@ func (ec *executionContext) fieldContext_Mutation_createIdentifier(ctx context.C Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Identifier_id(ctx, field) - case "calibreID": - return ec.fieldContext_Identifier_calibreID(ctx, field) - case "type": - return ec.fieldContext_Identifier_type(ctx, field) - case "value": - return ec.fieldContext_Identifier_value(ctx, field) - case "book": - return ec.fieldContext_Identifier_book(ctx, field) + return ec.fieldContext_Shelf_id(ctx, field) + case "createTime": + return ec.fieldContext_Shelf_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Shelf_updateTime(ctx, field) + case "public": + return ec.fieldContext_Shelf_public(ctx, field) + case "userID": + return ec.fieldContext_Shelf_userID(ctx, field) + case "name": + return ec.fieldContext_Shelf_name(ctx, field) + case "description": + return ec.fieldContext_Shelf_description(ctx, field) + case "user": + return ec.fieldContext_Shelf_user(ctx, field) + case "books": + return ec.fieldContext_Shelf_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) }, } defer func() { @@ -8239,15 +9100,15 @@ func (ec *executionContext) fieldContext_Mutation_createIdentifier(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createIdentifier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateShelf_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateIdentifier(ctx, field) +func (ec *executionContext) _Mutation_createTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTag(ctx, field) if err != nil { return graphql.Null } @@ -8260,7 +9121,7 @@ func (ec *executionContext) _Mutation_updateIdentifier(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateIdentifier(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateIdentifierInput)) + return ec.resolvers.Mutation().CreateTag(rctx, fc.Args["input"].(ent.CreateTagInput)) }) if err != nil { ec.Error(ctx, err) @@ -8269,12 +9130,12 @@ func (ec *executionContext) _Mutation_updateIdentifier(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Identifier) + res := resTmp.(*ent.Tag) fc.Result = res - return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) + return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8283,17 +9144,15 @@ func (ec *executionContext) fieldContext_Mutation_updateIdentifier(ctx context.C Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Identifier_id(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) case "calibreID": - return ec.fieldContext_Identifier_calibreID(ctx, field) - case "type": - return ec.fieldContext_Identifier_type(ctx, field) - case "value": - return ec.fieldContext_Identifier_value(ctx, field) - case "book": - return ec.fieldContext_Identifier_book(ctx, field) + return ec.fieldContext_Tag_calibreID(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "books": + return ec.fieldContext_Tag_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } defer func() { @@ -8303,15 +9162,15 @@ func (ec *executionContext) fieldContext_Mutation_updateIdentifier(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateIdentifier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createUser(ctx, field) +func (ec *executionContext) _Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateTag(ctx, field) if err != nil { return graphql.Null } @@ -8324,7 +9183,7 @@ func (ec *executionContext) _Mutation_createUser(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(ent.CreateUserInput)) + return ec.resolvers.Mutation().UpdateTag(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateTagInput)) }) if err != nil { ec.Error(ctx, err) @@ -8333,12 +9192,12 @@ func (ec *executionContext) _Mutation_createUser(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(*ent.Tag) fc.Result = res - return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateTag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8347,17 +9206,15 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "calibreID": + return ec.fieldContext_Tag_calibreID(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "books": + return ec.fieldContext_Tag_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } defer func() { @@ -8367,15 +9224,15 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateTag_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) +func (ec *executionContext) _Mutation_createPublisher(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createPublisher(ctx, field) if err != nil { return graphql.Null } @@ -8388,7 +9245,7 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateUserInput)) + return ec.resolvers.Mutation().CreatePublisher(rctx, fc.Args["input"].(ent.CreatePublisherInput)) }) if err != nil { ec.Error(ctx, err) @@ -8397,12 +9254,12 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(*ent.Publisher) fc.Result = res - return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createPublisher(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8411,17 +9268,19 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) + return ec.fieldContext_Publisher_id(ctx, field) + case "createTime": + return ec.fieldContext_Publisher_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Publisher_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Publisher_calibreID(ctx, field) + case "name": + return ec.fieldContext_Publisher_name(ctx, field) + case "books": + return ec.fieldContext_Publisher_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) }, } defer func() { @@ -8431,15 +9290,15 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createPublisher_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createTask(ctx, field) +func (ec *executionContext) _Mutation_updatePublisher(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updatePublisher(ctx, field) if err != nil { return graphql.Null } @@ -8452,7 +9311,7 @@ func (ec *executionContext) _Mutation_createTask(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTask(rctx, fc.Args["input"].(lybbrio.CreateTaskInput)) + return ec.resolvers.Mutation().UpdatePublisher(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdatePublisherInput)) }) if err != nil { ec.Error(ctx, err) @@ -8461,12 +9320,12 @@ func (ec *executionContext) _Mutation_createTask(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Task) + res := resTmp.(*ent.Publisher) fc.Result = res - return ec.marshalOTask2ᚖlybbrioᚋinternalᚋentᚐTask(ctx, field.Selections, res) + return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updatePublisher(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -8475,29 +9334,19 @@ func (ec *executionContext) fieldContext_Mutation_createTask(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) + return ec.fieldContext_Publisher_id(ctx, field) case "createTime": - return ec.fieldContext_Task_createTime(ctx, field) + return ec.fieldContext_Publisher_createTime(ctx, field) case "updateTime": - return ec.fieldContext_Task_updateTime(ctx, field) - case "type": - return ec.fieldContext_Task_type(ctx, field) - case "status": - return ec.fieldContext_Task_status(ctx, field) - case "progress": - return ec.fieldContext_Task_progress(ctx, field) - case "message": - return ec.fieldContext_Task_message(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "userID": - return ec.fieldContext_Task_userID(ctx, field) - case "isSystemTask": - return ec.fieldContext_Task_isSystemTask(ctx, field) - case "user": - return ec.fieldContext_Task_user(ctx, field) + return ec.fieldContext_Publisher_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Publisher_calibreID(ctx, field) + case "name": + return ec.fieldContext_Publisher_name(ctx, field) + case "books": + return ec.fieldContext_Publisher_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) }, } defer func() { @@ -8507,15 +9356,15 @@ func (ec *executionContext) fieldContext_Mutation_createTask(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createTask_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updatePublisher_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) +func (ec *executionContext) _Mutation_createLanguage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createLanguage(ctx, field) if err != nil { return graphql.Null } @@ -8528,82 +9377,60 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return ec.resolvers.Mutation().CreateLanguage(rctx, fc.Args["input"].(ent.CreateLanguageInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*ent.Language) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createLanguage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - if err != nil { - return graphql.Null + switch field.Name { + case "id": + return ec.fieldContext_Language_id(ctx, field) + case "createTime": + return ec.fieldContext_Language_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Language_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Language_calibreID(ctx, field) + case "code": + return ec.fieldContext_Language_code(ctx, field) + case "books": + return ec.fieldContext_Language_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) + }, } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createLanguage_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, + return fc, err } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) +func (ec *executionContext) _Mutation_updateLanguage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateLanguage(ctx, field) if err != nil { return graphql.Null } @@ -8616,7 +9443,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return ec.resolvers.Mutation().UpdateLanguage(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateLanguageInput)) }) if err != nil { ec.Error(ctx, err) @@ -8625,26 +9452,51 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(*entgql.Cursor[ksuid.ID]) + res := resTmp.(*ent.Language) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalOLanguage2ᚖlybbrioᚋinternalᚋentᚐLanguage(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateLanguage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Language_id(ctx, field) + case "createTime": + return ec.fieldContext_Language_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Language_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Language_calibreID(ctx, field) + case "code": + return ec.fieldContext_Language_code(ctx, field) + case "books": + return ec.fieldContext_Language_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Language", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateLanguage_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) +func (ec *executionContext) _Mutation_createSeries(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createSeries(ctx, field) if err != nil { return graphql.Null } @@ -8657,7 +9509,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return ec.resolvers.Mutation().CreateSeries(rctx, fc.Args["input"].(ent.CreateSeriesInput)) }) if err != nil { ec.Error(ctx, err) @@ -8666,26 +9518,53 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*entgql.Cursor[ksuid.ID]) + res := resTmp.(*ent.Series) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createSeries(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Series_id(ctx, field) + case "createTime": + return ec.fieldContext_Series_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Series_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Series_calibreID(ctx, field) + case "name": + return ec.fieldContext_Series_name(ctx, field) + case "sort": + return ec.fieldContext_Series_sort(ctx, field) + case "books": + return ec.fieldContext_Series_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createSeries_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Publisher_id(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Publisher_id(ctx, field) +func (ec *executionContext) _Mutation_updateSeries(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateSeries(ctx, field) if err != nil { return graphql.Null } @@ -8698,38 +9577,62 @@ func (ec *executionContext) _Publisher_id(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Mutation().UpdateSeries(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateSeriesInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(*ent.Series) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Publisher_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateSeries(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Publisher", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Series_id(ctx, field) + case "createTime": + return ec.fieldContext_Series_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Series_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Series_calibreID(ctx, field) + case "name": + return ec.fieldContext_Series_name(ctx, field) + case "sort": + return ec.fieldContext_Series_sort(ctx, field) + case "books": + return ec.fieldContext_Series_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateSeries_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Publisher_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Publisher_calibreID(ctx, field) +func (ec *executionContext) _Mutation_createIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createIdentifier(ctx, field) if err != nil { return graphql.Null } @@ -8742,7 +9645,7 @@ func (ec *executionContext) _Publisher_calibreID(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CalibreID, nil + return ec.resolvers.Mutation().CreateIdentifier(rctx, fc.Args["input"].(ent.CreateIdentifierInput)) }) if err != nil { ec.Error(ctx, err) @@ -8751,26 +9654,53 @@ func (ec *executionContext) _Publisher_calibreID(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(int64) + res := resTmp.(*ent.Identifier) fc.Result = res - return ec.marshalOInt2int64(ctx, field.Selections, res) + return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Publisher_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Publisher", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Identifier_id(ctx, field) + case "createTime": + return ec.fieldContext_Identifier_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Identifier_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Identifier_calibreID(ctx, field) + case "type": + return ec.fieldContext_Identifier_type(ctx, field) + case "value": + return ec.fieldContext_Identifier_value(ctx, field) + case "book": + return ec.fieldContext_Identifier_book(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createIdentifier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Publisher_name(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Publisher_name(ctx, field) +func (ec *executionContext) _Mutation_updateIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateIdentifier(ctx, field) if err != nil { return graphql.Null } @@ -8783,38 +9713,62 @@ func (ec *executionContext) _Publisher_name(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Mutation().UpdateIdentifier(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateIdentifierInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Identifier) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOIdentifier2ᚖlybbrioᚋinternalᚋentᚐIdentifier(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Publisher_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateIdentifier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Publisher", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Identifier_id(ctx, field) + case "createTime": + return ec.fieldContext_Identifier_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Identifier_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Identifier_calibreID(ctx, field) + case "type": + return ec.fieldContext_Identifier_type(ctx, field) + case "value": + return ec.fieldContext_Identifier_value(ctx, field) + case "book": + return ec.fieldContext_Identifier_book(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Identifier", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateIdentifier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Publisher_books(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Publisher_books(ctx, field) +func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createUser(ctx, field) if err != nil { return graphql.Null } @@ -8827,39 +9781,44 @@ func (ec *executionContext) _Publisher_books(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) + return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(ent.CreateUserInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.BookConnection) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) + return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Publisher_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Publisher", + Object: "Mutation", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_BookConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BookConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BookConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { @@ -8869,15 +9828,15 @@ func (ec *executionContext) fieldContext_Publisher_books(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Publisher_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _PublisherConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PublisherConnection_edges(ctx, field) +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) if err != nil { return graphql.Null } @@ -8890,7 +9849,7 @@ func (ec *executionContext) _PublisherConnection_edges(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(ksuid.ID), fc.Args["input"].(ent.UpdateUserInput)) }) if err != nil { ec.Error(ctx, err) @@ -8899,32 +9858,53 @@ func (ec *executionContext) _PublisherConnection_edges(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.PublisherEdge) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalOPublisherEdge2ᚕᚖlybbrioᚋinternalᚋentᚐPublisherEdge(ctx, field.Selections, res) + return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PublisherConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PublisherConnection", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_PublisherEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_PublisherEdge_cursor(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PublisherEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _PublisherConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PublisherConnection_pageInfo(ctx, field) +func (ec *executionContext) _Mutation_createTask(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createTask(ctx, field) if err != nil { return graphql.Null } @@ -8937,48 +9917,70 @@ func (ec *executionContext) _PublisherConnection_pageInfo(ctx context.Context, f }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return ec.resolvers.Mutation().CreateTask(rctx, fc.Args["input"].(lybbrio.CreateTaskInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.(*ent.Task) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalOTask2ᚖlybbrioᚋinternalᚋentᚐTask(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PublisherConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PublisherConnection", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createTime": + return ec.fieldContext_Task_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Task_updateTime(ctx, field) + case "type": + return ec.fieldContext_Task_type(ctx, field) + case "status": + return ec.fieldContext_Task_status(ctx, field) + case "progress": + return ec.fieldContext_Task_progress(ctx, field) + case "message": + return ec.fieldContext_Task_message(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "userID": + return ec.fieldContext_Task_userID(ctx, field) + case "isSystemTask": + return ec.fieldContext_Task_isSystemTask(ctx, field) + case "user": + return ec.fieldContext_Task_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createTask_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _PublisherConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PublisherConnection_totalCount(ctx, field) +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null } @@ -8991,7 +9993,7 @@ func (ec *executionContext) _PublisherConnection_totalCount(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) @@ -9003,26 +10005,26 @@ func (ec *executionContext) _PublisherConnection_totalCount(ctx context.Context, } return graphql.Null } - res := resTmp.(int) + res := resTmp.(bool) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PublisherConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PublisherConnection", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PublisherEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PublisherEdge_node(ctx, field) +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) if err != nil { return graphql.Null } @@ -9035,45 +10037,38 @@ func (ec *executionContext) _PublisherEdge_node(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.HasPreviousPage, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Publisher) + res := resTmp.(bool) fc.Result = res - return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PublisherEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PublisherEdge", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Publisher_id(ctx, field) - case "calibreID": - return ec.fieldContext_Publisher_calibreID(ctx, field) - case "name": - return ec.fieldContext_Publisher_name(ctx, field) - case "books": - return ec.fieldContext_Publisher_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PublisherEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PublisherEdge_cursor(ctx, field) +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) if err != nil { return graphql.Null } @@ -9086,26 +10081,23 @@ func (ec *executionContext) _PublisherEdge_cursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.StartCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(entgql.Cursor[ksuid.ID]) + res := resTmp.(*entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PublisherEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PublisherEdge", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, @@ -9116,8 +10108,8 @@ func (ec *executionContext) fieldContext_PublisherEdge_cursor(ctx context.Contex return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[ksuid.ID]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null } @@ -9130,7 +10122,7 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(ksuid.ID)) + return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) @@ -9139,37 +10131,26 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle if resTmp == nil { return graphql.Null } - res := resTmp.(ent.Noder) + res := resTmp.(*entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalONode2lybbrioᚋinternalᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Cursor does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) +func (ec *executionContext) _Publisher_id(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_id(ctx, field) if err != nil { return graphql.Null } @@ -9182,7 +10163,7 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]ksuid.ID)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -9194,37 +10175,26 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]ent.Noder) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNNode2ᚕlybbrioᚋinternalᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_authors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_authors(ctx, field) +func (ec *executionContext) _Publisher_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_createTime(ctx, field) if err != nil { return graphql.Null } @@ -9237,7 +10207,7 @@ func (ec *executionContext) _Query_authors(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Authors(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AuthorOrder), fc.Args["where"].(*ent.AuthorWhereInput)) + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -9249,45 +10219,26 @@ func (ec *executionContext) _Query_authors(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(*ent.AuthorConnection) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNAuthorConnection2ᚖlybbrioᚋinternalᚋentᚐAuthorConnection(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_authors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_AuthorConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AuthorConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AuthorConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AuthorConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_authors_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_books(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_books(ctx, field) +func (ec *executionContext) _Publisher_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -9300,7 +10251,7 @@ func (ec *executionContext) _Query_books(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Books(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -9312,45 +10263,26 @@ func (ec *executionContext) _Query_books(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*ent.BookConnection) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BookConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BookConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BookConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_identifiers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_identifiers(ctx, field) +func (ec *executionContext) _Publisher_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_calibreID(ctx, field) if err != nil { return graphql.Null } @@ -9363,57 +10295,35 @@ func (ec *executionContext) _Query_identifiers(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Identifiers(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.IdentifierOrder), fc.Args["where"].(*ent.IdentifierWhereInput)) + return obj.CalibreID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.IdentifierConnection) + res := resTmp.(int64) fc.Result = res - return ec.marshalNIdentifierConnection2ᚖlybbrioᚋinternalᚋentᚐIdentifierConnection(ctx, field.Selections, res) + return ec.marshalOInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_identifiers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_IdentifierConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_IdentifierConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_IdentifierConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type IdentifierConnection", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_identifiers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_languages(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_languages(ctx, field) +func (ec *executionContext) _Publisher_name(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_name(ctx, field) if err != nil { return graphql.Null } @@ -9426,7 +10336,7 @@ func (ec *executionContext) _Query_languages(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Languages(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.LanguageOrder), fc.Args["where"].(*ent.LanguageWhereInput)) + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -9438,45 +10348,26 @@ func (ec *executionContext) _Query_languages(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(*ent.LanguageConnection) + res := resTmp.(string) fc.Result = res - return ec.marshalNLanguageConnection2ᚖlybbrioᚋinternalᚋentᚐLanguageConnection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_languages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_LanguageConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_LanguageConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_LanguageConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type LanguageConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_languages_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_publishers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_publishers(ctx, field) +func (ec *executionContext) _Publisher_books(ctx context.Context, field graphql.CollectedField, obj *ent.Publisher) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Publisher_books(ctx, field) if err != nil { return graphql.Null } @@ -9489,7 +10380,7 @@ func (ec *executionContext) _Query_publishers(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Publishers(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PublisherOrder), fc.Args["where"].(*ent.PublisherWhereInput)) + return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -9501,27 +10392,27 @@ func (ec *executionContext) _Query_publishers(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(*ent.PublisherConnection) + res := resTmp.(*ent.BookConnection) fc.Result = res - return ec.marshalNPublisherConnection2ᚖlybbrioᚋinternalᚋentᚐPublisherConnection(ctx, field.Selections, res) + return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_publishers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Publisher_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Publisher", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "edges": - return ec.fieldContext_PublisherConnection_edges(ctx, field) + return ec.fieldContext_BookConnection_edges(ctx, field) case "pageInfo": - return ec.fieldContext_PublisherConnection_pageInfo(ctx, field) + return ec.fieldContext_BookConnection_pageInfo(ctx, field) case "totalCount": - return ec.fieldContext_PublisherConnection_totalCount(ctx, field) + return ec.fieldContext_BookConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PublisherConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) }, } defer func() { @@ -9531,15 +10422,15 @@ func (ec *executionContext) fieldContext_Query_publishers(ctx context.Context, f } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_publishers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Publisher_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_seriesSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_seriesSlice(ctx, field) +func (ec *executionContext) _PublisherConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PublisherConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -9552,57 +10443,41 @@ func (ec *executionContext) _Query_seriesSlice(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().SeriesSlice(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.SeriesOrder), fc.Args["where"].(*ent.SeriesWhereInput)) + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.SeriesConnection) + res := resTmp.([]*ent.PublisherEdge) fc.Result = res - return ec.marshalNSeriesConnection2ᚖlybbrioᚋinternalᚋentᚐSeriesConnection(ctx, field.Selections, res) + return ec.marshalOPublisherEdge2ᚕᚖlybbrioᚋinternalᚋentᚐPublisherEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_seriesSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PublisherConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PublisherConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_SeriesConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_SeriesConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_SeriesConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SeriesConnection", field.Name) + case "node": + return ec.fieldContext_PublisherEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_PublisherEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PublisherEdge", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_seriesSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_shelves(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_shelves(ctx, field) +func (ec *executionContext) _PublisherConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PublisherConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -9615,7 +10490,7 @@ func (ec *executionContext) _Query_shelves(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Shelves(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShelfOrder), fc.Args["where"].(*ent.ShelfWhereInput)) + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -9627,45 +10502,36 @@ func (ec *executionContext) _Query_shelves(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(*ent.ShelfConnection) + res := resTmp.(entgql.PageInfo[ksuid.ID]) fc.Result = res - return ec.marshalNShelfConnection2ᚖlybbrioᚋinternalᚋentᚐShelfConnection(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_shelves(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PublisherConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PublisherConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_ShelfConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_ShelfConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_ShelfConnection_totalCount(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ShelfConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_shelves_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_tags(ctx, field) +func (ec *executionContext) _PublisherConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PublisherConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -9678,7 +10544,7 @@ func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Tags(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -9690,45 +10556,26 @@ func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(*ent.TagConnection) + res := resTmp.(int) fc.Result = res - return ec.marshalNTagConnection2ᚖlybbrioᚋinternalᚋentᚐTagConnection(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PublisherConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PublisherConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TagConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TagConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TagConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_tasks(ctx, field) +func (ec *executionContext) _PublisherEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PublisherEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -9741,57 +10588,49 @@ func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Tasks(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.TaskConnection) + res := resTmp.(*ent.Publisher) fc.Result = res - return ec.marshalNTaskConnection2ᚖlybbrioᚋinternalᚋentᚐTaskConnection(ctx, field.Selections, res) + return ec.marshalOPublisher2ᚖlybbrioᚋinternalᚋentᚐPublisher(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PublisherEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PublisherEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) + case "id": + return ec.fieldContext_Publisher_id(ctx, field) + case "createTime": + return ec.fieldContext_Publisher_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Publisher_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Publisher_calibreID(ctx, field) + case "name": + return ec.fieldContext_Publisher_name(ctx, field) + case "books": + return ec.fieldContext_Publisher_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Publisher", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_users(ctx, field) +func (ec *executionContext) _PublisherEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.PublisherEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PublisherEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -9804,7 +10643,7 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx) + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -9816,38 +10655,26 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*ent.User) + res := resTmp.(entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalNUser2ᚕᚖlybbrioᚋinternalᚋentᚐUserᚄ(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PublisherEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PublisherEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_me(ctx, field) +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) if err != nil { return graphql.Null } @@ -9860,50 +10687,46 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Me(rctx) + return ec.resolvers.Query().Node(rctx, fc.Args["id"].(ksuid.ID)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(ent.Noder) fc.Result = res - return ec.marshalNUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalONode2lybbrioᚋinternalᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nodes(ctx, field) if err != nil { return graphql.Null } @@ -9916,50 +10739,31 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]ksuid.ID)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]ent.Noder) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNNode2ᚕlybbrioᚋinternalᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { @@ -9969,15 +10773,15 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _Query_authors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_authors(ctx, field) if err != nil { return graphql.Null } @@ -9990,49 +10794,57 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return ec.resolvers.Query().Authors(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.AuthorOrder), fc.Args["where"].(*ent.AuthorWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(*ent.AuthorConnection) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNAuthorConnection2ᚖlybbrioᚋinternalᚋentᚐAuthorConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_authors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) + case "edges": + return ec.fieldContext_AuthorConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_AuthorConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_AuthorConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AuthorConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_authors_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Series_id(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Series_id(ctx, field) +func (ec *executionContext) _Query_books(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_books(ctx, field) if err != nil { return graphql.Null } @@ -10045,7 +10857,7 @@ func (ec *executionContext) _Series_id(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Query().Books(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -10057,26 +10869,45 @@ func (ec *executionContext) _Series_id(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(*ent.BookConnection) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Series_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Series", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_BookConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BookConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BookConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Series_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Series_calibreID(ctx, field) +func (ec *executionContext) _Query_bookFiles(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_bookFiles(ctx, field) if err != nil { return graphql.Null } @@ -10089,35 +10920,56 @@ func (ec *executionContext) _Series_calibreID(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CalibreID, nil + return ec.resolvers.Query().BookFiles(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(int64) + res := resTmp.([]*ent.BookFile) fc.Result = res - return ec.marshalOInt2int64(ctx, field.Selections, res) + return ec.marshalNBookFile2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Series_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_bookFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Series", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_BookFile_id(ctx, field) + case "createTime": + return ec.fieldContext_BookFile_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_BookFile_updateTime(ctx, field) + case "name": + return ec.fieldContext_BookFile_name(ctx, field) + case "path": + return ec.fieldContext_BookFile_path(ctx, field) + case "size": + return ec.fieldContext_BookFile_size(ctx, field) + case "format": + return ec.fieldContext_BookFile_format(ctx, field) + case "book": + return ec.fieldContext_BookFile_book(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BookFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _Series_name(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Series_name(ctx, field) +func (ec *executionContext) _Query_identifiers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_identifiers(ctx, field) if err != nil { return graphql.Null } @@ -10130,7 +10982,7 @@ func (ec *executionContext) _Series_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Query().Identifiers(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.IdentifierOrder), fc.Args["where"].(*ent.IdentifierWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -10142,26 +10994,45 @@ func (ec *executionContext) _Series_name(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.IdentifierConnection) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNIdentifierConnection2ᚖlybbrioᚋinternalᚋentᚐIdentifierConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Series_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_identifiers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Series", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_IdentifierConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_IdentifierConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_IdentifierConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IdentifierConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_identifiers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Series_sort(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Series_sort(ctx, field) +func (ec *executionContext) _Query_languages(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_languages(ctx, field) if err != nil { return graphql.Null } @@ -10174,7 +11045,7 @@ func (ec *executionContext) _Series_sort(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Sort, nil + return ec.resolvers.Query().Languages(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.LanguageOrder), fc.Args["where"].(*ent.LanguageWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -10186,26 +11057,45 @@ func (ec *executionContext) _Series_sort(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.LanguageConnection) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNLanguageConnection2ᚖlybbrioᚋinternalᚋentᚐLanguageConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Series_sort(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_languages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Series", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_LanguageConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_LanguageConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_LanguageConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LanguageConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_languages_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Series_books(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Series_books(ctx, field) +func (ec *executionContext) _Query_publishers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_publishers(ctx, field) if err != nil { return graphql.Null } @@ -10218,69 +11108,57 @@ func (ec *executionContext) _Series_books(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Books(ctx) + return ec.resolvers.Query().Publishers(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.PublisherOrder), fc.Args["where"].(*ent.PublisherWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.Book) + res := resTmp.(*ent.PublisherConnection) fc.Result = res - return ec.marshalOBook2ᚕᚖlybbrioᚋinternalᚋentᚐBookᚄ(ctx, field.Selections, res) + return ec.marshalNPublisherConnection2ᚖlybbrioᚋinternalᚋentᚐPublisherConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Series_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_publishers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Series", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Book_id(ctx, field) - case "calibreID": - return ec.fieldContext_Book_calibreID(ctx, field) - case "title": - return ec.fieldContext_Book_title(ctx, field) - case "sort": - return ec.fieldContext_Book_sort(ctx, field) - case "publishedDate": - return ec.fieldContext_Book_publishedDate(ctx, field) - case "path": - return ec.fieldContext_Book_path(ctx, field) - case "isbn": - return ec.fieldContext_Book_isbn(ctx, field) - case "description": - return ec.fieldContext_Book_description(ctx, field) - case "seriesIndex": - return ec.fieldContext_Book_seriesIndex(ctx, field) - case "authors": - return ec.fieldContext_Book_authors(ctx, field) - case "publisher": - return ec.fieldContext_Book_publisher(ctx, field) - case "series": - return ec.fieldContext_Book_series(ctx, field) - case "identifiers": - return ec.fieldContext_Book_identifiers(ctx, field) - case "tags": - return ec.fieldContext_Book_tags(ctx, field) - case "language": - return ec.fieldContext_Book_language(ctx, field) - case "shelf": - return ec.fieldContext_Book_shelf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) - }, - } - return fc, nil + case "edges": + return ec.fieldContext_PublisherConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_PublisherConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_PublisherConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PublisherConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_publishers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil } -func (ec *executionContext) _SeriesConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SeriesConnection_edges(ctx, field) +func (ec *executionContext) _Query_seriesSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_seriesSlice(ctx, field) if err != nil { return graphql.Null } @@ -10293,41 +11171,57 @@ func (ec *executionContext) _SeriesConnection_edges(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return ec.resolvers.Query().SeriesSlice(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.SeriesOrder), fc.Args["where"].(*ent.SeriesWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.SeriesEdge) + res := resTmp.(*ent.SeriesConnection) fc.Result = res - return ec.marshalOSeriesEdge2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesEdge(ctx, field.Selections, res) + return ec.marshalNSeriesConnection2ᚖlybbrioᚋinternalᚋentᚐSeriesConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SeriesConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_seriesSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SeriesConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_SeriesEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_SeriesEdge_cursor(ctx, field) + case "edges": + return ec.fieldContext_SeriesConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_SeriesConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_SeriesConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SeriesEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SeriesConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_seriesSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SeriesConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SeriesConnection_pageInfo(ctx, field) +func (ec *executionContext) _Query_shelves(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_shelves(ctx, field) if err != nil { return graphql.Null } @@ -10340,7 +11234,7 @@ func (ec *executionContext) _SeriesConnection_pageInfo(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return ec.resolvers.Query().Shelves(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.ShelfOrder), fc.Args["where"].(*ent.ShelfWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -10352,36 +11246,45 @@ func (ec *executionContext) _SeriesConnection_pageInfo(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.(*ent.ShelfConnection) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNShelfConnection2ᚖlybbrioᚋinternalᚋentᚐShelfConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SeriesConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_shelves(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SeriesConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "edges": + return ec.fieldContext_ShelfConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ShelfConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ShelfConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ShelfConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_shelves_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SeriesConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SeriesConnection_totalCount(ctx, field) +func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_tags(ctx, field) if err != nil { return graphql.Null } @@ -10394,7 +11297,7 @@ func (ec *executionContext) _SeriesConnection_totalCount(ctx context.Context, fi }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return ec.resolvers.Query().Tags(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TagOrder), fc.Args["where"].(*ent.TagWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -10406,26 +11309,45 @@ func (ec *executionContext) _SeriesConnection_totalCount(ctx context.Context, fi } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*ent.TagConnection) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNTagConnection2ᚖlybbrioᚋinternalᚋentᚐTagConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SeriesConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SeriesConnection", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_TagConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TagConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TagConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TagConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SeriesEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SeriesEdge_node(ctx, field) +func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_tasks(ctx, field) if err != nil { return graphql.Null } @@ -10438,47 +11360,57 @@ func (ec *executionContext) _SeriesEdge_node(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return ec.resolvers.Query().Tasks(rctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Series) + res := resTmp.(*ent.TaskConnection) fc.Result = res - return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) + return ec.marshalNTaskConnection2ᚖlybbrioᚋinternalᚋentᚐTaskConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SeriesEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SeriesEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Series_id(ctx, field) - case "calibreID": - return ec.fieldContext_Series_calibreID(ctx, field) - case "name": - return ec.fieldContext_Series_name(ctx, field) - case "sort": - return ec.fieldContext_Series_sort(ctx, field) - case "books": - return ec.fieldContext_Series_books(ctx, field) + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _SeriesEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SeriesEdge_cursor(ctx, field) +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_users(ctx, field) if err != nil { return graphql.Null } @@ -10491,7 +11423,7 @@ func (ec *executionContext) _SeriesEdge_cursor(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return ec.resolvers.Query().Users(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10503,26 +11435,42 @@ func (ec *executionContext) _SeriesEdge_cursor(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(entgql.Cursor[ksuid.ID]) + res := resTmp.([]*ent.User) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNUser2ᚕᚖlybbrioᚋinternalᚋentᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_SeriesEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "SeriesEdge", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shelf_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_id(ctx, field) +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_me(ctx, field) if err != nil { return graphql.Null } @@ -10535,7 +11483,7 @@ func (ec *executionContext) _Shelf_id(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Query().Me(rctx) }) if err != nil { ec.Error(ctx, err) @@ -10547,26 +11495,42 @@ func (ec *executionContext) _Shelf_id(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil } -func (ec *executionContext) _Shelf_public(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_public(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -10579,38 +11543,68 @@ func (ec *executionContext) _Shelf_public(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Public, nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Shelf_userID(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_userID(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -10623,38 +11617,49 @@ func (ec *executionContext) _Shelf_userID(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserID, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _Shelf_name(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_name(ctx, field) +func (ec *executionContext) _Series_id(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_id(ctx, field) if err != nil { return graphql.Null } @@ -10667,7 +11672,7 @@ func (ec *executionContext) _Shelf_name(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -10679,26 +11684,26 @@ func (ec *executionContext) _Shelf_name(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Series", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shelf_description(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_description(ctx, field) +func (ec *executionContext) _Series_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_createTime(ctx, field) if err != nil { return graphql.Null } @@ -10711,35 +11716,38 @@ func (ec *executionContext) _Shelf_description(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Series", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shelf_user(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_user(ctx, field) +func (ec *executionContext) _Series_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -10752,7 +11760,7 @@ func (ec *executionContext) _Shelf_user(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.User(ctx) + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -10764,38 +11772,26 @@ func (ec *executionContext) _Shelf_user(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Series", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Shelf_books(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Shelf_books(ctx, field) +func (ec *executionContext) _Series_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_calibreID(ctx, field) if err != nil { return graphql.Null } @@ -10808,57 +11804,35 @@ func (ec *executionContext) _Shelf_books(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) + return obj.CalibreID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*ent.BookConnection) + res := resTmp.(int64) fc.Result = res - return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) + return ec.marshalOInt2int64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Shelf_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Shelf", + Object: "Series", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BookConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BookConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BookConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Shelf_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _ShelfConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ShelfConnection_edges(ctx, field) +func (ec *executionContext) _Series_name(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_name(ctx, field) if err != nil { return graphql.Null } @@ -10871,41 +11845,38 @@ func (ec *executionContext) _ShelfConnection_edges(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.ShelfEdge) + res := resTmp.(string) fc.Result = res - return ec.marshalOShelfEdge2ᚕᚖlybbrioᚋinternalᚋentᚐShelfEdge(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ShelfConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShelfConnection", + Object: "Series", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_ShelfEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_ShelfEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type ShelfEdge", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShelfConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ShelfConnection_pageInfo(ctx, field) +func (ec *executionContext) _Series_sort(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_sort(ctx, field) if err != nil { return graphql.Null } @@ -10918,7 +11889,7 @@ func (ec *executionContext) _ShelfConnection_pageInfo(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.Sort, nil }) if err != nil { ec.Error(ctx, err) @@ -10930,36 +11901,26 @@ func (ec *executionContext) _ShelfConnection_pageInfo(ctx context.Context, field } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.(string) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ShelfConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_sort(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShelfConnection", + Object: "Series", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ShelfConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ShelfConnection_totalCount(ctx, field) +func (ec *executionContext) _Series_books(ctx context.Context, field graphql.CollectedField, obj *ent.Series) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Series_books(ctx, field) if err != nil { return graphql.Null } @@ -10972,38 +11933,75 @@ func (ec *executionContext) _ShelfConnection_totalCount(ctx context.Context, fie }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.Books(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]*ent.Book) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOBook2ᚕᚖlybbrioᚋinternalᚋentᚐBookᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ShelfConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Series_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShelfConnection", + Object: "Series", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Book_id(ctx, field) + case "createTime": + return ec.fieldContext_Book_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Book_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Book_calibreID(ctx, field) + case "title": + return ec.fieldContext_Book_title(ctx, field) + case "sort": + return ec.fieldContext_Book_sort(ctx, field) + case "publishedDate": + return ec.fieldContext_Book_publishedDate(ctx, field) + case "path": + return ec.fieldContext_Book_path(ctx, field) + case "isbn": + return ec.fieldContext_Book_isbn(ctx, field) + case "description": + return ec.fieldContext_Book_description(ctx, field) + case "seriesIndex": + return ec.fieldContext_Book_seriesIndex(ctx, field) + case "authors": + return ec.fieldContext_Book_authors(ctx, field) + case "publisher": + return ec.fieldContext_Book_publisher(ctx, field) + case "series": + return ec.fieldContext_Book_series(ctx, field) + case "identifiers": + return ec.fieldContext_Book_identifiers(ctx, field) + case "tags": + return ec.fieldContext_Book_tags(ctx, field) + case "language": + return ec.fieldContext_Book_language(ctx, field) + case "shelf": + return ec.fieldContext_Book_shelf(ctx, field) + case "files": + return ec.fieldContext_Book_files(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Book", field.Name) }, } return fc, nil } -func (ec *executionContext) _ShelfEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ShelfEdge_node(ctx, field) +func (ec *executionContext) _SeriesConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SeriesConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -11016,7 +12014,7 @@ func (ec *executionContext) _ShelfEdge_node(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) @@ -11025,42 +12023,32 @@ func (ec *executionContext) _ShelfEdge_node(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Shelf) + res := resTmp.([]*ent.SeriesEdge) fc.Result = res - return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) + return ec.marshalOSeriesEdge2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ShelfEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SeriesConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShelfEdge", + Object: "SeriesConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Shelf_id(ctx, field) - case "public": - return ec.fieldContext_Shelf_public(ctx, field) - case "userID": - return ec.fieldContext_Shelf_userID(ctx, field) - case "name": - return ec.fieldContext_Shelf_name(ctx, field) - case "description": - return ec.fieldContext_Shelf_description(ctx, field) - case "user": - return ec.fieldContext_Shelf_user(ctx, field) - case "books": - return ec.fieldContext_Shelf_books(ctx, field) + case "node": + return ec.fieldContext_SeriesEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_SeriesEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SeriesEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _ShelfEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ShelfEdge_cursor(ctx, field) +func (ec *executionContext) _SeriesConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SeriesConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -11073,7 +12061,7 @@ func (ec *executionContext) _ShelfEdge_cursor(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -11085,26 +12073,36 @@ func (ec *executionContext) _ShelfEdge_cursor(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(entgql.Cursor[ksuid.ID]) + res := resTmp.(entgql.PageInfo[ksuid.ID]) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ShelfEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SeriesConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ShelfEdge", + Object: "SeriesConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_id(ctx, field) +func (ec *executionContext) _SeriesConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SeriesConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -11117,7 +12115,7 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -11129,26 +12127,26 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(int) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SeriesConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "SeriesConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_calibreID(ctx, field) +func (ec *executionContext) _SeriesEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SeriesEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -11161,7 +12159,7 @@ func (ec *executionContext) _Tag_calibreID(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CalibreID, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -11170,26 +12168,42 @@ func (ec *executionContext) _Tag_calibreID(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(int64) + res := resTmp.(*ent.Series) fc.Result = res - return ec.marshalOInt2int64(ctx, field.Selections, res) + return ec.marshalOSeries2ᚖlybbrioᚋinternalᚋentᚐSeries(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SeriesEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "SeriesEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Series_id(ctx, field) + case "createTime": + return ec.fieldContext_Series_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Series_updateTime(ctx, field) + case "calibreID": + return ec.fieldContext_Series_calibreID(ctx, field) + case "name": + return ec.fieldContext_Series_name(ctx, field) + case "sort": + return ec.fieldContext_Series_sort(ctx, field) + case "books": + return ec.fieldContext_Series_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Series", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_name(ctx, field) +func (ec *executionContext) _SeriesEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SeriesEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SeriesEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -11202,7 +12216,7 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -11214,26 +12228,26 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_SeriesEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "SeriesEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tag_books(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_books(ctx, field) +func (ec *executionContext) _Shelf_id(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_id(ctx, field) if err != nil { return graphql.Null } @@ -11246,7 +12260,7 @@ func (ec *executionContext) _Tag_books(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -11258,45 +12272,26 @@ func (ec *executionContext) _Tag_books(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(*ent.BookConnection) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Shelf", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_BookConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_BookConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_BookConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Tag_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TagConnection_edges(ctx, field) +func (ec *executionContext) _Shelf_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_createTime(ctx, field) if err != nil { return graphql.Null } @@ -11309,41 +12304,38 @@ func (ec *executionContext) _TagConnection_edges(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.TagEdge) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOTagEdge2ᚕᚖlybbrioᚋinternalᚋentᚐTagEdge(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TagConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_TagEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TagEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TagConnection_pageInfo(ctx, field) +func (ec *executionContext) _Shelf_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -11356,7 +12348,7 @@ func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -11368,36 +12360,26 @@ func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field g } return graphql.Null } - res := resTmp.(entgql.PageInfo[ksuid.ID]) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TagConnection_totalCount(ctx, field) +func (ec *executionContext) _Shelf_public(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_public(ctx, field) if err != nil { return graphql.Null } @@ -11410,7 +12392,7 @@ func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.Public, nil }) if err != nil { ec.Error(ctx, err) @@ -11422,26 +12404,26 @@ func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field } return graphql.Null } - res := resTmp.(int) + res := resTmp.(bool) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TagConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_public(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagConnection", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TagEdge_node(ctx, field) +func (ec *executionContext) _Shelf_userID(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_userID(ctx, field) if err != nil { return graphql.Null } @@ -11454,45 +12436,38 @@ func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Tag) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TagEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "calibreID": - return ec.fieldContext_Tag_calibreID(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "books": - return ec.fieldContext_Tag_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TagEdge_cursor(ctx, field) +func (ec *executionContext) _Shelf_name(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_name(ctx, field) if err != nil { return graphql.Null } @@ -11505,7 +12480,7 @@ func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -11517,26 +12492,26 @@ func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(entgql.Cursor[ksuid.ID]) + res := resTmp.(string) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TagEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TagEdge", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_id(ctx, field) +func (ec *executionContext) _Shelf_description(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_description(ctx, field) if err != nil { return graphql.Null } @@ -11549,38 +12524,35 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shelf", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_createTime(ctx, field) +func (ec *executionContext) _Shelf_user(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_user(ctx, field) if err != nil { return graphql.Null } @@ -11593,7 +12565,7 @@ func (ec *executionContext) _Task_createTime(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreateTime, nil + return obj.User(ctx) }) if err != nil { ec.Error(ctx, err) @@ -11605,26 +12577,42 @@ func (ec *executionContext) _Task_createTime(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shelf", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_updateTime(ctx, field) +func (ec *executionContext) _Shelf_books(ctx context.Context, field graphql.CollectedField, obj *ent.Shelf) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Shelf_books(ctx, field) if err != nil { return graphql.Null } @@ -11637,7 +12625,7 @@ func (ec *executionContext) _Task_updateTime(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UpdateTime, nil + return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) }) if err != nil { ec.Error(ctx, err) @@ -11649,26 +12637,45 @@ func (ec *executionContext) _Task_updateTime(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.BookConnection) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Shelf_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Shelf", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_BookConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BookConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BookConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Shelf_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_type(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_type(ctx, field) +func (ec *executionContext) _ShelfConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ShelfConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -11681,38 +12688,41 @@ func (ec *executionContext) _Task_type(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(task_enums.TaskType) + res := resTmp.([]*ent.ShelfEdge) fc.Result = res - return ec.marshalNTaskTaskType2lybbrioᚋinternalᚋentᚋschemaᚋtask_enumsᚐTaskType(ctx, field.Selections, res) + return ec.marshalOShelfEdge2ᚕᚖlybbrioᚋinternalᚋentᚐShelfEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShelfConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShelfConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TaskTaskType does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_ShelfEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_ShelfEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ShelfEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_status(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_status(ctx, field) +func (ec *executionContext) _ShelfConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ShelfConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -11725,7 +12735,7 @@ func (ec *executionContext) _Task_status(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Status, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -11737,26 +12747,36 @@ func (ec *executionContext) _Task_status(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(task_enums.Status) + res := resTmp.(entgql.PageInfo[ksuid.ID]) fc.Result = res - return ec.marshalNTaskStatus2lybbrioᚋinternalᚋentᚋschemaᚋtask_enumsᚐStatus(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShelfConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShelfConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TaskStatus does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_progress(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_progress(ctx, field) +func (ec *executionContext) _ShelfConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ShelfConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -11769,7 +12789,7 @@ func (ec *executionContext) _Task_progress(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Progress, nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -11781,26 +12801,26 @@ func (ec *executionContext) _Task_progress(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(float64) + res := resTmp.(int) fc.Result = res - return ec.marshalNFloat2float64(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_progress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShelfConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShelfConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Float does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_message(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_message(ctx, field) +func (ec *executionContext) _ShelfEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ShelfEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -11813,7 +12833,7 @@ func (ec *executionContext) _Task_message(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Message, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -11822,26 +12842,46 @@ func (ec *executionContext) _Task_message(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Shelf) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalOShelf2ᚖlybbrioᚋinternalᚋentᚐShelf(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShelfEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShelfEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Shelf_id(ctx, field) + case "createTime": + return ec.fieldContext_Shelf_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Shelf_updateTime(ctx, field) + case "public": + return ec.fieldContext_Shelf_public(ctx, field) + case "userID": + return ec.fieldContext_Shelf_userID(ctx, field) + case "name": + return ec.fieldContext_Shelf_name(ctx, field) + case "description": + return ec.fieldContext_Shelf_description(ctx, field) + case "user": + return ec.fieldContext_Shelf_user(ctx, field) + case "books": + return ec.fieldContext_Shelf_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_error(ctx, field) +func (ec *executionContext) _ShelfEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.ShelfEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ShelfEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -11854,35 +12894,38 @@ func (ec *executionContext) _Task_error(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Error, nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ShelfEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "ShelfEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_userID(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_userID(ctx, field) +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_id(ctx, field) if err != nil { return graphql.Null } @@ -11895,23 +12938,26 @@ func (ec *executionContext) _Task_userID(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserID, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalOID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, @@ -11922,8 +12968,8 @@ func (ec *executionContext) fieldContext_Task_userID(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Task_isSystemTask(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_isSystemTask(ctx, field) +func (ec *executionContext) _Tag_calibreID(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_calibreID(ctx, field) if err != nil { return graphql.Null } @@ -11936,7 +12982,48 @@ func (ec *executionContext) _Task_isSystemTask(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsSystemTask, nil + return obj.CalibreID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int64) + fc.Result = res + return ec.marshalOInt2int64(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tag_calibreID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tag", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -11948,26 +13035,26 @@ func (ec *executionContext) _Task_isSystemTask(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_isSystemTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_user(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_user(ctx, field) +func (ec *executionContext) _Tag_books(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_books(ctx, field) if err != nil { return graphql.Null } @@ -11980,47 +13067,57 @@ func (ec *executionContext) _Task_user(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.User(ctx) + return obj.Books(ctx, fc.Args["after"].(*entgql.Cursor[ksuid.ID]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[ksuid.ID]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.BookOrder), fc.Args["where"].(*ent.BookWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(*ent.BookConnection) fc.Result = res - return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNBookConnection2ᚖlybbrioᚋinternalᚋentᚐBookConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_books(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Tag", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "username": - return ec.fieldContext_User_username(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "shelves": - return ec.fieldContext_User_shelves(ctx, field) - case "userPermissions": - return ec.fieldContext_User_userPermissions(ctx, field) + case "edges": + return ec.fieldContext_BookConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_BookConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_BookConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type BookConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Tag_books_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) +func (ec *executionContext) _TagConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TagConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -12042,32 +13139,32 @@ func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.TaskEdge) + res := resTmp.([]*ent.TagEdge) fc.Result = res - return ec.marshalOTaskEdge2ᚕᚖlybbrioᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) + return ec.marshalOTagEdge2ᚕᚖlybbrioᚋinternalᚋentᚐTagEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) + return ec.fieldContext_TagEdge_node(ctx, field) case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) + return ec.fieldContext_TagEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TagEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) +func (ec *executionContext) _TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TagConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -12097,9 +13194,9 @@ func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -12120,8 +13217,8 @@ func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Con return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) +func (ec *executionContext) _TagConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TagConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TagConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -12151,9 +13248,9 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "TagConnection", Field: field, IsMethod: false, IsResolver: false, @@ -12164,8 +13261,8 @@ func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.C return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_node(ctx, field) +func (ec *executionContext) _TagEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TagEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -12187,50 +13284,36 @@ func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.Task) + res := resTmp.(*ent.Tag) fc.Result = res - return ec.marshalOTask2ᚖlybbrioᚋinternalᚋentᚐTask(ctx, field.Selections, res) + return ec.marshalOTag2ᚖlybbrioᚋinternalᚋentᚐTag(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createTime": - return ec.fieldContext_Task_createTime(ctx, field) - case "updateTime": - return ec.fieldContext_Task_updateTime(ctx, field) - case "type": - return ec.fieldContext_Task_type(ctx, field) - case "status": - return ec.fieldContext_Task_status(ctx, field) - case "progress": - return ec.fieldContext_Task_progress(ctx, field) - case "message": - return ec.fieldContext_Task_message(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "userID": - return ec.fieldContext_Task_userID(ctx, field) - case "isSystemTask": - return ec.fieldContext_Task_isSystemTask(ctx, field) - case "user": - return ec.fieldContext_Task_user(ctx, field) + return ec.fieldContext_Tag_id(ctx, field) + case "calibreID": + return ec.fieldContext_Tag_calibreID(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "books": + return ec.fieldContext_Tag_books(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) +func (ec *executionContext) _TagEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TagEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TagEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -12260,9 +13343,9 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TagEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "TagEdge", Field: field, IsMethod: false, IsResolver: false, @@ -12273,8 +13356,8 @@ func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_id(ctx, field) if err != nil { return graphql.Null } @@ -12304,9 +13387,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -12317,8 +13400,8 @@ func (ec *executionContext) fieldContext_User_id(ctx context.Context, field grap return fc, nil } -func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_username(ctx, field) +func (ec *executionContext) _Task_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_createTime(ctx, field) if err != nil { return graphql.Null } @@ -12331,7 +13414,7 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Username, nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -12343,26 +13426,26 @@ func (ec *executionContext) _User_username(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_username(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_email(ctx, field) +func (ec *executionContext) _Task_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -12375,7 +13458,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Email, nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -12387,26 +13470,26 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_shelves(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_shelves(ctx, field) +func (ec *executionContext) _Task_type(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_type(ctx, field) if err != nil { return graphql.Null } @@ -12419,51 +13502,38 @@ func (ec *executionContext) _User_shelves(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Shelves(ctx) + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.Shelf) + res := resTmp.(task_enums.TaskType) fc.Result = res - return ec.marshalOShelf2ᚕᚖlybbrioᚋinternalᚋentᚐShelfᚄ(ctx, field.Selections, res) + return ec.marshalNTaskTaskType2lybbrioᚋinternalᚋentᚋschemaᚋtask_enumsᚐTaskType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_shelves(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Shelf_id(ctx, field) - case "public": - return ec.fieldContext_Shelf_public(ctx, field) - case "userID": - return ec.fieldContext_Shelf_userID(ctx, field) - case "name": - return ec.fieldContext_Shelf_name(ctx, field) - case "description": - return ec.fieldContext_Shelf_description(ctx, field) - case "user": - return ec.fieldContext_Shelf_user(ctx, field) - case "books": - return ec.fieldContext_Shelf_books(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) + return nil, errors.New("field of type TaskTaskType does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_userPermissions(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_userPermissions(ctx, field) +func (ec *executionContext) _Task_status(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_status(ctx, field) if err != nil { return graphql.Null } @@ -12476,7 +13546,7 @@ func (ec *executionContext) _User_userPermissions(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserPermissions(ctx) + return obj.Status, nil }) if err != nil { ec.Error(ctx, err) @@ -12488,40 +13558,26 @@ func (ec *executionContext) _User_userPermissions(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(*ent.UserPermissions) + res := resTmp.(task_enums.Status) fc.Result = res - return ec.marshalNUserPermissions2ᚖlybbrioᚋinternalᚋentᚐUserPermissions(ctx, field.Selections, res) + return ec.marshalNTaskStatus2lybbrioᚋinternalᚋentᚋschemaᚋtask_enumsᚐStatus(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_userPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Task", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_UserPermissions_id(ctx, field) - case "userID": - return ec.fieldContext_UserPermissions_userID(ctx, field) - case "canedit": - return ec.fieldContext_UserPermissions_canedit(ctx, field) - case "admin": - return ec.fieldContext_UserPermissions_admin(ctx, field) - case "cancreatepublic": - return ec.fieldContext_UserPermissions_cancreatepublic(ctx, field) - case "user": - return ec.fieldContext_UserPermissions_user(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserPermissions", field.Name) + return nil, errors.New("field of type TaskStatus does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserPermissions_id(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_id(ctx, field) +func (ec *executionContext) _Task_progress(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_progress(ctx, field) if err != nil { return graphql.Null } @@ -12534,7 +13590,7 @@ func (ec *executionContext) _UserPermissions_id(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Progress, nil }) if err != nil { ec.Error(ctx, err) @@ -12546,26 +13602,26 @@ func (ec *executionContext) _UserPermissions_id(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(float64) fc.Result = res - return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_progress(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserPermissions_userID(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_userID(ctx, field) +func (ec *executionContext) _Task_message(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_message(ctx, field) if err != nil { return graphql.Null } @@ -12578,7 +13634,7 @@ func (ec *executionContext) _UserPermissions_userID(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.UserID, nil + return obj.Message, nil }) if err != nil { ec.Error(ctx, err) @@ -12587,26 +13643,26 @@ func (ec *executionContext) _UserPermissions_userID(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.(ksuid.ID) + res := resTmp.(string) fc.Result = res - return ec.marshalOID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_message(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserPermissions_canedit(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_canedit(ctx, field) +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_error(ctx, field) if err != nil { return graphql.Null } @@ -12619,38 +13675,35 @@ func (ec *executionContext) _UserPermissions_canedit(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CanEdit, nil + return obj.Error, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_canedit(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserPermissions_admin(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_admin(ctx, field) +func (ec *executionContext) _Task_userID(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_userID(ctx, field) if err != nil { return graphql.Null } @@ -12663,38 +13716,35 @@ func (ec *executionContext) _UserPermissions_admin(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Admin, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_admin(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UserPermissions_cancreatepublic(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_cancreatepublic(ctx, field) +func (ec *executionContext) _Task_isSystemTask(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_isSystemTask(ctx, field) if err != nil { return graphql.Null } @@ -12707,7 +13757,7 @@ func (ec *executionContext) _UserPermissions_cancreatepublic(ctx context.Context }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CanCreatePublic, nil + return obj.IsSystemTask, nil }) if err != nil { ec.Error(ctx, err) @@ -12724,9 +13774,9 @@ func (ec *executionContext) _UserPermissions_cancreatepublic(ctx context.Context return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_cancreatepublic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_isSystemTask(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -12737,8 +13787,8 @@ func (ec *executionContext) fieldContext_UserPermissions_cancreatepublic(ctx con return fc, nil } -func (ec *executionContext) _UserPermissions_user(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserPermissions_user(ctx, field) +func (ec *executionContext) _Task_user(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_user(ctx, field) if err != nil { return graphql.Null } @@ -12765,9 +13815,9 @@ func (ec *executionContext) _UserPermissions_user(ctx context.Context, field gra return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserPermissions_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserPermissions", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, @@ -12775,6 +13825,10 @@ func (ec *executionContext) fieldContext_UserPermissions_user(ctx context.Contex switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) case "email": @@ -12790,8 +13844,8 @@ func (ec *executionContext) fieldContext_UserPermissions_user(ctx context.Contex return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -12804,38 +13858,41 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.TaskEdge) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOTaskEdge2ᚕᚖlybbrioᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_TaskEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TaskEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -12848,35 +13905,48 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(entgql.PageInfo[ksuid.ID]) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "TaskConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -12889,7 +13959,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -12901,26 +13971,26 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(int) fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -12933,48 +14003,59 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*ent.Task) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOTask2ᚖlybbrioᚋinternalᚋentᚐTask(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createTime": + return ec.fieldContext_Task_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Task_updateTime(ctx, field) case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + return ec.fieldContext_Task_type(ctx, field) + case "status": + return ec.fieldContext_Task_status(ctx, field) + case "progress": + return ec.fieldContext_Task_progress(ctx, field) + case "message": + return ec.fieldContext_Task_message(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "userID": + return ec.fieldContext_Task_userID(ctx, field) + case "isSystemTask": + return ec.fieldContext_Task_isSystemTask(ctx, field) + case "user": + return ec.fieldContext_Task_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -12987,7 +14068,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -12999,26 +14080,26 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(entgql.Cursor[ksuid.ID]) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "TaskEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { return graphql.Null } @@ -13031,7 +14112,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -13043,26 +14124,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _User_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_createTime(ctx, field) if err != nil { return graphql.Null } @@ -13075,35 +14156,38 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _User_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -13116,7 +14200,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -13128,26 +14212,26 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_username(ctx, field) if err != nil { return graphql.Null } @@ -13160,25 +14244,28 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Username, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_username(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -13187,8 +14274,8 @@ func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx conte return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) if err != nil { return graphql.Null } @@ -13201,7 +14288,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Email, nil }) if err != nil { ec.Error(ctx, err) @@ -13218,9 +14305,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_email(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "User", Field: field, IsMethod: false, IsResolver: false, @@ -13231,8 +14318,8 @@ func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _User_shelves(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_shelves(ctx, field) if err != nil { return graphql.Null } @@ -13245,7 +14332,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Shelves(ctx) }) if err != nil { ec.Error(ctx, err) @@ -13254,26 +14341,46 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*ent.Shelf) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOShelf2ᚕᚖlybbrioᚋinternalᚋentᚐShelfᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_shelves(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "User", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Shelf_id(ctx, field) + case "createTime": + return ec.fieldContext_Shelf_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_Shelf_updateTime(ctx, field) + case "public": + return ec.fieldContext_Shelf_public(ctx, field) + case "userID": + return ec.fieldContext_Shelf_userID(ctx, field) + case "name": + return ec.fieldContext_Shelf_name(ctx, field) + case "description": + return ec.fieldContext_Shelf_description(ctx, field) + case "user": + return ec.fieldContext_Shelf_user(ctx, field) + case "books": + return ec.fieldContext_Shelf_books(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Shelf", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _User_userPermissions(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_userPermissions(ctx, field) if err != nil { return graphql.Null } @@ -13286,7 +14393,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.UserPermissions(ctx) }) if err != nil { ec.Error(ctx, err) @@ -13298,36 +14405,44 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*ent.UserPermissions) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNUserPermissions2ᚖlybbrioᚋinternalᚋentᚐUserPermissions(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_userPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "User", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "id": + return ec.fieldContext_UserPermissions_id(ctx, field) + case "createTime": + return ec.fieldContext_UserPermissions_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_UserPermissions_updateTime(ctx, field) + case "userID": + return ec.fieldContext_UserPermissions_userID(ctx, field) + case "admin": + return ec.fieldContext_UserPermissions_admin(ctx, field) + case "cancreatepublic": + return ec.fieldContext_UserPermissions_cancreatepublic(ctx, field) + case "canedit": + return ec.fieldContext_UserPermissions_canedit(ctx, field) + case "user": + return ec.fieldContext_UserPermissions_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPermissions", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _UserPermissions_id(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_id(ctx, field) if err != nil { return graphql.Null } @@ -13340,7 +14455,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -13352,48 +14467,26 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "UserPermissions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _UserPermissions_createTime(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_createTime(ctx, field) if err != nil { return graphql.Null } @@ -13406,7 +14499,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.CreateTime, nil }) if err != nil { ec.Error(ctx, err) @@ -13418,26 +14511,26 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_createTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "UserPermissions", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _UserPermissions_updateTime(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_updateTime(ctx, field) if err != nil { return graphql.Null } @@ -13450,35 +14543,38 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.UpdateTime, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "UserPermissions", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _UserPermissions_userID(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_userID(ctx, field) if err != nil { return graphql.Null } @@ -13491,38 +14587,35 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.UserID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(ksuid.ID) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOID2lybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_userID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UserPermissions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) +func (ec *executionContext) _UserPermissions_admin(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_admin(ctx, field) if err != nil { return graphql.Null } @@ -13535,35 +14628,38 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Admin, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_admin(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UserPermissions", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) +func (ec *executionContext) _UserPermissions_cancreatepublic(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_cancreatepublic(ctx, field) if err != nil { return graphql.Null } @@ -13576,7 +14672,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.CanCreatePublic, nil }) if err != nil { ec.Error(ctx, err) @@ -13588,48 +14684,26 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_cancreatepublic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UserPermissions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) +func (ec *executionContext) _UserPermissions_canedit(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_canedit(ctx, field) if err != nil { return graphql.Null } @@ -13642,35 +14716,38 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.CanEdit, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_canedit(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UserPermissions", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) +func (ec *executionContext) _UserPermissions_user(ctx context.Context, field graphql.CollectedField, obj *ent.UserPermissions) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserPermissions_user(ctx, field) if err != nil { return graphql.Null } @@ -13683,7 +14760,7 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.User(ctx) }) if err != nil { ec.Error(ctx, err) @@ -13692,26 +14769,42 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOUser2ᚖlybbrioᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserPermissions_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "UserPermissions", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "createTime": + return ec.fieldContext_User_createTime(ctx, field) + case "updateTime": + return ec.fieldContext_User_updateTime(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "shelves": + return ec.fieldContext_User_shelves(ctx, field) + case "userPermissions": + return ec.fieldContext_User_userPermissions(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } @@ -13724,7 +14817,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -13736,48 +14829,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) if err != nil { return graphql.Null } @@ -13790,60 +14861,35 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "__Directive", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) if err != nil { return graphql.Null } @@ -13856,57 +14902,38 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.Locations, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type __DirectiveLocation does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) if err != nil { return graphql.Null } @@ -13919,57 +14946,48 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) + return ec.fieldContext___InputValue_name(ctx, field) case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) if err != nil { return graphql.Null } @@ -13982,7 +15000,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.IsRepeatable, nil }) if err != nil { ec.Error(ctx, err) @@ -13994,38 +15012,26 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) if err != nil { return graphql.Null } @@ -14038,7 +15044,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -14052,24 +15058,24 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } res := resTmp.(string) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) if err != nil { return graphql.Null } @@ -14082,7 +15088,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) @@ -14096,9 +15102,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, @@ -14109,8 +15115,8 @@ func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) if err != nil { return graphql.Null } @@ -14123,35 +15129,38 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) if err != nil { return graphql.Null } @@ -14164,7 +15173,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) @@ -14173,51 +15182,26 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) if err != nil { return graphql.Null } @@ -14230,57 +15214,38 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) if err != nil { return graphql.Null } @@ -14293,7 +15258,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) @@ -14302,48 +15267,26 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) if err != nil { return graphql.Null } @@ -14356,56 +15299,48 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": - return ec.fieldContext___EnumValue_name(ctx, field) + return ec.fieldContext___InputValue_name(ctx, field) case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) if err != nil { return graphql.Null } @@ -14418,45 +15353,60 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": - return ec.fieldContext___InputValue_name(ctx, field) + return ec.fieldContext___Type_name(ctx, field) case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) if err != nil { return graphql.Null } @@ -14469,57 +15419,38 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) if err != nil { return graphql.Null } @@ -14532,7 +15463,7 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil + return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) @@ -14546,9 +15477,9 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Field", Field: field, IsMethod: true, IsResolver: false, @@ -14559,56 +15490,1718 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Conte return fc, nil } -// endregion **************************** field.gotpl ***************************** +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} -// region **************************** input.gotpl ***************************** +func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} -func (ec *executionContext) unmarshalInputAuthorOrder(ctx context.Context, obj interface{}) (ent.AuthorOrder, error) { - var it ent.AuthorOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } + return fc, nil +} - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAuthorOrder(ctx context.Context, obj interface{}) (ent.AuthorOrder, error) { + var it ent.AuthorOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNAuthorOrderField2ᚖlybbrioᚋinternalᚋentᚐAuthorOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputAuthorWhereInput(ctx context.Context, obj interface{}) (ent.AuthorWhereInput, error) { + var it ent.AuthorWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "link", "linkNEQ", "linkIn", "linkNotIn", "linkGT", "linkGTE", "linkLT", "linkLTE", "linkContains", "linkHasPrefix", "linkHasSuffix", "linkIsNil", "linkNotNil", "linkEqualFold", "linkContainsFold", "hasBooks", "hasBooksWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOAuthorWhereInput2ᚖlybbrioᚋinternalᚋentᚐAuthorWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOAuthorWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐAuthorWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOAuthorWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐAuthorWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data + case "calibreID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreID = data + case "calibreIDNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNEQ")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDNEQ = data + case "calibreIDIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDIn")) + data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDIn = data + case "calibreIDNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNotIn")) + data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDNotIn = data + case "calibreIDGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDGT")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDGT = data + case "calibreIDGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDGTE")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDGTE = data + case "calibreIDLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDLT")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDLT = data + case "calibreIDLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDLTE")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDLTE = data + case "calibreIDIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDIsNil = data + case "calibreIDNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.CalibreIDNotNil = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "sort": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sort")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Sort = data + case "sortNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortNEQ = data + case "sortIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.SortIn = data + case "sortNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.SortNotIn = data + case "sortGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortGT = data + case "sortGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortGTE = data + case "sortLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortLT = data + case "sortLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortLTE = data + case "sortContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortContains = data + case "sortHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortHasPrefix = data + case "sortHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortHasSuffix = data + case "sortEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortEqualFold = data + case "sortContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.SortContainsFold = data + case "link": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Link = data + case "linkNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkNEQ = data + case "linkIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.LinkIn = data + case "linkNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.LinkNotIn = data + case "linkGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkGT = data + case "linkGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkGTE = data + case "linkLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkLT = data + case "linkLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkLTE = data + case "linkContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkContains = data + case "linkHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkHasPrefix = data + case "linkHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LinkHasSuffix = data + case "linkIsNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LinkIsNil = data + case "linkNotNil": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LinkNotNil = data + case "linkEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAuthorOrderField2ᚖlybbrioᚋinternalᚋentᚐAuthorOrderField(ctx, v) + it.LinkEqualFold = data + case "linkContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Field = data + it.LinkContainsFold = data + case "hasBooks": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBooks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasBooks = data + case "hasBooksWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBooksWith")) + data, err := ec.unmarshalOBookWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasBooksWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputAuthorWhereInput(ctx context.Context, obj interface{}) (ent.AuthorWhereInput, error) { - var it ent.AuthorWhereInput +func (ec *executionContext) unmarshalInputBookFileWhereInput(ctx context.Context, obj interface{}) (ent.BookFileWhereInput, error) { + var it ent.BookFileWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "link", "linkNEQ", "linkIn", "linkNotIn", "linkGT", "linkGTE", "linkLT", "linkLTE", "linkContains", "linkHasPrefix", "linkHasSuffix", "linkIsNil", "linkNotNil", "linkEqualFold", "linkContainsFold", "hasBooks", "hasBooksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "format", "formatNEQ", "formatIn", "formatNotIn", "hasBook", "hasBookWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -14617,21 +17210,21 @@ func (ec *executionContext) unmarshalInputAuthorWhereInput(ctx context.Context, switch k { case "not": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAuthorWhereInput2ᚖlybbrioᚋinternalᚋentᚐAuthorWhereInput(ctx, v) + data, err := ec.unmarshalOBookFileWhereInput2ᚖlybbrioᚋinternalᚋentᚐBookFileWhereInput(ctx, v) if err != nil { return it, err } it.Not = data case "and": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAuthorWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐAuthorWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBookFileWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileWhereInputᚄ(ctx, v) if err != nil { return it, err } it.And = data case "or": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAuthorWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐAuthorWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOBookFileWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -14692,76 +17285,118 @@ func (ec *executionContext) unmarshalInputAuthorWhereInput(ctx context.Context, return it, err } it.IDLTE = data - case "calibreID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreID = data - case "calibreIDNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNEQ")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDNEQ = data - case "calibreIDIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.CalibreIDIn = data - case "calibreIDNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNotIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.CalibreIDNotIn = data - case "calibreIDGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDGT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDGT = data - case "calibreIDGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDGTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDGTE = data - case "calibreIDLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDLT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDLT = data - case "calibreIDLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDLTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDLTE = data - case "calibreIDIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDIsNil = data - case "calibreIDNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreIDNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.CalibreIDNotNil = data + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -14853,216 +17488,195 @@ func (ec *executionContext) unmarshalInputAuthorWhereInput(ctx context.Context, return it, err } it.NameContainsFold = data - case "sort": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sort")) + case "path": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Sort = data - case "sortNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortNEQ")) + it.Path = data + case "pathNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortNEQ = data - case "sortIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortIn")) + it.PathNEQ = data + case "pathIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SortIn = data - case "sortNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortNotIn")) + it.PathIn = data + case "pathNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.SortNotIn = data - case "sortGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.SortGT = data - case "sortGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.SortGTE = data - case "sortLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortLT")) + it.PathNotIn = data + case "pathGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortLT = data - case "sortLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortLTE")) + it.PathGT = data + case "pathGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortLTE = data - case "sortContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortContains")) + it.PathGTE = data + case "pathLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortContains = data - case "sortHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortHasPrefix")) + it.PathLT = data + case "pathLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortHasPrefix = data - case "sortHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortHasSuffix")) + it.PathLTE = data + case "pathContains": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortHasSuffix = data - case "sortEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortEqualFold")) + it.PathContains = data + case "pathHasPrefix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortEqualFold = data - case "sortContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortContainsFold")) + it.PathHasPrefix = data + case "pathHasSuffix": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.SortContainsFold = data - case "link": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("link")) + it.PathHasSuffix = data + case "pathEqualFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Link = data - case "linkNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNEQ")) + it.PathEqualFold = data + case "pathContainsFold": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LinkNEQ = data - case "linkIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.LinkIn = data - case "linkNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + it.PathContainsFold = data + case "size": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkNotIn = data - case "linkGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Size = data + case "sizeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkGT = data - case "linkGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeNEQ = data + case "sizeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) if err != nil { return it, err } - it.LinkGTE = data - case "linkLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeIn = data + case "sizeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) if err != nil { return it, err } - it.LinkLT = data - case "linkLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeNotIn = data + case "sizeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkLTE = data - case "linkContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeGT = data + case "sizeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkContains = data - case "linkHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeGTE = data + case "sizeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkHasPrefix = data - case "linkHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.SizeLT = data + case "sizeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint64(ctx, v) if err != nil { return it, err } - it.LinkHasSuffix = data - case "linkIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.SizeLTE = data + case "format": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("format")) + data, err := ec.unmarshalOBookFileFormat2ᚖlybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx, v) if err != nil { return it, err } - it.LinkIsNil = data - case "linkNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + it.Format = data + case "formatNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("formatNEQ")) + data, err := ec.unmarshalOBookFileFormat2ᚖlybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx, v) if err != nil { return it, err } - it.LinkNotNil = data - case "linkEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.FormatNEQ = data + case "formatIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("formatIn")) + data, err := ec.unmarshalOBookFileFormat2ᚕlybbrioᚋinternalᚋentᚋbookfileᚐFormatᚄ(ctx, v) if err != nil { return it, err } - it.LinkEqualFold = data - case "linkContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("linkContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.FormatIn = data + case "formatNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("formatNotIn")) + data, err := ec.unmarshalOBookFileFormat2ᚕlybbrioᚋinternalᚋentᚋbookfileᚐFormatᚄ(ctx, v) if err != nil { return it, err } - it.LinkContainsFold = data - case "hasBooks": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBooks")) + it.FormatNotIn = data + case "hasBook": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBook")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasBooks = data - case "hasBooksWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBooksWith")) + it.HasBook = data + case "hasBookWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBookWith")) data, err := ec.unmarshalOBookWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasBooksWith = data + it.HasBookWith = data } } @@ -15114,7 +17728,7 @@ func (ec *executionContext) unmarshalInputBookWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "title", "titleNEQ", "titleIn", "titleNotIn", "titleGT", "titleGTE", "titleLT", "titleLTE", "titleContains", "titleHasPrefix", "titleHasSuffix", "titleEqualFold", "titleContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "publishedDate", "publishedDateNEQ", "publishedDateIn", "publishedDateNotIn", "publishedDateGT", "publishedDateGTE", "publishedDateLT", "publishedDateLTE", "publishedDateIsNil", "publishedDateNotNil", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "isbn", "isbnNEQ", "isbnIn", "isbnNotIn", "isbnGT", "isbnGTE", "isbnLT", "isbnLTE", "isbnContains", "isbnHasPrefix", "isbnHasSuffix", "isbnIsNil", "isbnNotNil", "isbnEqualFold", "isbnContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "seriesIndex", "seriesIndexNEQ", "seriesIndexIn", "seriesIndexNotIn", "seriesIndexGT", "seriesIndexGTE", "seriesIndexLT", "seriesIndexLTE", "seriesIndexIsNil", "seriesIndexNotNil", "hasAuthors", "hasAuthorsWith", "hasPublisher", "hasPublisherWith", "hasSeries", "hasSeriesWith", "hasIdentifiers", "hasIdentifiersWith", "hasTags", "hasTagsWith", "hasLanguage", "hasLanguageWith", "hasShelf", "hasShelfWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "title", "titleNEQ", "titleIn", "titleNotIn", "titleGT", "titleGTE", "titleLT", "titleLTE", "titleContains", "titleHasPrefix", "titleHasSuffix", "titleEqualFold", "titleContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "publishedDate", "publishedDateNEQ", "publishedDateIn", "publishedDateNotIn", "publishedDateGT", "publishedDateGTE", "publishedDateLT", "publishedDateLTE", "publishedDateIsNil", "publishedDateNotNil", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "isbn", "isbnNEQ", "isbnIn", "isbnNotIn", "isbnGT", "isbnGTE", "isbnLT", "isbnLTE", "isbnContains", "isbnHasPrefix", "isbnHasSuffix", "isbnIsNil", "isbnNotNil", "isbnEqualFold", "isbnContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "seriesIndex", "seriesIndexNEQ", "seriesIndexIn", "seriesIndexNotIn", "seriesIndexGT", "seriesIndexGTE", "seriesIndexLT", "seriesIndexLTE", "seriesIndexIsNil", "seriesIndexNotNil", "hasAuthors", "hasAuthorsWith", "hasPublisher", "hasPublisherWith", "hasSeries", "hasSeriesWith", "hasIdentifiers", "hasIdentifiersWith", "hasTags", "hasTagsWith", "hasLanguage", "hasLanguageWith", "hasShelf", "hasShelfWith", "hasFiles", "hasFilesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -15198,6 +17812,118 @@ func (ec *executionContext) unmarshalInputBookWhereInput(ctx context.Context, ob return it, err } it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -15989,6 +18715,20 @@ func (ec *executionContext) unmarshalInputBookWhereInput(ctx context.Context, ob return it, err } it.HasShelfWith = data + case "hasFiles": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFiles")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasFiles = data + case "hasFilesWith": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFilesWith")) + data, err := ec.unmarshalOBookFileWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasFilesWith = data } } @@ -16002,13 +18742,27 @@ func (ec *executionContext) unmarshalInputCreateAuthorInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "name", "sort", "link", "bookIDs"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "name", "sort", "link", "bookIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16057,13 +18811,27 @@ func (ec *executionContext) unmarshalInputCreateBookInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "title", "sort", "publishedDate", "path", "isbn", "description", "seriesIndex", "authorIDs", "publisherIDs", "seriesIDs", "identifierIDs", "tagIDs", "languageIDs", "shelfIDs"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "title", "sort", "publishedDate", "path", "isbn", "description", "seriesIndex", "authorIDs", "publisherIDs", "seriesIDs", "identifierIDs", "tagIDs", "languageIDs", "shelfIDs", "fileIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16169,6 +18937,13 @@ func (ec *executionContext) unmarshalInputCreateBookInput(ctx context.Context, o return it, err } it.ShelfIDs = data + case "fileIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.FileIDs = data } } @@ -16182,13 +18957,27 @@ func (ec *executionContext) unmarshalInputCreateIdentifierInput(ctx context.Cont asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "type", "value", "bookID"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "type", "value", "bookID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16230,13 +19019,27 @@ func (ec *executionContext) unmarshalInputCreateLanguageInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "code", "bookIDs"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "code", "bookIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16271,13 +19074,27 @@ func (ec *executionContext) unmarshalInputCreatePublisherInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "name", "bookIDs"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "name", "bookIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16312,13 +19129,27 @@ func (ec *executionContext) unmarshalInputCreateSeriesInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "name", "sort", "bookIDs"} + fieldsInOrder := [...]string{"createTime", "updateTime", "calibreID", "name", "sort", "bookIDs"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16476,13 +19307,27 @@ func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"username", "passwordHash", "email", "shelfIDs", "userPermissionsID"} + fieldsInOrder := [...]string{"createTime", "updateTime", "username", "passwordHash", "email", "shelfIDs", "userPermissionsID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "username": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalNString2string(ctx, v) @@ -16569,7 +19414,7 @@ func (ec *executionContext) unmarshalInputIdentifierWhereInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "type", "typeNEQ", "typeIn", "typeNotIn", "typeGT", "typeGTE", "typeLT", "typeLTE", "typeContains", "typeHasPrefix", "typeHasSuffix", "typeEqualFold", "typeContainsFold", "value", "valueNEQ", "valueIn", "valueNotIn", "valueGT", "valueGTE", "valueLT", "valueLTE", "valueContains", "valueHasPrefix", "valueHasSuffix", "valueEqualFold", "valueContainsFold", "hasBook", "hasBookWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "type", "typeNEQ", "typeIn", "typeNotIn", "typeGT", "typeGTE", "typeLT", "typeLTE", "typeContains", "typeHasPrefix", "typeHasSuffix", "typeEqualFold", "typeContainsFold", "value", "valueNEQ", "valueIn", "valueNotIn", "valueGT", "valueGTE", "valueLT", "valueLTE", "valueContains", "valueHasPrefix", "valueHasSuffix", "valueEqualFold", "valueContainsFold", "hasBook", "hasBookWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -16653,6 +19498,118 @@ func (ec *executionContext) unmarshalInputIdentifierWhereInput(ctx context.Conte return it, err } it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -16970,7 +19927,7 @@ func (ec *executionContext) unmarshalInputLanguageWhereInput(ctx context.Context asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "code", "codeNEQ", "codeIn", "codeNotIn", "codeGT", "codeGTE", "codeLT", "codeLTE", "codeContains", "codeHasPrefix", "codeHasSuffix", "codeEqualFold", "codeContainsFold", "hasBooks", "hasBooksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "code", "codeNEQ", "codeIn", "codeNotIn", "codeGT", "codeGTE", "codeLT", "codeLTE", "codeContains", "codeHasPrefix", "codeHasSuffix", "codeEqualFold", "codeContainsFold", "hasBooks", "hasBooksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -17025,35 +19982,147 @@ func (ec *executionContext) unmarshalInputLanguageWhereInput(ctx context.Context if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLTE = data + it.UpdateTimeLTE = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -17280,7 +20349,7 @@ func (ec *executionContext) unmarshalInputPublisherWhereInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasBooks", "hasBooksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "hasBooks", "hasBooksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -17364,6 +20433,118 @@ func (ec *executionContext) unmarshalInputPublisherWhereInput(ctx context.Contex return it, err } it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -17590,7 +20771,7 @@ func (ec *executionContext) unmarshalInputSeriesWhereInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "hasBooks", "hasBooksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "calibreID", "calibreIDNEQ", "calibreIDIn", "calibreIDNotIn", "calibreIDGT", "calibreIDGTE", "calibreIDLT", "calibreIDLTE", "calibreIDIsNil", "calibreIDNotNil", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "sort", "sortNEQ", "sortIn", "sortNotIn", "sortGT", "sortGTE", "sortLT", "sortLTE", "sortContains", "sortHasPrefix", "sortHasSuffix", "sortEqualFold", "sortContainsFold", "hasBooks", "hasBooksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -17603,77 +20784,189 @@ func (ec *executionContext) unmarshalInputSeriesWhereInput(ctx context.Context, if err != nil { return it, err } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOSeriesWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesWhereInputᚄ(ctx, v) + it.Not = data + case "and": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOSeriesWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOSeriesWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOSeriesWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐSeriesWhereInputᚄ(ctx, v) + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLTE = data + it.UpdateTimeLTE = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -17991,7 +21284,7 @@ func (ec *executionContext) unmarshalInputShelfWhereInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "public", "publicNEQ", "userID", "userIDNEQ", "userIDIn", "userIDNotIn", "userIDGT", "userIDGTE", "userIDLT", "userIDLTE", "userIDContains", "userIDHasPrefix", "userIDHasSuffix", "userIDEqualFold", "userIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "hasUser", "hasUserWith", "hasBooks", "hasBooksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "public", "publicNEQ", "userID", "userIDNEQ", "userIDIn", "userIDNotIn", "userIDGT", "userIDGTE", "userIDLT", "userIDLTE", "userIDContains", "userIDHasPrefix", "userIDHasSuffix", "userIDEqualFold", "userIDContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "description", "descriptionNEQ", "descriptionIn", "descriptionNotIn", "descriptionGT", "descriptionGTE", "descriptionLT", "descriptionLTE", "descriptionContains", "descriptionHasPrefix", "descriptionHasSuffix", "descriptionIsNil", "descriptionNotNil", "descriptionEqualFold", "descriptionContainsFold", "hasUser", "hasUserWith", "hasBooks", "hasBooksWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -18075,6 +21368,118 @@ func (ec *executionContext) unmarshalInputShelfWhereInput(ctx context.Context, o return it, err } it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "public": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -19429,13 +22834,20 @@ func (ec *executionContext) unmarshalInputUpdateAuthorInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "name", "sort", "link", "clearLink", "addBookIDs", "removeBookIDs", "clearBooks"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "name", "sort", "link", "clearLink", "addBookIDs", "removeBookIDs", "clearBooks"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -19512,13 +22924,20 @@ func (ec *executionContext) unmarshalInputUpdateBookInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "title", "sort", "publishedDate", "clearPublishedDate", "path", "isbn", "clearIsbn", "description", "clearDescription", "seriesIndex", "clearSeriesIndex", "addAuthorIDs", "removeAuthorIDs", "clearAuthors", "addPublisherIDs", "removePublisherIDs", "clearPublisher", "addSeriesIDs", "removeSeriesIDs", "clearSeries", "addIdentifierIDs", "removeIdentifierIDs", "clearIdentifiers", "addTagIDs", "removeTagIDs", "clearTags", "addLanguageIDs", "removeLanguageIDs", "clearLanguage", "addShelfIDs", "removeShelfIDs", "clearShelf"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "title", "sort", "publishedDate", "clearPublishedDate", "path", "isbn", "clearIsbn", "description", "clearDescription", "seriesIndex", "clearSeriesIndex", "addAuthorIDs", "removeAuthorIDs", "clearAuthors", "addPublisherIDs", "removePublisherIDs", "clearPublisher", "addSeriesIDs", "removeSeriesIDs", "clearSeries", "addIdentifierIDs", "removeIdentifierIDs", "clearIdentifiers", "addTagIDs", "removeTagIDs", "clearTags", "addLanguageIDs", "removeLanguageIDs", "clearLanguage", "addShelfIDs", "removeShelfIDs", "clearShelf", "addFileIDs", "removeFileIDs", "clearFiles"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -19757,6 +23176,27 @@ func (ec *executionContext) unmarshalInputUpdateBookInput(ctx context.Context, o return it, err } it.ClearShelf = data + case "addFileIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFileIDs")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddFileIDs = data + case "removeFileIDs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFileIDs")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveFileIDs = data + case "clearFiles": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFiles")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearFiles = data } } @@ -19770,13 +23210,20 @@ func (ec *executionContext) unmarshalInputUpdateIdentifierInput(ctx context.Cont asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "type", "value", "bookID"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "type", "value", "bookID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -19825,13 +23272,20 @@ func (ec *executionContext) unmarshalInputUpdateLanguageInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "code", "addBookIDs", "removeBookIDs", "clearBooks"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "code", "addBookIDs", "removeBookIDs", "clearBooks"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -19887,13 +23341,20 @@ func (ec *executionContext) unmarshalInputUpdatePublisherInput(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "name", "addBookIDs", "removeBookIDs", "clearBooks"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "name", "addBookIDs", "removeBookIDs", "clearBooks"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -19949,13 +23410,20 @@ func (ec *executionContext) unmarshalInputUpdateSeriesInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"calibreID", "clearCalibreID", "name", "sort", "addBookIDs", "removeBookIDs", "clearBooks"} + fieldsInOrder := [...]string{"updateTime", "calibreID", "clearCalibreID", "name", "sort", "addBookIDs", "removeBookIDs", "clearBooks"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "calibreID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("calibreID")) data, err := ec.unmarshalOInt2ᚖint64(ctx, v) @@ -20018,13 +23486,20 @@ func (ec *executionContext) unmarshalInputUpdateShelfInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"public", "name", "description", "clearDescription", "addBookIDs", "removeBookIDs", "clearBooks"} + fieldsInOrder := [...]string{"updateTime", "public", "name", "description", "clearDescription", "addBookIDs", "removeBookIDs", "clearBooks"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "public": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -20149,13 +23624,20 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"username", "passwordHash", "clearPasswordHash", "email", "addShelfIDs", "removeShelfIDs", "clearShelves"} + fieldsInOrder := [...]string{"updateTime", "username", "passwordHash", "clearPasswordHash", "email", "addShelfIDs", "removeShelfIDs", "clearShelves"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data case "username": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -20256,7 +23738,7 @@ func (ec *executionContext) unmarshalInputUserPermissionsWhereInput(ctx context. asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "userID", "userIDNEQ", "userIDIn", "userIDNotIn", "userIDGT", "userIDGTE", "userIDLT", "userIDLTE", "userIDContains", "userIDHasPrefix", "userIDHasSuffix", "userIDIsNil", "userIDNotNil", "userIDEqualFold", "userIDContainsFold", "canedit", "caneditNEQ", "admin", "adminNEQ", "cancreatepublic", "cancreatepublicNEQ", "hasUser", "hasUserWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "userID", "userIDNEQ", "userIDIn", "userIDNotIn", "userIDGT", "userIDGTE", "userIDLT", "userIDLTE", "userIDContains", "userIDHasPrefix", "userIDHasSuffix", "userIDIsNil", "userIDNotNil", "userIDEqualFold", "userIDContainsFold", "admin", "adminNEQ", "cancreatepublic", "cancreatepublicNEQ", "canedit", "caneditNEQ", "hasUser", "hasUserWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -20340,6 +23822,118 @@ func (ec *executionContext) unmarshalInputUserPermissionsWhereInput(ctx context. return it, err } it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.UpdateTimeLTE = data case "userID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) @@ -20445,20 +24039,6 @@ func (ec *executionContext) unmarshalInputUserPermissionsWhereInput(ctx context. return it, err } it.UserIDContainsFold = data - case "canedit": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("canedit")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.CanEdit = data - case "caneditNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caneditNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.CanEditNEQ = data case "admin": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("admin")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -20487,6 +24067,20 @@ func (ec *executionContext) unmarshalInputUserPermissionsWhereInput(ctx context. return it, err } it.CanCreatePublicNEQ = data + case "canedit": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("canedit")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.CanEdit = data + case "caneditNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("caneditNEQ")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.CanEditNEQ = data case "hasUser": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasUser")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) @@ -20514,7 +24108,7 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "usernameContains", "usernameHasPrefix", "usernameHasSuffix", "usernameEqualFold", "usernameContainsFold", "email", "emailNEQ", "emailIn", "emailNotIn", "emailGT", "emailGTE", "emailLT", "emailLTE", "emailContains", "emailHasPrefix", "emailHasSuffix", "emailEqualFold", "emailContainsFold", "hasShelves", "hasShelvesWith", "hasUserPermissions", "hasUserPermissionsWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createTime", "createTimeNEQ", "createTimeIn", "createTimeNotIn", "createTimeGT", "createTimeGTE", "createTimeLT", "createTimeLTE", "updateTime", "updateTimeNEQ", "updateTimeIn", "updateTimeNotIn", "updateTimeGT", "updateTimeGTE", "updateTimeLT", "updateTimeLTE", "username", "usernameNEQ", "usernameIn", "usernameNotIn", "usernameGT", "usernameGTE", "usernameLT", "usernameLTE", "usernameContains", "usernameHasPrefix", "usernameHasSuffix", "usernameEqualFold", "usernameContainsFold", "email", "emailNEQ", "emailIn", "emailNotIn", "emailGT", "emailGTE", "emailLT", "emailLTE", "emailContains", "emailHasPrefix", "emailHasSuffix", "emailEqualFold", "emailContainsFold", "hasShelves", "hasShelvesWith", "hasUserPermissions", "hasUserPermissionsWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -20541,63 +24135,175 @@ func (ec *executionContext) unmarshalInputUserWhereInput(ctx context.Context, ob if err != nil { return it, err } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.Or = data + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTime = data + case "createTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNEQ = data + case "createTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeIn = data + case "createTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeNotIn = data + case "createTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGT = data + case "createTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeGTE = data + case "createTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLT = data + case "createTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreateTimeLTE = data + case "updateTime": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTime")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTime = data + case "updateTimeNEQ": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + it.UpdateTimeNEQ = data + case "updateTimeIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐIDᚄ(ctx, v) + it.UpdateTimeIn = data + case "updateTimeNotIn": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeNotIn = data + case "updateTimeGT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGT = data + case "updateTimeGTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeGTE = data + case "updateTimeLT": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖlybbrioᚋinternalᚋentᚋschemaᚋksuidᚐID(ctx, v) + it.UpdateTimeLT = data + case "updateTimeLTE": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("updateTimeLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.IDLTE = data + it.UpdateTimeLTE = data case "username": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("username")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) @@ -20832,6 +24538,11 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Book(ctx, sel, obj) + case *ent.BookFile: + if obj == nil { + return graphql.Null + } + return ec._BookFile(ctx, sel, obj) case *ent.Identifier: if obj == nil { return graphql.Null @@ -20902,6 +24613,16 @@ func (ec *executionContext) _Author(ctx context.Context, sel ast.SelectionSet, o if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Author_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Author_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Author_calibreID(ctx, field, obj) case "name": @@ -21078,6 +24799,16 @@ func (ec *executionContext) _Book(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Book_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Book_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Book_calibreID(ctx, field, obj) case "title": @@ -21333,6 +25064,39 @@ func (ec *executionContext) _Book(ctx context.Context, sel ast.SelectionSet, obj continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "files": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Book_files(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) @@ -21444,6 +25208,111 @@ func (ec *executionContext) _BookEdge(ctx context.Context, sel ast.SelectionSet, return out } +var bookFileImplementors = []string{"BookFile", "Node"} + +func (ec *executionContext) _BookFile(ctx context.Context, sel ast.SelectionSet, obj *ent.BookFile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, bookFileImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BookFile") + case "id": + out.Values[i] = ec._BookFile_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "createTime": + out.Values[i] = ec._BookFile_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._BookFile_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._BookFile_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "path": + out.Values[i] = ec._BookFile_path(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "size": + out.Values[i] = ec._BookFile_size(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "format": + out.Values[i] = ec._BookFile_format(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "book": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._BookFile_book(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var identifierImplementors = []string{"Identifier", "Node"} func (ec *executionContext) _Identifier(ctx context.Context, sel ast.SelectionSet, obj *ent.Identifier) graphql.Marshaler { @@ -21460,6 +25329,16 @@ func (ec *executionContext) _Identifier(ctx context.Context, sel ast.SelectionSe if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Identifier_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Identifier_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Identifier_calibreID(ctx, field, obj) case "type": @@ -21634,6 +25513,16 @@ func (ec *executionContext) _Language(ctx context.Context, sel ast.SelectionSet, if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Language_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Language_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Language_calibreID(ctx, field, obj) case "code": @@ -21969,6 +25858,16 @@ func (ec *executionContext) _Publisher(ctx context.Context, sel ast.SelectionSet if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Publisher_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Publisher_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Publisher_calibreID(ctx, field, obj) case "name": @@ -22160,7 +26059,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "nodes": + case "nodes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_nodes(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "authors": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22169,7 +26090,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_nodes(ctx, field) + res = ec._Query_authors(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22182,7 +26103,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "authors": + case "books": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22191,7 +26112,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_authors(ctx, field) + res = ec._Query_books(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22204,7 +26125,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "books": + case "bookFiles": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -22213,7 +26134,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_books(ctx, field) + res = ec._Query_bookFiles(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -22471,6 +26392,16 @@ func (ec *executionContext) _Series(ctx context.Context, sel ast.SelectionSet, o if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Series_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Series_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "calibreID": out.Values[i] = ec._Series_calibreID(ctx, field, obj) case "name": @@ -22642,6 +26573,16 @@ func (ec *executionContext) _Shelf(ctx context.Context, sel ast.SelectionSet, ob if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._Shelf_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._Shelf_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "public": out.Values[i] = ec._Shelf_public(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -23221,6 +27162,16 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "createTime": + out.Values[i] = ec._User_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._User_updateTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "username": out.Values[i] = ec._User_username(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -23339,13 +27290,18 @@ func (ec *executionContext) _UserPermissions(ctx context.Context, sel ast.Select if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "userID": - out.Values[i] = ec._UserPermissions_userID(ctx, field, obj) - case "canedit": - out.Values[i] = ec._UserPermissions_canedit(ctx, field, obj) + case "createTime": + out.Values[i] = ec._UserPermissions_createTime(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + out.Values[i] = ec._UserPermissions_updateTime(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "userID": + out.Values[i] = ec._UserPermissions_userID(ctx, field, obj) case "admin": out.Values[i] = ec._UserPermissions_admin(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -23356,6 +27312,11 @@ func (ec *executionContext) _UserPermissions(ctx context.Context, sel ast.Select if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "canedit": + out.Values[i] = ec._UserPermissions_canedit(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "user": field := field @@ -23812,6 +27773,75 @@ func (ec *executionContext) marshalNBookConnection2ᚖlybbrioᚋinternalᚋent return ec._BookConnection(ctx, sel, v) } +func (ec *executionContext) marshalNBookFile2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.BookFile) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNBookFile2ᚖlybbrioᚋinternalᚋentᚐBookFile(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNBookFile2ᚖlybbrioᚋinternalᚋentᚐBookFile(ctx context.Context, sel ast.SelectionSet, v *ent.BookFile) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._BookFile(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNBookFileFormat2lybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx context.Context, v interface{}) (bookfile.Format, error) { + var res bookfile.Format + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBookFileFormat2lybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx context.Context, sel ast.SelectionSet, v bookfile.Format) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNBookFileWhereInput2ᚖlybbrioᚋinternalᚋentᚐBookFileWhereInput(ctx context.Context, v interface{}) (*ent.BookFileWhereInput, error) { + res, err := ec.unmarshalInputBookFileWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNBookOrder2ᚖlybbrioᚋinternalᚋentᚐBookOrder(ctx context.Context, v interface{}) (*ent.BookOrder, error) { res, err := ec.unmarshalInputBookOrder(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -25086,6 +29116,164 @@ func (ec *executionContext) marshalOBookEdge2ᚖlybbrioᚋinternalᚋentᚐBookE return ec._BookEdge(ctx, sel, v) } +func (ec *executionContext) marshalOBookFile2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.BookFile) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNBookFile2ᚖlybbrioᚋinternalᚋentᚐBookFile(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOBookFileFormat2ᚕlybbrioᚋinternalᚋentᚋbookfileᚐFormatᚄ(ctx context.Context, v interface{}) ([]bookfile.Format, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]bookfile.Format, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBookFileFormat2lybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOBookFileFormat2ᚕlybbrioᚋinternalᚋentᚋbookfileᚐFormatᚄ(ctx context.Context, sel ast.SelectionSet, v []bookfile.Format) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNBookFileFormat2lybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOBookFileFormat2ᚖlybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx context.Context, v interface{}) (*bookfile.Format, error) { + if v == nil { + return nil, nil + } + var res = new(bookfile.Format) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBookFileFormat2ᚖlybbrioᚋinternalᚋentᚋbookfileᚐFormat(ctx context.Context, sel ast.SelectionSet, v *bookfile.Format) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOBookFileWhereInput2ᚕᚖlybbrioᚋinternalᚋentᚐBookFileWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.BookFileWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.BookFileWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNBookFileWhereInput2ᚖlybbrioᚋinternalᚋentᚐBookFileWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOBookFileWhereInput2ᚖlybbrioᚋinternalᚋentᚐBookFileWhereInput(ctx context.Context, v interface{}) (*ent.BookFileWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputBookFileWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOBookOrder2ᚕᚖlybbrioᚋinternalᚋentᚐBookOrderᚄ(ctx context.Context, v interface{}) ([]*ent.BookOrder, error) { if v == nil { return nil, nil diff --git a/internal/task/scheduler.go b/internal/scheduler/scheduler.go similarity index 99% rename from internal/task/scheduler.go rename to internal/scheduler/scheduler.go index 86e0c8f4..9e9e745a 100644 --- a/internal/task/scheduler.go +++ b/internal/scheduler/scheduler.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/internal/task/scheduler_test.go b/internal/scheduler/scheduler_test.go similarity index 99% rename from internal/task/scheduler_test.go rename to internal/scheduler/scheduler_test.go index 3dbf6565..d1c86a78 100644 --- a/internal/task/scheduler_test.go +++ b/internal/scheduler/scheduler_test.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/internal/task/task.go b/internal/scheduler/task.go similarity index 98% rename from internal/task/task.go rename to internal/scheduler/task.go index 0dcc709c..fede602c 100644 --- a/internal/task/task.go +++ b/internal/scheduler/task.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/internal/task/task_test.go b/internal/scheduler/task_test.go similarity index 98% rename from internal/task/task_test.go rename to internal/scheduler/task_test.go index 7aada7bb..f00681a0 100644 --- a/internal/task/task_test.go +++ b/internal/scheduler/task_test.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/internal/task/worker.go b/internal/scheduler/worker.go similarity index 99% rename from internal/task/worker.go rename to internal/scheduler/worker.go index a67ee945..9ce2f702 100644 --- a/internal/task/worker.go +++ b/internal/scheduler/worker.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/internal/task/worker_test.go b/internal/scheduler/worker_test.go similarity index 99% rename from internal/task/worker_test.go rename to internal/scheduler/worker_test.go index 29760a86..9b06d3b0 100644 --- a/internal/task/worker_test.go +++ b/internal/scheduler/worker_test.go @@ -1,4 +1,4 @@ -package task +package scheduler import ( "context" diff --git a/lybbrio b/lybbrio new file mode 100755 index 00000000..ce791d95 Binary files /dev/null and b/lybbrio differ