// 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 query import ( "context" "database/sql" "gorm.io/gorm" "gorm.io/gen" "gorm.io/plugin/dbresolver" ) var ( Q = new(Query) AcmeUser *acmeUser Auth *auth AuthToken *authToken Cert *cert ChatGPTLog *chatGPTLog ConfigBackup *configBackup DnsCredential *dnsCredential Environment *environment Notification *notification Site *site Stream *stream ) func SetDefault(db *gorm.DB, opts ...gen.DOOption) { *Q = *Use(db, opts...) AcmeUser = &Q.AcmeUser Auth = &Q.Auth AuthToken = &Q.AuthToken Cert = &Q.Cert ChatGPTLog = &Q.ChatGPTLog ConfigBackup = &Q.ConfigBackup DnsCredential = &Q.DnsCredential Environment = &Q.Environment Notification = &Q.Notification Site = &Q.Site Stream = &Q.Stream } func Use(db *gorm.DB, opts ...gen.DOOption) *Query { return &Query{ db: db, AcmeUser: newAcmeUser(db, opts...), Auth: newAuth(db, opts...), AuthToken: newAuthToken(db, opts...), Cert: newCert(db, opts...), ChatGPTLog: newChatGPTLog(db, opts...), ConfigBackup: newConfigBackup(db, opts...), DnsCredential: newDnsCredential(db, opts...), Environment: newEnvironment(db, opts...), Notification: newNotification(db, opts...), Site: newSite(db, opts...), Stream: newStream(db, opts...), } } type Query struct { db *gorm.DB AcmeUser acmeUser Auth auth AuthToken authToken Cert cert ChatGPTLog chatGPTLog ConfigBackup configBackup DnsCredential dnsCredential Environment environment Notification notification Site site Stream stream } func (q *Query) Available() bool { return q.db != nil } func (q *Query) clone(db *gorm.DB) *Query { return &Query{ db: db, AcmeUser: q.AcmeUser.clone(db), Auth: q.Auth.clone(db), AuthToken: q.AuthToken.clone(db), Cert: q.Cert.clone(db), ChatGPTLog: q.ChatGPTLog.clone(db), ConfigBackup: q.ConfigBackup.clone(db), DnsCredential: q.DnsCredential.clone(db), Environment: q.Environment.clone(db), Notification: q.Notification.clone(db), Site: q.Site.clone(db), Stream: q.Stream.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, AcmeUser: q.AcmeUser.replaceDB(db), Auth: q.Auth.replaceDB(db), AuthToken: q.AuthToken.replaceDB(db), Cert: q.Cert.replaceDB(db), ChatGPTLog: q.ChatGPTLog.replaceDB(db), ConfigBackup: q.ConfigBackup.replaceDB(db), DnsCredential: q.DnsCredential.replaceDB(db), Environment: q.Environment.replaceDB(db), Notification: q.Notification.replaceDB(db), Site: q.Site.replaceDB(db), Stream: q.Stream.replaceDB(db), } } type queryCtx struct { AcmeUser *acmeUserDo Auth *authDo AuthToken *authTokenDo Cert *certDo ChatGPTLog *chatGPTLogDo ConfigBackup *configBackupDo DnsCredential *dnsCredentialDo Environment *environmentDo Notification *notificationDo Site *siteDo Stream *streamDo } func (q *Query) WithContext(ctx context.Context) *queryCtx { return &queryCtx{ AcmeUser: q.AcmeUser.WithContext(ctx), Auth: q.Auth.WithContext(ctx), AuthToken: q.AuthToken.WithContext(ctx), Cert: q.Cert.WithContext(ctx), ChatGPTLog: q.ChatGPTLog.WithContext(ctx), ConfigBackup: q.ConfigBackup.WithContext(ctx), DnsCredential: q.DnsCredential.WithContext(ctx), Environment: q.Environment.WithContext(ctx), Notification: q.Notification.WithContext(ctx), Site: q.Site.WithContext(ctx), Stream: q.Stream.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 }