@ -16,29 +16,31 @@ import (
)
var (
Q = new ( Query )
Attachment * attachment
Category * category
Comment * comment
CommentBlack * commentBlack
Journal * journal
Link * link
Log * log
Menu * menu
Meta * meta
Option * option
Photo * photo
Post * post
PostCategory * postCategory
PostTag * postTag
ScrapPage * scrapPage
Tag * tag
ThemeSetting * themeSetting
User * user
Q = new ( Query )
ApplicationPassword * applicationPassword
Attachment * attachment
Category * category
Comment * comment
CommentBlack * commentBlack
Journal * journal
Link * link
Log * log
Menu * menu
Meta * meta
Option * option
Photo * photo
Post * post
PostCategory * postCategory
PostTag * postTag
ScrapPage * scrapPage
Tag * tag
ThemeSetting * themeSetting
User * user
)
func SetDefault ( db * gorm . DB , opts ... gen . DOOption ) {
* Q = * Use ( db , opts ... )
ApplicationPassword = & Q . ApplicationPassword
Attachment = & Q . Attachment
Category = & Q . Category
Comment = & Q . Comment
@ -61,74 +63,77 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
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 ... ) ,
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 ... ) ,
ScrapPage : newScrapPage ( db , opts ... ) ,
Tag : newTag ( db , opts ... ) ,
ThemeSetting : newThemeSetting ( db , opts ... ) ,
User : newUser ( db , opts ... ) ,
db : db ,
ApplicationPassword : newApplicationPassword ( db , opts ... ) ,
Attachment : newAttachment ( db , opts ... ) ,
Category : newCategory ( db , opts ... ) ,
Comment : newComment ( db , opts ... ) ,
CommentBlack : newCommentBlack ( 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 ... ) ,
ScrapPage : newScrapPage ( 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
Journal journal
Link link
Log log
Menu menu
Meta meta
Option option
Photo photo
Post post
PostCategory postCategory
PostTag postTag
ScrapPage scrapPage
Tag tag
ThemeSetting themeSetting
User user
ApplicationPassword applicationPassword
Attachment attachment
Category category
Comment comment
CommentBlack commentBlack
Journal journal
Link link
Log log
Menu menu
Meta meta
Option option
Photo photo
Post post
PostCategory postCategory
PostTag postTag
ScrapPage scrapPage
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 ) ,
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 ) ,
ScrapPage : q . ScrapPage . clone ( db ) ,
Tag : q . Tag . clone ( db ) ,
ThemeSetting : q . ThemeSetting . clone ( db ) ,
User : q . User . clone ( db ) ,
db : db ,
ApplicationPassword : q . ApplicationPassword . clone ( db ) ,
Attachment : q . Attachment . clone ( db ) ,
Category : q . Category . clone ( db ) ,
Comment : q . Comment . clone ( db ) ,
CommentBlack : q . CommentBlack . 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 ) ,
ScrapPage : q . ScrapPage . clone ( db ) ,
Tag : q . Tag . clone ( db ) ,
ThemeSetting : q . ThemeSetting . clone ( db ) ,
User : q . User . clone ( db ) ,
}
}
@ -142,69 +147,72 @@ func (q *Query) WriteDB() *Query {
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 ) ,
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 ) ,
ScrapPage : q . ScrapPage . replaceDB ( db ) ,
Tag : q . Tag . replaceDB ( db ) ,
ThemeSetting : q . ThemeSetting . replaceDB ( db ) ,
User : q . User . replaceDB ( db ) ,
db : db ,
ApplicationPassword : q . ApplicationPassword . replaceDB ( db ) ,
Attachment : q . Attachment . replaceDB ( db ) ,
Category : q . Category . replaceDB ( db ) ,
Comment : q . Comment . replaceDB ( db ) ,
CommentBlack : q . CommentBlack . 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 ) ,
ScrapPage : q . ScrapPage . 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
Journal * journalDo
Link * linkDo
Log * logDo
Menu * menuDo
Meta * metaDo
Option * optionDo
Photo * photoDo
Post * postDo
PostCategory * postCategoryDo
PostTag * postTagDo
ScrapPage * scrapPageDo
Tag * tagDo
ThemeSetting * themeSettingDo
User * userDo
ApplicationPassword * applicationPasswordDo
Attachment * attachmentDo
Category * categoryDo
Comment * commentDo
CommentBlack * commentBlackDo
Journal * journalDo
Link * linkDo
Log * logDo
Menu * menuDo
Meta * metaDo
Option * optionDo
Photo * photoDo
Post * postDo
PostCategory * postCategoryDo
PostTag * postTagDo
ScrapPage * scrapPageDo
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 ) ,
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 ) ,
ScrapPage : q . ScrapPage . WithContext ( ctx ) ,
Tag : q . Tag . WithContext ( ctx ) ,
ThemeSetting : q . ThemeSetting . WithContext ( ctx ) ,
User : q . User . WithContext ( ctx ) ,
ApplicationPassword : q . ApplicationPassword . WithContext ( ctx ) ,
Attachment : q . Attachment . WithContext ( ctx ) ,
Category : q . Category . WithContext ( ctx ) ,
Comment : q . Comment . WithContext ( ctx ) ,
CommentBlack : q . CommentBlack . 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 ) ,
ScrapPage : q . ScrapPage . WithContext ( ctx ) ,
Tag : q . Tag . WithContext ( ctx ) ,
ThemeSetting : q . ThemeSetting . WithContext ( ctx ) ,
User : q . User . WithContext ( ctx ) ,
}
}