table

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 3 Imported by: 60

Documentation

Overview

Package table adds support for super simple CRUD operations based on table model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Name    string
	Columns []string
	PartKey []string
	SortKey []string
}

Metadata represents table schema.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table allows for simple CRUD operations, it's backed by query builders from gocqlx/qb package.

func New

func New(m Metadata) *Table

New creates new Table based on table schema read from Metadata.

func (*Table) Delete

func (t *Table) Delete(columns ...string) (stmt string, names []string)

Delete returns delete by primary key statement.

func (*Table) DeleteBuilder

func (t *Table) DeleteBuilder(columns ...string) *qb.DeleteBuilder

DeleteBuilder returns a builder initialised to delete by primary key statement.

func (*Table) DeleteQuery added in v2.1.0

func (t *Table) DeleteQuery(session gocqlx.Session, columns ...string) *gocqlx.Queryx

DeleteQuery returns query which delete by primary key.

func (*Table) DeleteQueryContext added in v2.1.0

func (t *Table) DeleteQueryContext(ctx context.Context, session gocqlx.Session, columns ...string) *gocqlx.Queryx

DeleteQueryContext returns query wrapped with context which delete by primary key.

func (*Table) Get

func (t *Table) Get(columns ...string) (stmt string, names []string)

Get returns select by primary key statement.

func (*Table) GetQuery added in v2.1.0

func (t *Table) GetQuery(session gocqlx.Session, columns ...string) *gocqlx.Queryx

GetQuery returns query which gets by primary key.

func (*Table) GetQueryContext added in v2.1.0

func (t *Table) GetQueryContext(ctx context.Context, session gocqlx.Session, columns ...string) *gocqlx.Queryx

GetQueryContext returns query wrapped with context which gets by partition key.

func (*Table) Insert

func (t *Table) Insert() (stmt string, names []string)

Insert returns insert all columns statement.

func (*Table) InsertBuilder added in v2.2.0

func (t *Table) InsertBuilder() *qb.InsertBuilder

InsertBuilder returns a builder initialised with all columns.

func (*Table) InsertQuery added in v2.1.0

func (t *Table) InsertQuery(session gocqlx.Session) *gocqlx.Queryx

InsertQuery returns query which inserts all columns.

func (*Table) InsertQueryContext added in v2.1.0

func (t *Table) InsertQueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx

InsertQueryContext returns query wrapped with context which inserts all columns.

func (*Table) Metadata

func (t *Table) Metadata() Metadata

Metadata returns copy of table metadata.

func (*Table) Name

func (t *Table) Name() string

Name returns table name.

func (*Table) PrimaryKeyCmp

func (t *Table) PrimaryKeyCmp() []qb.Cmp

PrimaryKeyCmp returns copy of table's primaryKeyCmp.

func (*Table) Select

func (t *Table) Select(columns ...string) (stmt string, names []string)

Select returns select by partition key statement.

func (*Table) SelectAll added in v2.2.0

func (t *Table) SelectAll() (stmt string, names []string)

SelectAll returns select * statement.

func (*Table) SelectBuilder

func (t *Table) SelectBuilder(columns ...string) *qb.SelectBuilder

SelectBuilder returns a builder initialised to select by partition key statement.

func (*Table) SelectQuery added in v2.1.0

func (t *Table) SelectQuery(session gocqlx.Session, columns ...string) *gocqlx.Queryx

SelectQuery returns query which selects by partition key statement.

func (*Table) SelectQueryContext added in v2.1.0

func (t *Table) SelectQueryContext(ctx context.Context, session gocqlx.Session, columns ...string) *gocqlx.Queryx

SelectQueryContext returns query wrapped with context which selects by partition key statement.

func (*Table) Update

func (t *Table) Update(columns ...string) (stmt string, names []string)

Update returns update by primary key statement.

func (*Table) UpdateBuilder

func (t *Table) UpdateBuilder(columns ...string) *qb.UpdateBuilder

UpdateBuilder returns a builder initialised to update by primary key statement.

func (*Table) UpdateQuery added in v2.1.0

func (t *Table) UpdateQuery(session gocqlx.Session, columns ...string) *gocqlx.Queryx

UpdateQuery returns query which updates by primary key.

func (*Table) UpdateQueryContext added in v2.1.0

func (t *Table) UpdateQueryContext(ctx context.Context, session gocqlx.Session, columns ...string) *gocqlx.Queryx

UpdateQueryContext returns query wrapped with context which updates by primary key.

Jump to

Keyboard shortcuts

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