postgres

package
v0.0.0-...-ee1e9a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct{}

Driver contains all the function needed to be recognized as a libdata driver

func (*Driver) BeginTransaction

func (d *Driver) BeginTransaction(
	c *libdata.Cluster, tenant *libdata.Tenant, useCache bool,
) (*libdata.Transaction, error)

BeginTransaction will create a new transaction and return it.

func (*Driver) CommitTransaction

func (d *Driver) CommitTransaction(tx *libdata.Transaction) error

CommitTransaction will definitely save all the operations in the transaction.

func (*Driver) CreateTenant

func (d *Driver) CreateTenant(cluster *libdata.Cluster, tenant *libdata.Tenant) error

CreateTenant will create the tenant in postgres, either a new schema or a new tenant record

func (*Driver) Delete

func (d *Driver) Delete(
	ctx context.Context, tx *libdata.Transaction,
	model *libdata.ModelDefinition, filters []*libdata.Filter,
) error

Delete will delete the filtered records.

func (*Driver) GenerateScanFunc

func (d *Driver) GenerateScanFunc(model *libdata.ModelDefinition) string

func (*Driver) GetTenant

func (d *Driver) GetTenant(
	tx *libdata.Transaction, tenant *libdata.Tenant,
) (*libdata.Tenant, error)

GetTenant will return the tenant.

func (*Driver) InitDB

func (d *Driver) InitDB(
	writeInfo *libdata.ClusterInfo, readInfo *libdata.ClusterInfo,
) (*libdata.Cluster, error)

InitDB will connect to the postgres database and return the connection

func (*Driver) Insert

func (d *Driver) Insert(
	ctx context.Context, tx *libdata.Transaction,
	t *libdata.ModelDefinition, records []libdata.ModelInterface,
) (interface{}, error)

Insert will insert the new record in the database.

func (*Driver) RegisterEvent

func (d *Driver) RegisterEvent(
	tx *libdata.Transaction, aggregate string, aggregateUUID string, name string, payload []byte,
) (libdata.EventInterface, error)

RegisterEvent will register the event in the event model.

func (*Driver) RollbackTransaction

func (d *Driver) RollbackTransaction(tx *libdata.Transaction) error

RollbackTransaction will cancel all the operations in the transaction.

func (*Driver) Select

func (d *Driver) Select(
	ctx context.Context, tx *libdata.Transaction, model *libdata.ModelDefinition,
	filters []*libdata.Filter, limit *uint, orderBy []*libdata.OrderByInput,
) (interface{}, error)

Select will return the filtered records.

func (*Driver) Update

func (d *Driver) Update(
	ctx context.Context, tx *libdata.Transaction, t *libdata.ModelDefinition,
	filters []*libdata.Filter, record interface{}, updateMask *fieldmask.FieldMask,
) (interface{}, error)

Update will update the data in the filtered records.

type Store

type Store interface {
	InsertBuildArgs([]libdata.ModelInterface) ([]string, map[string]interface{})
	UpdateBuildArgs(interface{}, *fieldmask.FieldMask) ([]string, map[string]interface{})
}

Store is an interface containing the functions needed to build the arguments specifics to the model type.

type Tx

type Tx struct {
	Sqlx *sqlx.Tx
}

Tx contains all the function needed to be recognized as a libdata Tx

func (*Tx) Exec

func (tx *Tx) Exec(query string, args interface{}) error

Exec will execute the specified query in this transaction.

func (*Tx) QueryRows

func (tx *Tx) QueryRows(q string, args interface{}) (*sqlx.Rows, error)

QueryRows will execute the specified query in this transaction and return the records.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL