gen.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package query
  5. import (
  6. "context"
  7. "database/sql"
  8. "gorm.io/gorm"
  9. "gorm.io/gen"
  10. "gorm.io/plugin/dbresolver"
  11. )
  12. var (
  13. Q = new(Query)
  14. AcmeUser *acmeUser
  15. AuthToken *authToken
  16. AutoBackup *autoBackup
  17. BanIP *banIP
  18. Cert *cert
  19. Config *config
  20. ConfigBackup *configBackup
  21. DnsCredential *dnsCredential
  22. ExternalNotify *externalNotify
  23. LLMSession *lLMSession
  24. Namespace *namespace
  25. NginxLogIndex *nginxLogIndex
  26. Node *node
  27. Notification *notification
  28. Passkey *passkey
  29. Site *site
  30. SiteConfig *siteConfig
  31. Stream *stream
  32. User *user
  33. )
  34. func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
  35. *Q = *Use(db, opts...)
  36. AcmeUser = &Q.AcmeUser
  37. AuthToken = &Q.AuthToken
  38. AutoBackup = &Q.AutoBackup
  39. BanIP = &Q.BanIP
  40. Cert = &Q.Cert
  41. Config = &Q.Config
  42. ConfigBackup = &Q.ConfigBackup
  43. DnsCredential = &Q.DnsCredential
  44. ExternalNotify = &Q.ExternalNotify
  45. LLMSession = &Q.LLMSession
  46. Namespace = &Q.Namespace
  47. NginxLogIndex = &Q.NginxLogIndex
  48. Node = &Q.Node
  49. Notification = &Q.Notification
  50. Passkey = &Q.Passkey
  51. Site = &Q.Site
  52. SiteConfig = &Q.SiteConfig
  53. Stream = &Q.Stream
  54. User = &Q.User
  55. }
  56. func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
  57. return &Query{
  58. db: db,
  59. AcmeUser: newAcmeUser(db, opts...),
  60. AuthToken: newAuthToken(db, opts...),
  61. AutoBackup: newAutoBackup(db, opts...),
  62. BanIP: newBanIP(db, opts...),
  63. Cert: newCert(db, opts...),
  64. Config: newConfig(db, opts...),
  65. ConfigBackup: newConfigBackup(db, opts...),
  66. DnsCredential: newDnsCredential(db, opts...),
  67. ExternalNotify: newExternalNotify(db, opts...),
  68. LLMSession: newLLMSession(db, opts...),
  69. Namespace: newNamespace(db, opts...),
  70. NginxLogIndex: newNginxLogIndex(db, opts...),
  71. Node: newNode(db, opts...),
  72. Notification: newNotification(db, opts...),
  73. Passkey: newPasskey(db, opts...),
  74. Site: newSite(db, opts...),
  75. SiteConfig: newSiteConfig(db, opts...),
  76. Stream: newStream(db, opts...),
  77. User: newUser(db, opts...),
  78. }
  79. }
  80. type Query struct {
  81. db *gorm.DB
  82. AcmeUser acmeUser
  83. AuthToken authToken
  84. AutoBackup autoBackup
  85. BanIP banIP
  86. Cert cert
  87. Config config
  88. ConfigBackup configBackup
  89. DnsCredential dnsCredential
  90. ExternalNotify externalNotify
  91. LLMSession lLMSession
  92. Namespace namespace
  93. NginxLogIndex nginxLogIndex
  94. Node node
  95. Notification notification
  96. Passkey passkey
  97. Site site
  98. SiteConfig siteConfig
  99. Stream stream
  100. User user
  101. }
  102. func (q *Query) Available() bool { return q.db != nil }
  103. func (q *Query) clone(db *gorm.DB) *Query {
  104. return &Query{
  105. db: db,
  106. AcmeUser: q.AcmeUser.clone(db),
  107. AuthToken: q.AuthToken.clone(db),
  108. AutoBackup: q.AutoBackup.clone(db),
  109. BanIP: q.BanIP.clone(db),
  110. Cert: q.Cert.clone(db),
  111. Config: q.Config.clone(db),
  112. ConfigBackup: q.ConfigBackup.clone(db),
  113. DnsCredential: q.DnsCredential.clone(db),
  114. ExternalNotify: q.ExternalNotify.clone(db),
  115. LLMSession: q.LLMSession.clone(db),
  116. Namespace: q.Namespace.clone(db),
  117. NginxLogIndex: q.NginxLogIndex.clone(db),
  118. Node: q.Node.clone(db),
  119. Notification: q.Notification.clone(db),
  120. Passkey: q.Passkey.clone(db),
  121. Site: q.Site.clone(db),
  122. SiteConfig: q.SiteConfig.clone(db),
  123. Stream: q.Stream.clone(db),
  124. User: q.User.clone(db),
  125. }
  126. }
  127. func (q *Query) ReadDB() *Query {
  128. return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
  129. }
  130. func (q *Query) WriteDB() *Query {
  131. return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
  132. }
  133. func (q *Query) ReplaceDB(db *gorm.DB) *Query {
  134. return &Query{
  135. db: db,
  136. AcmeUser: q.AcmeUser.replaceDB(db),
  137. AuthToken: q.AuthToken.replaceDB(db),
  138. AutoBackup: q.AutoBackup.replaceDB(db),
  139. BanIP: q.BanIP.replaceDB(db),
  140. Cert: q.Cert.replaceDB(db),
  141. Config: q.Config.replaceDB(db),
  142. ConfigBackup: q.ConfigBackup.replaceDB(db),
  143. DnsCredential: q.DnsCredential.replaceDB(db),
  144. ExternalNotify: q.ExternalNotify.replaceDB(db),
  145. LLMSession: q.LLMSession.replaceDB(db),
  146. Namespace: q.Namespace.replaceDB(db),
  147. NginxLogIndex: q.NginxLogIndex.replaceDB(db),
  148. Node: q.Node.replaceDB(db),
  149. Notification: q.Notification.replaceDB(db),
  150. Passkey: q.Passkey.replaceDB(db),
  151. Site: q.Site.replaceDB(db),
  152. SiteConfig: q.SiteConfig.replaceDB(db),
  153. Stream: q.Stream.replaceDB(db),
  154. User: q.User.replaceDB(db),
  155. }
  156. }
  157. type queryCtx struct {
  158. AcmeUser *acmeUserDo
  159. AuthToken *authTokenDo
  160. AutoBackup *autoBackupDo
  161. BanIP *banIPDo
  162. Cert *certDo
  163. Config *configDo
  164. ConfigBackup *configBackupDo
  165. DnsCredential *dnsCredentialDo
  166. ExternalNotify *externalNotifyDo
  167. LLMSession *lLMSessionDo
  168. Namespace *namespaceDo
  169. NginxLogIndex *nginxLogIndexDo
  170. Node *nodeDo
  171. Notification *notificationDo
  172. Passkey *passkeyDo
  173. Site *siteDo
  174. SiteConfig *siteConfigDo
  175. Stream *streamDo
  176. User *userDo
  177. }
  178. func (q *Query) WithContext(ctx context.Context) *queryCtx {
  179. return &queryCtx{
  180. AcmeUser: q.AcmeUser.WithContext(ctx),
  181. AuthToken: q.AuthToken.WithContext(ctx),
  182. AutoBackup: q.AutoBackup.WithContext(ctx),
  183. BanIP: q.BanIP.WithContext(ctx),
  184. Cert: q.Cert.WithContext(ctx),
  185. Config: q.Config.WithContext(ctx),
  186. ConfigBackup: q.ConfigBackup.WithContext(ctx),
  187. DnsCredential: q.DnsCredential.WithContext(ctx),
  188. ExternalNotify: q.ExternalNotify.WithContext(ctx),
  189. LLMSession: q.LLMSession.WithContext(ctx),
  190. Namespace: q.Namespace.WithContext(ctx),
  191. NginxLogIndex: q.NginxLogIndex.WithContext(ctx),
  192. Node: q.Node.WithContext(ctx),
  193. Notification: q.Notification.WithContext(ctx),
  194. Passkey: q.Passkey.WithContext(ctx),
  195. Site: q.Site.WithContext(ctx),
  196. SiteConfig: q.SiteConfig.WithContext(ctx),
  197. Stream: q.Stream.WithContext(ctx),
  198. User: q.User.WithContext(ctx),
  199. }
  200. }
  201. func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
  202. return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
  203. }
  204. func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
  205. tx := q.db.Begin(opts...)
  206. return &QueryTx{Query: q.clone(tx), Error: tx.Error}
  207. }
  208. type QueryTx struct {
  209. *Query
  210. Error error
  211. }
  212. func (q *QueryTx) Commit() error {
  213. return q.db.Commit().Error
  214. }
  215. func (q *QueryTx) Rollback() error {
  216. return q.db.Rollback().Error
  217. }
  218. func (q *QueryTx) SavePoint(name string) error {
  219. return q.db.SavePoint(name).Error
  220. }
  221. func (q *QueryTx) RollbackTo(name string) error {
  222. return q.db.RollbackTo(name).Error
  223. }