linstrom/storage-new/dbgen/gen.go

263 lines
8.5 KiB
Go

// 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 dbgen
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gen"
"gorm.io/plugin/dbresolver"
)
var (
Q = new(Query)
AccessToken *accessToken
Emote *emote
LoginProcessToken *loginProcessToken
MediaMetadata *mediaMetadata
Note *note
NoteTag *noteTag
NoteToAttachment *noteToAttachment
NoteToEmote *noteToEmote
NoteToPing *noteToPing
Reaction *reaction
RemoteServer *remoteServer
Role *role
User *user
UserAuthMethod *userAuthMethod
UserInfoField *userInfoField
UserRemoteLinks *userRemoteLinks
UserToBeing *userToBeing
UserToPronoun *userToPronoun
UserToRole *userToRole
UserToTag *userToTag
UserToUserRelation *userToUserRelation
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
AccessToken = &Q.AccessToken
Emote = &Q.Emote
LoginProcessToken = &Q.LoginProcessToken
MediaMetadata = &Q.MediaMetadata
Note = &Q.Note
NoteTag = &Q.NoteTag
NoteToAttachment = &Q.NoteToAttachment
NoteToEmote = &Q.NoteToEmote
NoteToPing = &Q.NoteToPing
Reaction = &Q.Reaction
RemoteServer = &Q.RemoteServer
Role = &Q.Role
User = &Q.User
UserAuthMethod = &Q.UserAuthMethod
UserInfoField = &Q.UserInfoField
UserRemoteLinks = &Q.UserRemoteLinks
UserToBeing = &Q.UserToBeing
UserToPronoun = &Q.UserToPronoun
UserToRole = &Q.UserToRole
UserToTag = &Q.UserToTag
UserToUserRelation = &Q.UserToUserRelation
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
AccessToken: newAccessToken(db, opts...),
Emote: newEmote(db, opts...),
LoginProcessToken: newLoginProcessToken(db, opts...),
MediaMetadata: newMediaMetadata(db, opts...),
Note: newNote(db, opts...),
NoteTag: newNoteTag(db, opts...),
NoteToAttachment: newNoteToAttachment(db, opts...),
NoteToEmote: newNoteToEmote(db, opts...),
NoteToPing: newNoteToPing(db, opts...),
Reaction: newReaction(db, opts...),
RemoteServer: newRemoteServer(db, opts...),
Role: newRole(db, opts...),
User: newUser(db, opts...),
UserAuthMethod: newUserAuthMethod(db, opts...),
UserInfoField: newUserInfoField(db, opts...),
UserRemoteLinks: newUserRemoteLinks(db, opts...),
UserToBeing: newUserToBeing(db, opts...),
UserToPronoun: newUserToPronoun(db, opts...),
UserToRole: newUserToRole(db, opts...),
UserToTag: newUserToTag(db, opts...),
UserToUserRelation: newUserToUserRelation(db, opts...),
}
}
type Query struct {
db *gorm.DB
AccessToken accessToken
Emote emote
LoginProcessToken loginProcessToken
MediaMetadata mediaMetadata
Note note
NoteTag noteTag
NoteToAttachment noteToAttachment
NoteToEmote noteToEmote
NoteToPing noteToPing
Reaction reaction
RemoteServer remoteServer
Role role
User user
UserAuthMethod userAuthMethod
UserInfoField userInfoField
UserRemoteLinks userRemoteLinks
UserToBeing userToBeing
UserToPronoun userToPronoun
UserToRole userToRole
UserToTag userToTag
UserToUserRelation userToUserRelation
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
AccessToken: q.AccessToken.clone(db),
Emote: q.Emote.clone(db),
LoginProcessToken: q.LoginProcessToken.clone(db),
MediaMetadata: q.MediaMetadata.clone(db),
Note: q.Note.clone(db),
NoteTag: q.NoteTag.clone(db),
NoteToAttachment: q.NoteToAttachment.clone(db),
NoteToEmote: q.NoteToEmote.clone(db),
NoteToPing: q.NoteToPing.clone(db),
Reaction: q.Reaction.clone(db),
RemoteServer: q.RemoteServer.clone(db),
Role: q.Role.clone(db),
User: q.User.clone(db),
UserAuthMethod: q.UserAuthMethod.clone(db),
UserInfoField: q.UserInfoField.clone(db),
UserRemoteLinks: q.UserRemoteLinks.clone(db),
UserToBeing: q.UserToBeing.clone(db),
UserToPronoun: q.UserToPronoun.clone(db),
UserToRole: q.UserToRole.clone(db),
UserToTag: q.UserToTag.clone(db),
UserToUserRelation: q.UserToUserRelation.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,
AccessToken: q.AccessToken.replaceDB(db),
Emote: q.Emote.replaceDB(db),
LoginProcessToken: q.LoginProcessToken.replaceDB(db),
MediaMetadata: q.MediaMetadata.replaceDB(db),
Note: q.Note.replaceDB(db),
NoteTag: q.NoteTag.replaceDB(db),
NoteToAttachment: q.NoteToAttachment.replaceDB(db),
NoteToEmote: q.NoteToEmote.replaceDB(db),
NoteToPing: q.NoteToPing.replaceDB(db),
Reaction: q.Reaction.replaceDB(db),
RemoteServer: q.RemoteServer.replaceDB(db),
Role: q.Role.replaceDB(db),
User: q.User.replaceDB(db),
UserAuthMethod: q.UserAuthMethod.replaceDB(db),
UserInfoField: q.UserInfoField.replaceDB(db),
UserRemoteLinks: q.UserRemoteLinks.replaceDB(db),
UserToBeing: q.UserToBeing.replaceDB(db),
UserToPronoun: q.UserToPronoun.replaceDB(db),
UserToRole: q.UserToRole.replaceDB(db),
UserToTag: q.UserToTag.replaceDB(db),
UserToUserRelation: q.UserToUserRelation.replaceDB(db),
}
}
type queryCtx struct {
AccessToken IAccessTokenDo
Emote IEmoteDo
LoginProcessToken ILoginProcessTokenDo
MediaMetadata IMediaMetadataDo
Note INoteDo
NoteTag INoteTagDo
NoteToAttachment INoteToAttachmentDo
NoteToEmote INoteToEmoteDo
NoteToPing INoteToPingDo
Reaction IReactionDo
RemoteServer IRemoteServerDo
Role IRoleDo
User IUserDo
UserAuthMethod IUserAuthMethodDo
UserInfoField IUserInfoFieldDo
UserRemoteLinks IUserRemoteLinksDo
UserToBeing IUserToBeingDo
UserToPronoun IUserToPronounDo
UserToRole IUserToRoleDo
UserToTag IUserToTagDo
UserToUserRelation IUserToUserRelationDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
AccessToken: q.AccessToken.WithContext(ctx),
Emote: q.Emote.WithContext(ctx),
LoginProcessToken: q.LoginProcessToken.WithContext(ctx),
MediaMetadata: q.MediaMetadata.WithContext(ctx),
Note: q.Note.WithContext(ctx),
NoteTag: q.NoteTag.WithContext(ctx),
NoteToAttachment: q.NoteToAttachment.WithContext(ctx),
NoteToEmote: q.NoteToEmote.WithContext(ctx),
NoteToPing: q.NoteToPing.WithContext(ctx),
Reaction: q.Reaction.WithContext(ctx),
RemoteServer: q.RemoteServer.WithContext(ctx),
Role: q.Role.WithContext(ctx),
User: q.User.WithContext(ctx),
UserAuthMethod: q.UserAuthMethod.WithContext(ctx),
UserInfoField: q.UserInfoField.WithContext(ctx),
UserRemoteLinks: q.UserRemoteLinks.WithContext(ctx),
UserToBeing: q.UserToBeing.WithContext(ctx),
UserToPronoun: q.UserToPronoun.WithContext(ctx),
UserToRole: q.UserToRole.WithContext(ctx),
UserToTag: q.UserToTag.WithContext(ctx),
UserToUserRelation: q.UserToUserRelation.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
}