Documentation
¶
Index ¶
- Variables
- func Session(ctx context.Context) *session
- type Driver
- type Orm
- type Repository
- func (r *Repository) Delete(ctx context.Context, entities ...interface{}) error
- func (r *Repository) FindAll(ctx context.Context, q *query.Query) (*d3entity.Collection, error)
- func (r *Repository) FindOne(ctx context.Context, q *query.Query) (interface{}, error)
- func (r *Repository) Persists(ctx context.Context, entities ...interface{}) error
- func (r *Repository) Select() *query.Query
- type ScalarDataMapper
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ( ErrEntityNotFound = errors.New("entity not found") ErrSessionNotSet = errors.New("session not found in context") )
Functions ¶
Types ¶
type Driver ¶
type Driver interface { MakePusher(tx Transaction) persistence.Pusher ExecuteQuery(query *query.Query, tx Transaction) ([]map[string]interface{}, error) BeforeQuery(fn func(query string, args ...interface{})) AfterQuery(fn func(query string, args ...interface{})) BeginTx() (Transaction, error) MakeScalarDataMapper() ScalarDataMapper }
type Orm ¶
type Orm struct {
// contains filtered or unexported fields
}
Orm - d3 orm instance.
func New ¶
New - create an instance of d3 orm.
driver - d3 wrapper on database driver. Find it in adapter package.
func (*Orm) CtxWithSession ¶
CtxWithSession append new session instance to context.
func (*Orm) GenerateSchema ¶
GenerateSchema - create sql DDL for persist all registered entities in database. May return error if driver nonsupport schema generation.
func (*Orm) MakeRepository ¶
func (o *Orm) MakeRepository(entity interface{}) (*Repository, error)
MakeRepository - create new repository for entity.
entity - entity to store in repository.
func (*Orm) MakeSession ¶
func (o *Orm) MakeSession() *session
MakeSession - create new instance of session.
func (*Orm) Register ¶
Register - register entities in d3 orm. Note that entity must be structure and must implement D3Entity interface (it's implement it after use code generation tool). Besides if you register entity with dependencies (for example: one to one relation) you must registered depended entities too, in the same call.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func (*Repository) Delete ¶
func (r *Repository) Delete(ctx context.Context, entities ...interface{}) error
Delete - delete entities from repository.
func (*Repository) FindAll ¶
func (r *Repository) FindAll(ctx context.Context, q *query.Query) (*d3entity.Collection, error)
FindOne - return collection of entities fetched by query.
func (*Repository) FindOne ¶
FindOne - return one entity fetched by query. If entity not found ErrEntityNotFound will returned.
func (*Repository) Persists ¶
func (r *Repository) Persists(ctx context.Context, entities ...interface{}) error
Persists - add entities to repository.
func (*Repository) Select ¶
func (r *Repository) Select() *query.Query
Select - create query for fetch entity with the same type as the repository.
type ScalarDataMapper ¶
type Transaction ¶
Transaction for control transaction driver must provide instance of this interface.