128 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			128 lines
		
	
	
		
			3.4 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 query
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"database/sql"
 | 
						|
 | 
						|
	"gorm.io/gorm"
 | 
						|
 | 
						|
	"gorm.io/gen"
 | 
						|
 | 
						|
	"gorm.io/plugin/dbresolver"
 | 
						|
)
 | 
						|
 | 
						|
var (
 | 
						|
	Q                       = new(Query)
 | 
						|
	Knowledge               *knowledge
 | 
						|
	KnowledgeDocument       *knowledgeDocument
 | 
						|
	KnowledgeDocumentReview *knowledgeDocumentReview
 | 
						|
	KnowledgeDocumentSlice  *knowledgeDocumentSlice
 | 
						|
)
 | 
						|
 | 
						|
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
 | 
						|
	*Q = *Use(db, opts...)
 | 
						|
	Knowledge = &Q.Knowledge
 | 
						|
	KnowledgeDocument = &Q.KnowledgeDocument
 | 
						|
	KnowledgeDocumentReview = &Q.KnowledgeDocumentReview
 | 
						|
	KnowledgeDocumentSlice = &Q.KnowledgeDocumentSlice
 | 
						|
}
 | 
						|
 | 
						|
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
 | 
						|
	return &Query{
 | 
						|
		db:                      db,
 | 
						|
		Knowledge:               newKnowledge(db, opts...),
 | 
						|
		KnowledgeDocument:       newKnowledgeDocument(db, opts...),
 | 
						|
		KnowledgeDocumentReview: newKnowledgeDocumentReview(db, opts...),
 | 
						|
		KnowledgeDocumentSlice:  newKnowledgeDocumentSlice(db, opts...),
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
type Query struct {
 | 
						|
	db *gorm.DB
 | 
						|
 | 
						|
	Knowledge               knowledge
 | 
						|
	KnowledgeDocument       knowledgeDocument
 | 
						|
	KnowledgeDocumentReview knowledgeDocumentReview
 | 
						|
	KnowledgeDocumentSlice  knowledgeDocumentSlice
 | 
						|
}
 | 
						|
 | 
						|
func (q *Query) Available() bool { return q.db != nil }
 | 
						|
 | 
						|
func (q *Query) clone(db *gorm.DB) *Query {
 | 
						|
	return &Query{
 | 
						|
		db:                      db,
 | 
						|
		Knowledge:               q.Knowledge.clone(db),
 | 
						|
		KnowledgeDocument:       q.KnowledgeDocument.clone(db),
 | 
						|
		KnowledgeDocumentReview: q.KnowledgeDocumentReview.clone(db),
 | 
						|
		KnowledgeDocumentSlice:  q.KnowledgeDocumentSlice.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,
 | 
						|
		Knowledge:               q.Knowledge.replaceDB(db),
 | 
						|
		KnowledgeDocument:       q.KnowledgeDocument.replaceDB(db),
 | 
						|
		KnowledgeDocumentReview: q.KnowledgeDocumentReview.replaceDB(db),
 | 
						|
		KnowledgeDocumentSlice:  q.KnowledgeDocumentSlice.replaceDB(db),
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
type queryCtx struct {
 | 
						|
	Knowledge               IKnowledgeDo
 | 
						|
	KnowledgeDocument       IKnowledgeDocumentDo
 | 
						|
	KnowledgeDocumentReview IKnowledgeDocumentReviewDo
 | 
						|
	KnowledgeDocumentSlice  IKnowledgeDocumentSliceDo
 | 
						|
}
 | 
						|
 | 
						|
func (q *Query) WithContext(ctx context.Context) *queryCtx {
 | 
						|
	return &queryCtx{
 | 
						|
		Knowledge:               q.Knowledge.WithContext(ctx),
 | 
						|
		KnowledgeDocument:       q.KnowledgeDocument.WithContext(ctx),
 | 
						|
		KnowledgeDocumentReview: q.KnowledgeDocumentReview.WithContext(ctx),
 | 
						|
		KnowledgeDocumentSlice:  q.KnowledgeDocumentSlice.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
 | 
						|
}
 |