// Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. package dal import ( "context" "database/sql" "gorm.io/gen" "gorm.io/gorm" "gorm.io/plugin/dbresolver" ) var ( Q = new(Query) Attachment *attachment Category *category Comment *comment CommentBlack *commentBlack FlywaySchemaHistory *flywaySchemaHistory Journal *journal Link *link Log *log Menu *menu Meta *meta Option *option Photo *photo Post *post PostCategory *postCategory PostTag *postTag Tag *tag ThemeSetting *themeSetting User *user ) func SetDefault(db *gorm.DB, opts ...gen.DOOption) { *Q = *Use(db, opts...) Attachment = &Q.Attachment Category = &Q.Category Comment = &Q.Comment CommentBlack = &Q.CommentBlack FlywaySchemaHistory = &Q.FlywaySchemaHistory Journal = &Q.Journal Link = &Q.Link Log = &Q.Log Menu = &Q.Menu Meta = &Q.Meta Option = &Q.Option Photo = &Q.Photo Post = &Q.Post PostCategory = &Q.PostCategory PostTag = &Q.PostTag Tag = &Q.Tag ThemeSetting = &Q.ThemeSetting User = &Q.User } func Use(db *gorm.DB, opts ...gen.DOOption) *Query { return &Query{ db: db, Attachment: newAttachment(db, opts...), Category: newCategory(db, opts...), Comment: newComment(db, opts...), CommentBlack: newCommentBlack(db, opts...), FlywaySchemaHistory: newFlywaySchemaHistory(db, opts...), Journal: newJournal(db, opts...), Link: newLink(db, opts...), Log: newLog(db, opts...), Menu: newMenu(db, opts...), Meta: newMeta(db, opts...), Option: newOption(db, opts...), Photo: newPhoto(db, opts...), Post: newPost(db, opts...), PostCategory: newPostCategory(db, opts...), PostTag: newPostTag(db, opts...), Tag: newTag(db, opts...), ThemeSetting: newThemeSetting(db, opts...), User: newUser(db, opts...), } } type Query struct { db *gorm.DB Attachment attachment Category category Comment comment CommentBlack commentBlack FlywaySchemaHistory flywaySchemaHistory Journal journal Link link Log log Menu menu Meta meta Option option Photo photo Post post PostCategory postCategory PostTag postTag Tag tag ThemeSetting themeSetting User user } func (q *Query) Available() bool { return q.db != nil } func (q *Query) clone(db *gorm.DB) *Query { return &Query{ db: db, Attachment: q.Attachment.clone(db), Category: q.Category.clone(db), Comment: q.Comment.clone(db), CommentBlack: q.CommentBlack.clone(db), FlywaySchemaHistory: q.FlywaySchemaHistory.clone(db), Journal: q.Journal.clone(db), Link: q.Link.clone(db), Log: q.Log.clone(db), Menu: q.Menu.clone(db), Meta: q.Meta.clone(db), Option: q.Option.clone(db), Photo: q.Photo.clone(db), Post: q.Post.clone(db), PostCategory: q.PostCategory.clone(db), PostTag: q.PostTag.clone(db), Tag: q.Tag.clone(db), ThemeSetting: q.ThemeSetting.clone(db), User: q.User.clone(db), } } func (q *Query) ReadDB() *Query { return q.ReplaceDB(q.db.Clauses(dbresolver.Read)) } func (q *Query) WriteDB() *Query { return q.ReplaceDB(q.db.Clauses(dbresolver.Write)) } func (q *Query) ReplaceDB(db *gorm.DB) *Query { return &Query{ db: db, Attachment: q.Attachment.replaceDB(db), Category: q.Category.replaceDB(db), Comment: q.Comment.replaceDB(db), CommentBlack: q.CommentBlack.replaceDB(db), FlywaySchemaHistory: q.FlywaySchemaHistory.replaceDB(db), Journal: q.Journal.replaceDB(db), Link: q.Link.replaceDB(db), Log: q.Log.replaceDB(db), Menu: q.Menu.replaceDB(db), Meta: q.Meta.replaceDB(db), Option: q.Option.replaceDB(db), Photo: q.Photo.replaceDB(db), Post: q.Post.replaceDB(db), PostCategory: q.PostCategory.replaceDB(db), PostTag: q.PostTag.replaceDB(db), Tag: q.Tag.replaceDB(db), ThemeSetting: q.ThemeSetting.replaceDB(db), User: q.User.replaceDB(db), } } type queryCtx struct { Attachment *attachmentDo Category *categoryDo Comment *commentDo CommentBlack *commentBlackDo FlywaySchemaHistory *flywaySchemaHistoryDo Journal *journalDo Link *linkDo Log *logDo Menu *menuDo Meta *metaDo Option *optionDo Photo *photoDo Post *postDo PostCategory *postCategoryDo PostTag *postTagDo Tag *tagDo ThemeSetting *themeSettingDo User *userDo } func (q *Query) WithContext(ctx context.Context) *queryCtx { return &queryCtx{ Attachment: q.Attachment.WithContext(ctx), Category: q.Category.WithContext(ctx), Comment: q.Comment.WithContext(ctx), CommentBlack: q.CommentBlack.WithContext(ctx), FlywaySchemaHistory: q.FlywaySchemaHistory.WithContext(ctx), Journal: q.Journal.WithContext(ctx), Link: q.Link.WithContext(ctx), Log: q.Log.WithContext(ctx), Menu: q.Menu.WithContext(ctx), Meta: q.Meta.WithContext(ctx), Option: q.Option.WithContext(ctx), Photo: q.Photo.WithContext(ctx), Post: q.Post.WithContext(ctx), PostCategory: q.PostCategory.WithContext(ctx), PostTag: q.PostTag.WithContext(ctx), Tag: q.Tag.WithContext(ctx), ThemeSetting: q.ThemeSetting.WithContext(ctx), User: q.User.WithContext(ctx), } } func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error { return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...) } func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx { tx := q.db.Begin(opts...) return &QueryTx{Query: q.clone(tx), Error: tx.Error} } type QueryTx struct { *Query Error error } func (q *QueryTx) Commit() error { return q.db.Commit().Error } func (q *QueryTx) Rollback() error { return q.db.Rollback().Error } func (q *QueryTx) SavePoint(name string) error { return q.db.SavePoint(name).Error } func (q *QueryTx) RollbackTo(name string) error { return q.db.RollbackTo(name).Error }