Files
yokowu 34320f9ed5 feat(phase6): 添加 gitbot/gittask 实体 schema 和 migration
- 新增 git_bots, git_bot_users, git_bot_tasks, project_git_bots 表
- 添加 user, host, project 到 gitbot 的关联边
- 使用 soft delete 和 created_at 游标
2026-03-19 18:14:53 +08:00

1080 lines
42 KiB
Go

// Code generated by ent, DO NOT EDIT.
package intercept
import (
"context"
"fmt"
"entgo.io/ent/dialect/sql"
"github.com/chaitin/MonkeyCode/backend/db"
"github.com/chaitin/MonkeyCode/backend/db/audit"
"github.com/chaitin/MonkeyCode/backend/db/gitbot"
"github.com/chaitin/MonkeyCode/backend/db/gitbottask"
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
"github.com/chaitin/MonkeyCode/backend/db/host"
"github.com/chaitin/MonkeyCode/backend/db/image"
"github.com/chaitin/MonkeyCode/backend/db/model"
"github.com/chaitin/MonkeyCode/backend/db/notifychannel"
"github.com/chaitin/MonkeyCode/backend/db/notifysendlog"
"github.com/chaitin/MonkeyCode/backend/db/notifysubscription"
"github.com/chaitin/MonkeyCode/backend/db/predicate"
"github.com/chaitin/MonkeyCode/backend/db/project"
"github.com/chaitin/MonkeyCode/backend/db/projectcollaborator"
"github.com/chaitin/MonkeyCode/backend/db/projectgitbot"
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
"github.com/chaitin/MonkeyCode/backend/db/task"
"github.com/chaitin/MonkeyCode/backend/db/taskvirtualmachine"
"github.com/chaitin/MonkeyCode/backend/db/team"
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
"github.com/chaitin/MonkeyCode/backend/db/teamgrouphost"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupimage"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupmember"
"github.com/chaitin/MonkeyCode/backend/db/teamgroupmodel"
"github.com/chaitin/MonkeyCode/backend/db/teamhost"
"github.com/chaitin/MonkeyCode/backend/db/teamimage"
"github.com/chaitin/MonkeyCode/backend/db/teammember"
"github.com/chaitin/MonkeyCode/backend/db/teammodel"
"github.com/chaitin/MonkeyCode/backend/db/user"
"github.com/chaitin/MonkeyCode/backend/db/useridentity"
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
)
// The Query interface represents an operation that queries a graph.
// By using this interface, users can write generic code that manipulates
// query builders of different types.
type Query interface {
// Type returns the string representation of the query type.
Type() string
// Limit the number of records to be returned by this query.
Limit(int)
// Offset to start from.
Offset(int)
// Unique configures the query builder to filter duplicate records.
Unique(bool)
// Order specifies how the records should be ordered.
Order(...func(*sql.Selector))
// WhereP appends storage-level predicates to the query builder. Using this method, users
// can use type-assertion to append predicates that do not depend on any generated package.
WhereP(...func(*sql.Selector))
}
// The Func type is an adapter that allows ordinary functions to be used as interceptors.
// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
type Func func(context.Context, Query) error
// Intercept calls f(ctx, q) and then applied the next Querier.
func (f Func) Intercept(next db.Querier) db.Querier {
return db.QuerierFunc(func(ctx context.Context, q db.Query) (db.Value, error) {
query, err := NewQuery(q)
if err != nil {
return nil, err
}
if err := f(ctx, query); err != nil {
return nil, err
}
return next.Query(ctx, q)
})
}
// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
type TraverseFunc func(context.Context, Query) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseFunc) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseFunc) Traverse(ctx context.Context, q db.Query) error {
query, err := NewQuery(q)
if err != nil {
return err
}
return f(ctx, query)
}
// The AuditFunc type is an adapter to allow the use of ordinary function as a Querier.
type AuditFunc func(context.Context, *db.AuditQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f AuditFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.AuditQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.AuditQuery", q)
}
// The TraverseAudit type is an adapter to allow the use of ordinary function as Traverser.
type TraverseAudit func(context.Context, *db.AuditQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseAudit) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseAudit) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.AuditQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.AuditQuery", q)
}
// The GitBotFunc type is an adapter to allow the use of ordinary function as a Querier.
type GitBotFunc func(context.Context, *db.GitBotQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f GitBotFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.GitBotQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.GitBotQuery", q)
}
// The TraverseGitBot type is an adapter to allow the use of ordinary function as Traverser.
type TraverseGitBot func(context.Context, *db.GitBotQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseGitBot) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseGitBot) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.GitBotQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.GitBotQuery", q)
}
// The GitBotTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type GitBotTaskFunc func(context.Context, *db.GitBotTaskQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f GitBotTaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.GitBotTaskQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.GitBotTaskQuery", q)
}
// The TraverseGitBotTask type is an adapter to allow the use of ordinary function as Traverser.
type TraverseGitBotTask func(context.Context, *db.GitBotTaskQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseGitBotTask) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseGitBotTask) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.GitBotTaskQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.GitBotTaskQuery", q)
}
// The GitBotUserFunc type is an adapter to allow the use of ordinary function as a Querier.
type GitBotUserFunc func(context.Context, *db.GitBotUserQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f GitBotUserFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.GitBotUserQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.GitBotUserQuery", q)
}
// The TraverseGitBotUser type is an adapter to allow the use of ordinary function as Traverser.
type TraverseGitBotUser func(context.Context, *db.GitBotUserQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseGitBotUser) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseGitBotUser) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.GitBotUserQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.GitBotUserQuery", q)
}
// The GitIdentityFunc type is an adapter to allow the use of ordinary function as a Querier.
type GitIdentityFunc func(context.Context, *db.GitIdentityQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f GitIdentityFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.GitIdentityQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.GitIdentityQuery", q)
}
// The TraverseGitIdentity type is an adapter to allow the use of ordinary function as Traverser.
type TraverseGitIdentity func(context.Context, *db.GitIdentityQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseGitIdentity) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseGitIdentity) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.GitIdentityQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.GitIdentityQuery", q)
}
// The HostFunc type is an adapter to allow the use of ordinary function as a Querier.
type HostFunc func(context.Context, *db.HostQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f HostFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.HostQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.HostQuery", q)
}
// The TraverseHost type is an adapter to allow the use of ordinary function as Traverser.
type TraverseHost func(context.Context, *db.HostQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseHost) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseHost) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.HostQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.HostQuery", q)
}
// The ImageFunc type is an adapter to allow the use of ordinary function as a Querier.
type ImageFunc func(context.Context, *db.ImageQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ImageFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ImageQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ImageQuery", q)
}
// The TraverseImage type is an adapter to allow the use of ordinary function as Traverser.
type TraverseImage func(context.Context, *db.ImageQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseImage) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseImage) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ImageQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ImageQuery", q)
}
// The ModelFunc type is an adapter to allow the use of ordinary function as a Querier.
type ModelFunc func(context.Context, *db.ModelQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ModelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ModelQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ModelQuery", q)
}
// The TraverseModel type is an adapter to allow the use of ordinary function as Traverser.
type TraverseModel func(context.Context, *db.ModelQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseModel) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseModel) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ModelQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ModelQuery", q)
}
// The NotifyChannelFunc type is an adapter to allow the use of ordinary function as a Querier.
type NotifyChannelFunc func(context.Context, *db.NotifyChannelQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f NotifyChannelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.NotifyChannelQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.NotifyChannelQuery", q)
}
// The TraverseNotifyChannel type is an adapter to allow the use of ordinary function as Traverser.
type TraverseNotifyChannel func(context.Context, *db.NotifyChannelQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseNotifyChannel) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseNotifyChannel) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.NotifyChannelQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.NotifyChannelQuery", q)
}
// The NotifySendLogFunc type is an adapter to allow the use of ordinary function as a Querier.
type NotifySendLogFunc func(context.Context, *db.NotifySendLogQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f NotifySendLogFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.NotifySendLogQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.NotifySendLogQuery", q)
}
// The TraverseNotifySendLog type is an adapter to allow the use of ordinary function as Traverser.
type TraverseNotifySendLog func(context.Context, *db.NotifySendLogQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseNotifySendLog) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseNotifySendLog) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.NotifySendLogQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.NotifySendLogQuery", q)
}
// The NotifySubscriptionFunc type is an adapter to allow the use of ordinary function as a Querier.
type NotifySubscriptionFunc func(context.Context, *db.NotifySubscriptionQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f NotifySubscriptionFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.NotifySubscriptionQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.NotifySubscriptionQuery", q)
}
// The TraverseNotifySubscription type is an adapter to allow the use of ordinary function as Traverser.
type TraverseNotifySubscription func(context.Context, *db.NotifySubscriptionQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseNotifySubscription) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseNotifySubscription) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.NotifySubscriptionQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.NotifySubscriptionQuery", q)
}
// The ProjectFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectFunc func(context.Context, *db.ProjectQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectQuery", q)
}
// The TraverseProject type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProject func(context.Context, *db.ProjectQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProject) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProject) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectQuery", q)
}
// The ProjectCollaboratorFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectCollaboratorFunc func(context.Context, *db.ProjectCollaboratorQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectCollaboratorFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectCollaboratorQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectCollaboratorQuery", q)
}
// The TraverseProjectCollaborator type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProjectCollaborator func(context.Context, *db.ProjectCollaboratorQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProjectCollaborator) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProjectCollaborator) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectCollaboratorQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectCollaboratorQuery", q)
}
// The ProjectGitBotFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectGitBotFunc func(context.Context, *db.ProjectGitBotQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectGitBotFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectGitBotQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectGitBotQuery", q)
}
// The TraverseProjectGitBot type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProjectGitBot func(context.Context, *db.ProjectGitBotQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProjectGitBot) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProjectGitBot) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectGitBotQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectGitBotQuery", q)
}
// The ProjectIssueFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectIssueFunc func(context.Context, *db.ProjectIssueQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectIssueFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectIssueQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectIssueQuery", q)
}
// The TraverseProjectIssue type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProjectIssue func(context.Context, *db.ProjectIssueQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProjectIssue) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProjectIssue) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectIssueQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectIssueQuery", q)
}
// The ProjectIssueCommentFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectIssueCommentFunc func(context.Context, *db.ProjectIssueCommentQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectIssueCommentFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectIssueCommentQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectIssueCommentQuery", q)
}
// The TraverseProjectIssueComment type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProjectIssueComment func(context.Context, *db.ProjectIssueCommentQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProjectIssueComment) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProjectIssueComment) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectIssueCommentQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectIssueCommentQuery", q)
}
// The ProjectTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type ProjectTaskFunc func(context.Context, *db.ProjectTaskQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f ProjectTaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.ProjectTaskQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.ProjectTaskQuery", q)
}
// The TraverseProjectTask type is an adapter to allow the use of ordinary function as Traverser.
type TraverseProjectTask func(context.Context, *db.ProjectTaskQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseProjectTask) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseProjectTask) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.ProjectTaskQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.ProjectTaskQuery", q)
}
// The TaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type TaskFunc func(context.Context, *db.TaskQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TaskFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TaskQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TaskQuery", q)
}
// The TraverseTask type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTask func(context.Context, *db.TaskQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTask) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTask) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TaskQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TaskQuery", q)
}
// The TaskVirtualMachineFunc type is an adapter to allow the use of ordinary function as a Querier.
type TaskVirtualMachineFunc func(context.Context, *db.TaskVirtualMachineQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TaskVirtualMachineFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TaskVirtualMachineQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TaskVirtualMachineQuery", q)
}
// The TraverseTaskVirtualMachine type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTaskVirtualMachine func(context.Context, *db.TaskVirtualMachineQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTaskVirtualMachine) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTaskVirtualMachine) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TaskVirtualMachineQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TaskVirtualMachineQuery", q)
}
// The TeamFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamFunc func(context.Context, *db.TeamQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamQuery", q)
}
// The TraverseTeam type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeam func(context.Context, *db.TeamQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeam) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeam) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamQuery", q)
}
// The TeamGroupFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamGroupFunc func(context.Context, *db.TeamGroupQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamGroupFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamGroupQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupQuery", q)
}
// The TraverseTeamGroup type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamGroup func(context.Context, *db.TeamGroupQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamGroup) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamGroup) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamGroupQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupQuery", q)
}
// The TeamGroupHostFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamGroupHostFunc func(context.Context, *db.TeamGroupHostQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamGroupHostFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamGroupHostQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupHostQuery", q)
}
// The TraverseTeamGroupHost type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamGroupHost func(context.Context, *db.TeamGroupHostQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamGroupHost) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamGroupHost) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamGroupHostQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupHostQuery", q)
}
// The TeamGroupImageFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamGroupImageFunc func(context.Context, *db.TeamGroupImageQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamGroupImageFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamGroupImageQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupImageQuery", q)
}
// The TraverseTeamGroupImage type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamGroupImage func(context.Context, *db.TeamGroupImageQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamGroupImage) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamGroupImage) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamGroupImageQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupImageQuery", q)
}
// The TeamGroupMemberFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamGroupMemberFunc func(context.Context, *db.TeamGroupMemberQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamGroupMemberFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamGroupMemberQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupMemberQuery", q)
}
// The TraverseTeamGroupMember type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamGroupMember func(context.Context, *db.TeamGroupMemberQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamGroupMember) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamGroupMember) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamGroupMemberQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupMemberQuery", q)
}
// The TeamGroupModelFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamGroupModelFunc func(context.Context, *db.TeamGroupModelQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamGroupModelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamGroupModelQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamGroupModelQuery", q)
}
// The TraverseTeamGroupModel type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamGroupModel func(context.Context, *db.TeamGroupModelQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamGroupModel) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamGroupModel) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamGroupModelQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamGroupModelQuery", q)
}
// The TeamHostFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamHostFunc func(context.Context, *db.TeamHostQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamHostFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamHostQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamHostQuery", q)
}
// The TraverseTeamHost type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamHost func(context.Context, *db.TeamHostQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamHost) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamHost) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamHostQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamHostQuery", q)
}
// The TeamImageFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamImageFunc func(context.Context, *db.TeamImageQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamImageFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamImageQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamImageQuery", q)
}
// The TraverseTeamImage type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamImage func(context.Context, *db.TeamImageQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamImage) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamImage) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamImageQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamImageQuery", q)
}
// The TeamMemberFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamMemberFunc func(context.Context, *db.TeamMemberQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamMemberFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamMemberQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamMemberQuery", q)
}
// The TraverseTeamMember type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamMember func(context.Context, *db.TeamMemberQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamMember) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamMember) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamMemberQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamMemberQuery", q)
}
// The TeamModelFunc type is an adapter to allow the use of ordinary function as a Querier.
type TeamModelFunc func(context.Context, *db.TeamModelQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f TeamModelFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.TeamModelQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.TeamModelQuery", q)
}
// The TraverseTeamModel type is an adapter to allow the use of ordinary function as Traverser.
type TraverseTeamModel func(context.Context, *db.TeamModelQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseTeamModel) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseTeamModel) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.TeamModelQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.TeamModelQuery", q)
}
// The UserFunc type is an adapter to allow the use of ordinary function as a Querier.
type UserFunc func(context.Context, *db.UserQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f UserFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.UserQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserQuery", q)
}
// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser.
type TraverseUser func(context.Context, *db.UserQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseUser) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseUser) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.UserQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.UserQuery", q)
}
// The UserIdentityFunc type is an adapter to allow the use of ordinary function as a Querier.
type UserIdentityFunc func(context.Context, *db.UserIdentityQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f UserIdentityFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.UserIdentityQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.UserIdentityQuery", q)
}
// The TraverseUserIdentity type is an adapter to allow the use of ordinary function as Traverser.
type TraverseUserIdentity func(context.Context, *db.UserIdentityQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseUserIdentity) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseUserIdentity) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.UserIdentityQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.UserIdentityQuery", q)
}
// The VirtualMachineFunc type is an adapter to allow the use of ordinary function as a Querier.
type VirtualMachineFunc func(context.Context, *db.VirtualMachineQuery) (db.Value, error)
// Query calls f(ctx, q).
func (f VirtualMachineFunc) Query(ctx context.Context, q db.Query) (db.Value, error) {
if q, ok := q.(*db.VirtualMachineQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *db.VirtualMachineQuery", q)
}
// The TraverseVirtualMachine type is an adapter to allow the use of ordinary function as Traverser.
type TraverseVirtualMachine func(context.Context, *db.VirtualMachineQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseVirtualMachine) Intercept(next db.Querier) db.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseVirtualMachine) Traverse(ctx context.Context, q db.Query) error {
if q, ok := q.(*db.VirtualMachineQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *db.VirtualMachineQuery", q)
}
// NewQuery returns the generic Query interface for the given typed query.
func NewQuery(q db.Query) (Query, error) {
switch q := q.(type) {
case *db.AuditQuery:
return &query[*db.AuditQuery, predicate.Audit, audit.OrderOption]{typ: db.TypeAudit, tq: q}, nil
case *db.GitBotQuery:
return &query[*db.GitBotQuery, predicate.GitBot, gitbot.OrderOption]{typ: db.TypeGitBot, tq: q}, nil
case *db.GitBotTaskQuery:
return &query[*db.GitBotTaskQuery, predicate.GitBotTask, gitbottask.OrderOption]{typ: db.TypeGitBotTask, tq: q}, nil
case *db.GitBotUserQuery:
return &query[*db.GitBotUserQuery, predicate.GitBotUser, gitbotuser.OrderOption]{typ: db.TypeGitBotUser, tq: q}, nil
case *db.GitIdentityQuery:
return &query[*db.GitIdentityQuery, predicate.GitIdentity, gitidentity.OrderOption]{typ: db.TypeGitIdentity, tq: q}, nil
case *db.HostQuery:
return &query[*db.HostQuery, predicate.Host, host.OrderOption]{typ: db.TypeHost, tq: q}, nil
case *db.ImageQuery:
return &query[*db.ImageQuery, predicate.Image, image.OrderOption]{typ: db.TypeImage, tq: q}, nil
case *db.ModelQuery:
return &query[*db.ModelQuery, predicate.Model, model.OrderOption]{typ: db.TypeModel, tq: q}, nil
case *db.NotifyChannelQuery:
return &query[*db.NotifyChannelQuery, predicate.NotifyChannel, notifychannel.OrderOption]{typ: db.TypeNotifyChannel, tq: q}, nil
case *db.NotifySendLogQuery:
return &query[*db.NotifySendLogQuery, predicate.NotifySendLog, notifysendlog.OrderOption]{typ: db.TypeNotifySendLog, tq: q}, nil
case *db.NotifySubscriptionQuery:
return &query[*db.NotifySubscriptionQuery, predicate.NotifySubscription, notifysubscription.OrderOption]{typ: db.TypeNotifySubscription, tq: q}, nil
case *db.ProjectQuery:
return &query[*db.ProjectQuery, predicate.Project, project.OrderOption]{typ: db.TypeProject, tq: q}, nil
case *db.ProjectCollaboratorQuery:
return &query[*db.ProjectCollaboratorQuery, predicate.ProjectCollaborator, projectcollaborator.OrderOption]{typ: db.TypeProjectCollaborator, tq: q}, nil
case *db.ProjectGitBotQuery:
return &query[*db.ProjectGitBotQuery, predicate.ProjectGitBot, projectgitbot.OrderOption]{typ: db.TypeProjectGitBot, tq: q}, nil
case *db.ProjectIssueQuery:
return &query[*db.ProjectIssueQuery, predicate.ProjectIssue, projectissue.OrderOption]{typ: db.TypeProjectIssue, tq: q}, nil
case *db.ProjectIssueCommentQuery:
return &query[*db.ProjectIssueCommentQuery, predicate.ProjectIssueComment, projectissuecomment.OrderOption]{typ: db.TypeProjectIssueComment, tq: q}, nil
case *db.ProjectTaskQuery:
return &query[*db.ProjectTaskQuery, predicate.ProjectTask, projecttask.OrderOption]{typ: db.TypeProjectTask, tq: q}, nil
case *db.TaskQuery:
return &query[*db.TaskQuery, predicate.Task, task.OrderOption]{typ: db.TypeTask, tq: q}, nil
case *db.TaskVirtualMachineQuery:
return &query[*db.TaskVirtualMachineQuery, predicate.TaskVirtualMachine, taskvirtualmachine.OrderOption]{typ: db.TypeTaskVirtualMachine, tq: q}, nil
case *db.TeamQuery:
return &query[*db.TeamQuery, predicate.Team, team.OrderOption]{typ: db.TypeTeam, tq: q}, nil
case *db.TeamGroupQuery:
return &query[*db.TeamGroupQuery, predicate.TeamGroup, teamgroup.OrderOption]{typ: db.TypeTeamGroup, tq: q}, nil
case *db.TeamGroupHostQuery:
return &query[*db.TeamGroupHostQuery, predicate.TeamGroupHost, teamgrouphost.OrderOption]{typ: db.TypeTeamGroupHost, tq: q}, nil
case *db.TeamGroupImageQuery:
return &query[*db.TeamGroupImageQuery, predicate.TeamGroupImage, teamgroupimage.OrderOption]{typ: db.TypeTeamGroupImage, tq: q}, nil
case *db.TeamGroupMemberQuery:
return &query[*db.TeamGroupMemberQuery, predicate.TeamGroupMember, teamgroupmember.OrderOption]{typ: db.TypeTeamGroupMember, tq: q}, nil
case *db.TeamGroupModelQuery:
return &query[*db.TeamGroupModelQuery, predicate.TeamGroupModel, teamgroupmodel.OrderOption]{typ: db.TypeTeamGroupModel, tq: q}, nil
case *db.TeamHostQuery:
return &query[*db.TeamHostQuery, predicate.TeamHost, teamhost.OrderOption]{typ: db.TypeTeamHost, tq: q}, nil
case *db.TeamImageQuery:
return &query[*db.TeamImageQuery, predicate.TeamImage, teamimage.OrderOption]{typ: db.TypeTeamImage, tq: q}, nil
case *db.TeamMemberQuery:
return &query[*db.TeamMemberQuery, predicate.TeamMember, teammember.OrderOption]{typ: db.TypeTeamMember, tq: q}, nil
case *db.TeamModelQuery:
return &query[*db.TeamModelQuery, predicate.TeamModel, teammodel.OrderOption]{typ: db.TypeTeamModel, tq: q}, nil
case *db.UserQuery:
return &query[*db.UserQuery, predicate.User, user.OrderOption]{typ: db.TypeUser, tq: q}, nil
case *db.UserIdentityQuery:
return &query[*db.UserIdentityQuery, predicate.UserIdentity, useridentity.OrderOption]{typ: db.TypeUserIdentity, tq: q}, nil
case *db.VirtualMachineQuery:
return &query[*db.VirtualMachineQuery, predicate.VirtualMachine, virtualmachine.OrderOption]{typ: db.TypeVirtualMachine, tq: q}, nil
default:
return nil, fmt.Errorf("unknown query type %T", q)
}
}
type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
typ string
tq interface {
Limit(int) T
Offset(int) T
Unique(bool) T
Order(...R) T
Where(...P) T
}
}
func (q query[T, P, R]) Type() string {
return q.typ
}
func (q query[T, P, R]) Limit(limit int) {
q.tq.Limit(limit)
}
func (q query[T, P, R]) Offset(offset int) {
q.tq.Offset(offset)
}
func (q query[T, P, R]) Unique(unique bool) {
q.tq.Unique(unique)
}
func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
rs := make([]R, len(orders))
for i := range orders {
rs[i] = orders[i]
}
q.tq.Order(rs...)
}
func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
p := make([]P, len(ps))
for i := range ps {
p[i] = ps[i]
}
q.tq.Where(p...)
}