Documentation ¶
Index ¶
- Variables
- func CreateDBDSN(config *app.DBConfig) string
- func CreateDebugFN(config *app.DBConfig) func(ctx context.Context, i ...any)
- func GetEntDialect(config *app.DBConfig) (string, error)
- func NOW(dialect string) any
- func NewClient(config *app.DBConfig, schemaBuilder *schema.Builder) (_ app.DBClient, err error)
- func NewDBAdapter(config *app.DBConfig, schemaBuilder *schema.Builder) (app.DBClient, error)
- func NewEntClient(config *app.DBConfig, schemaBuilder *schema.Builder, ...) (_ app.DBClient, err error)
- func NewTestClient(migrationDir string, schemaBuilder *schema.Builder, ...) (_ app.DBClient, err error)
- type Adapter
- func (d *Adapter) Close() error
- func (d *Adapter) Commit() error
- func (d *Adapter) Config() *app.DBConfig
- func (d *Adapter) CreateDBModel(s *schema.Schema, relations ...*schema.Relation) app.Model
- func (d *Adapter) CreateModel(s *schema.Schema, relations ...*schema.Relation) *Model
- func (d *Adapter) DB() *sql.DB
- func (d *Adapter) Dialect() string
- func (d *Adapter) Driver() dialect.Driver
- func (d *Adapter) Exec(ctx context.Context, query string, args, bindValue any) error
- func (d *Adapter) Hooks() *app.Hooks
- func (d *Adapter) IsTx() bool
- func (d *Adapter) Migrate(migration *app.Migration, appendEntTables ...*entSchema.Table) (err error)
- func (d *Adapter) Model(name string) (app.Model, error)
- func (d *Adapter) NewEdgeSpec(r *schema.Relation, nodeIDs []driver.Value) (*sqlgraph.EdgeSpec, error)
- func (d *Adapter) NewEdgeStepOption(r *schema.Relation) (sqlgraph.StepOption, error)
- func (d *Adapter) Reload(newSchemaBuilder *schema.Builder, migration *app.Migration) (_ app.DBClient, err error)
- func (d *Adapter) Rollback() error
- func (d *Adapter) SchemaBuilder() *schema.Builder
- func (d *Adapter) SetDriver(driver dialect.Driver)
- func (d *Adapter) SetSQLDB(db *sql.DB)
- func (d *Adapter) Tx(ctx context.Context) (app.DBClient, error)
- type Column
- type EntAdapter
- type Model
- func (m *Model) Clone() app.Model
- func (m *Model) Column(name string) (*Column, error)
- func (m *Model) Create(e *schema.Entity) (_ uint64, err error)
- func (m *Model) CreateFromJSON(json string) (_ uint64, err error)
- func (m *Model) DBColumns() []string
- func (m *Model) GetEntTable() *entSchema.Table
- func (m *Model) Mutation(skipTxs ...bool) app.Mutation
- func (m *Model) Name() string
- func (m *Model) Query(predicates ...*app.Predicate) app.Query
- func (m *Model) Schema() *schema.Schema
- func (m *Model) SetClient(client app.DBClient) app.Model
- type Mutation
- func (m *Mutation) Create(e *schema.Entity) (_ uint64, err error)
- func (m *Mutation) Delete() (affected int, err error)
- func (m *Mutation) GetRelationEntityIDs(fieldName string, fieldValue any) ([]driver.Value, error)
- func (m *Mutation) ProcessFieldAdd(entAdapter EntAdapter, k string, v any) error
- func (m *Mutation) ProcessFieldClear(entAdapter EntAdapter, k string, v any) error
- func (m *Mutation) ProcessFieldExpr(entAdapter EntAdapter, k string, v any) error
- func (m *Mutation) ProcessUpdateBlockAdd(entAdapter EntAdapter, fieldValue any) error
- func (m *Mutation) ProcessUpdateBlockClear(entAdapter EntAdapter, fieldValue any) error
- func (m *Mutation) ProcessUpdateBlockExpr(entAdapter EntAdapter, fieldValue any) error
- func (m *Mutation) ProcessUpdateBlockSet(entAdapter EntAdapter, fieldValue any) error
- func (m *Mutation) ProcessUpdateFieldSet(entAdapter EntAdapter, k string, v any) error
- func (m *Mutation) Update(e *schema.Entity) (affected int, err error)
- func (m *Mutation) Where(predicates ...*app.Predicate) app.Mutation
- type PredicateFN
- type Query
- func (q *Query) Count(options *app.CountOption, ctxs ...context.Context) (int, error)
- func (q *Query) First(ctxs ...context.Context) (*schema.Entity, error)
- func (q *Query) Get(ctxs ...context.Context) ([]*schema.Entity, error)
- func (q *Query) Limit(limit uint) app.Query
- func (q *Query) Offset(offset uint) app.Query
- func (q *Query) Only(ctxs ...context.Context) (*schema.Entity, error)
- func (q *Query) Options() *app.QueryOption
- func (q *Query) Order(order ...string) app.Query
- func (q *Query) Select(fields ...string) app.Query
- func (q *Query) Where(predicates ...*app.Predicate) app.Query
- type Tx
- func (tx *Tx) Close() error
- func (tx *Tx) Commit() error
- func (tx *Tx) Config() *app.DBConfig
- func (tx *Tx) CreateDBModel(s *schema.Schema, relations ...*schema.Relation) app.Model
- func (tx *Tx) DB() *sql.DB
- func (tx *Tx) Dialect() string
- func (tx *Tx) Driver() dialect.Driver
- func (tx *Tx) Exec(ctx context.Context, query string, args any, bindValue any) error
- func (tx *Tx) Hooks() *app.Hooks
- func (tx *Tx) IsTx() bool
- func (tx *Tx) Migrate(migration *app.Migration, appendEntTables ...*entSchema.Table) (err error)
- func (tx *Tx) Model(name string) (app.Model, error)
- func (tx *Tx) NewEdgeSpec(r *schema.Relation, nodeIDs []driver.Value) (*sqlgraph.EdgeSpec, error)
- func (tx *Tx) NewEdgeStepOption(r *schema.Relation) (sqlgraph.StepOption, error)
- func (tx *Tx) Reload(newSchemaBuilder *schema.Builder, migration *app.Migration) (app.DBClient, error)
- func (tx *Tx) Rollback() error
- func (tx *Tx) SchemaBuilder() *schema.Builder
- func (tx *Tx) SetDriver(driver dialect.Driver)
- func (tx *Tx) SetSQLDB(db *sql.DB)
- func (tx *Tx) Tx(ctx context.Context) (t app.DBClient, err error)
- type TxDriver
- func (tx *TxDriver) Close() error
- func (tx *TxDriver) Commit() error
- func (tx *TxDriver) Dialect() string
- func (tx *TxDriver) Exec(ctx context.Context, query string, args, v any) error
- func (tx *TxDriver) ID() string
- func (tx *TxDriver) Query(ctx context.Context, query string, args, v any) error
- func (tx *TxDriver) Rollback() error
- func (tx *TxDriver) Tx(context.Context) (dialect.Tx, error)
Constants ¶
This section is empty.
Variables ¶
var RelMaps = map[schema.RelationType]sqlgraph.Rel{ schema.O2O: sqlgraph.O2O, schema.O2M: sqlgraph.O2M, schema.M2M: sqlgraph.M2M, }
RelMaps map the relation type to the ent relation type
Functions ¶
func CreateDBDSN ¶
CreateDBDSN create a DSN string for the database connection
func NewDBAdapter ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is the ent adapter for app.Client
func (*Adapter) CreateDBModel ¶
func (*Adapter) CreateModel ¶
CreateModel create a new model from schema
func (*Adapter) NewEdgeSpec ¶
func (d *Adapter) NewEdgeSpec( r *schema.Relation, nodeIDs []driver.Value, ) (*sqlgraph.EdgeSpec, error)
NewEdgeSpec create a new edge spec
func (*Adapter) NewEdgeStepOption ¶
NewEdgeStep create a new edge step
func (*Adapter) SchemaBuilder ¶
SchemaBuilder returns the schema builder.
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
Column is a wrapper around a schema field and an ent column
type EntAdapter ¶ added in v0.0.5
type EntAdapter interface { NewEdgeSpec( r *schema.Relation, nodeIDs []driver.Value, ) (*sqlgraph.EdgeSpec, error) NewEdgeStepOption(r *schema.Relation) (sqlgraph.StepOption, error) Reload( newSchemaBuilder *schema.Builder, migration *app.Migration, ) (_ app.DBClient, err error) Driver() dialect.Driver CreateDBModel(s *schema.Schema, relations ...*schema.Relation) app.Model Close() error Commit() error Rollback() error Config() *app.DBConfig DB() *sql.DB Dialect() string Exec( ctx context.Context, query string, args, bindValue any, ) error Hooks() *app.Hooks IsTx() bool Model(name string) (app.Model, error) SchemaBuilder() *schema.Builder Tx(ctx context.Context) (app.DBClient, error) Migrate( migration *app.Migration, appendEntTables ...*entSchema.Table, ) (err error) SetSQLDB(db *sql.DB) SetDriver(driver dialect.Driver) }
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model holds the model data
func (*Model) CreateFromJSON ¶
CreateFromJSON creates a new entity from JSON
func (*Model) GetEntTable ¶
type Mutation ¶
type Mutation struct {
// contains filtered or unexported fields
}
Mutation holds the entity mutation data
func (*Mutation) GetRelationEntityIDs ¶
GetRelationEntityIDs return the relation IDs from the given field value
func (*Mutation) ProcessFieldAdd ¶
func (m *Mutation) ProcessFieldAdd(entAdapter EntAdapter, k string, v any) error
ProcessFieldAdd processes a field in the $add block
func (*Mutation) ProcessFieldClear ¶
func (m *Mutation) ProcessFieldClear(entAdapter EntAdapter, k string, v any) error
ProcessFieldClear processes a field in the $clear block
func (*Mutation) ProcessFieldExpr ¶
func (m *Mutation) ProcessFieldExpr(entAdapter EntAdapter, k string, v any) error
ProcessFieldExpr processes a field in the $expr block
func (*Mutation) ProcessUpdateBlockAdd ¶
func (m *Mutation) ProcessUpdateBlockAdd(entAdapter EntAdapter, fieldValue any) error
ProcessUpdateBlockAdd processes the $add block
func (*Mutation) ProcessUpdateBlockClear ¶
func (m *Mutation) ProcessUpdateBlockClear(entAdapter EntAdapter, fieldValue any) error
ProcessUpdateBlockClear processes the $clear block
func (*Mutation) ProcessUpdateBlockExpr ¶
func (m *Mutation) ProcessUpdateBlockExpr(entAdapter EntAdapter, fieldValue any) error
ProcessUpdateBlockExpr processes the $expr block
func (*Mutation) ProcessUpdateBlockSet ¶
func (m *Mutation) ProcessUpdateBlockSet(entAdapter EntAdapter, fieldValue any) error
ProcessUpdateBlockSet processes the $set block
func (*Mutation) ProcessUpdateFieldSet ¶
func (m *Mutation) ProcessUpdateFieldSet(entAdapter EntAdapter, k string, v any) error
ProcessUpdateFieldSet processes a field in the $set block
type PredicateFN ¶
func CreateFieldPredicate ¶ added in v0.0.5
func CreateFieldPredicate(predicate *app.Predicate) (PredicateFN, error)
CreateFieldPredicate convert a predicate to ent predicate
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) Options ¶
func (q *Query) Options() *app.QueryOption
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx hold the transaction and the schema manager.
func (*Tx) CreateDBModel ¶
CreateDBModel creates a new model from the schema.
func (*Tx) NewEdgeSpec ¶
func (*Tx) NewEdgeStepOption ¶
func (*Tx) Reload ¶
func (tx *Tx) Reload(newSchemaBuilder *schema.Builder, migration *app.Migration) (app.DBClient, error)
Reload reloads the schema.
func (*Tx) SchemaBuilder ¶
SchemaBuilder returns the schema builder.