Documentation ¶
Index ¶
- func ConditionArg(c *rt.GoCont, n int) (condition.Condition, error)
- func QueryArg(c *rt.GoCont, n int) (*parse.Query, error)
- func RecordArg(c *rt.GoCont, n int) (record.Record, error)
- func RecordToTable(r record.Record) *rt.Table
- func Register(name string, f func() *rt.Table)
- func TableToRecord(t *rt.Table) (record.Record, error)
- func ValueToCondition(v rt.Value) (condition.Condition, bool)
- func ValueToQuery(v rt.Value) (*parse.Query, bool)
- func ValueToRecord(v rt.Value) (record.Record, bool)
- func WrapConnectFunc(f func(*rt.Thread, *rt.GoCont) (string, error)) func(*rt.Thread, *rt.GoCont) (rt.Cont, error)
- type Connection
- func (conn *Connection) Close() error
- func (conn *Connection) ConnectToTable(ctx context.Context, name string) (*Table, error)
- func (conn *Connection) CreateTable(ctx context.Context, name string, template record.Record) error
- func (conn *Connection) DataSource() string
- func (conn *Connection) DeleteTable(ctx context.Context, name string) error
- func (conn *Connection) DriverName() string
- func (conn *Connection) GetTimeout() time.Duration
- func (conn *Connection) IsClosed() bool
- func (conn *Connection) ListTables(ctx context.Context) ([]string, error)
- func (conn *Connection) SetTimeout(timeout time.Duration)
- func (conn *Connection) String() string
- type Cursor
- func (cur *Cursor) Advance(ctx context.Context) (r record.Record, err error)
- func (cur *Cursor) Buffered() bool
- func (cur *Cursor) Close() error
- func (cur *Cursor) GetTimeout() time.Duration
- func (cur *Cursor) IsClosed() bool
- func (cur *Cursor) SetTimeout(timeout time.Duration)
- func (cur *Cursor) String() string
- type Table
- func (t *Table) Close() error
- func (t *Table) Count(ctx context.Context, selector record.Record) (int64, error)
- func (t *Table) CountWhere(ctx context.Context, cond condition.Condition) (int64, error)
- func (t *Table) Delete(ctx context.Context, selector record.Record) (int64, error)
- func (t *Table) DeleteWhere(ctx context.Context, cond condition.Condition) (int64, error)
- func (t *Table) Describe(ctx context.Context) (record.Record, error)
- func (t *Table) GetTimeout() time.Duration
- func (t *Table) Insert(ctx context.Context, itr record.Iterator) error
- func (t *Table) InsertRecords(ctx context.Context, records ...record.Record) error
- func (t *Table) IsClosed() bool
- func (t *Table) Name() string
- func (t *Table) Select(ctx context.Context, template record.Record, selector record.Record, ...) (record.Iterator, error)
- func (t *Table) SelectLimit(ctx context.Context, template record.Record, selector record.Record, ...) (record.Iterator, error)
- func (t *Table) SelectOne(ctx context.Context, template record.Record, selector record.Record, ...) (record.Record, error)
- func (t *Table) SelectOneWhere(ctx context.Context, template record.Record, cond condition.Condition, ...) (record.Record, error)
- func (t *Table) SelectWhere(ctx context.Context, template record.Record, cond condition.Condition, ...) (record.Iterator, error)
- func (t *Table) SelectWhereLimit(ctx context.Context, template record.Record, cond condition.Condition, ...) (record.Iterator, error)
- func (t *Table) SetTimeout(timeout time.Duration)
- func (t *Table) String() string
- func (t *Table) Update(ctx context.Context, replacement record.Record, selector record.Record) (int64, error)
- func (t *Table) UpdateWhere(ctx context.Context, replacement record.Record, cond condition.Condition) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConditionArg ¶
ConditionArg turns a continuation argument into a condition.Condition.
func RecordToTable ¶
RecordToTable converts the given record.Record to a lua table.
func Register ¶
Register registers the given function that returns a table to be added to the package table using the given name (typically a name of a keyvalue driver). If a function is already registered with the given name then it will be replaced; if the name coincides with one of the package functions or values then it will be overwritten. Note that any function registered after the package is loaded into the Lua runtime will not appear in that instance of the package.
func TableToRecord ¶
TableToRecord converts the given lua table to a record.Record.
func ValueToCondition ¶
ValueToCondition turns a lua value to a condition.Condition, if possible.
func ValueToQuery ¶
ValueToQuery turns a lua value to a *parse.Query, if possible.
func ValueToRecord ¶
ValueToRecord turns a lua value to a record.Record, if possible.
Types ¶
type Connection ¶
type Connection struct { log.Logable metrics.Metricsable // contains filtered or unexported fields }
Connection wraps a keyvalue.Connection.
func ConnectionArg ¶
func ConnectionArg(c *rt.GoCont, n int) (*Connection, error)
ConnectionArg turns a continuation argument into a *Connection.
func ValueToConnection ¶
func ValueToConnection(v rt.Value) (*Connection, bool)
ValueToConnection turns a lua value to a *Connection, if possible.
func (*Connection) Close ¶
func (conn *Connection) Close() error
Close prevents any further queries through this connection.
func (*Connection) ConnectToTable ¶
ConnectToTable connects to the indicated table in the database. A finaliser is set on the table to ensure that it is closed.
func (*Connection) CreateTable ¶
CreateTable creates a table with the given name in the database.
The provided template will be used by the underlying storage-engine to create the new table if appropriate; the storage-engine is free to ignore the template if it is not required (for example, in a schema-less database).
func (*Connection) DataSource ¶
func (conn *Connection) DataSource() string
DataSource returns the data source string used to establish the connection. Note that this may contain sensitive user data such as a password.
func (*Connection) DeleteTable ¶
func (conn *Connection) DeleteTable(ctx context.Context, name string) error
DeleteTable deletes the indicated table from the database. Does not return an error if the table does not exist.
func (*Connection) DriverName ¶
func (conn *Connection) DriverName() string
DriverName returns the name of the associated driver.
func (*Connection) GetTimeout ¶
func (conn *Connection) GetTimeout() time.Duration
GetTimeout returns the timeout.
func (*Connection) IsClosed ¶
func (conn *Connection) IsClosed() bool
IsClosed returns true iff the connection is closed.
func (*Connection) ListTables ¶
func (conn *Connection) ListTables(ctx context.Context) ([]string, error)
ListTables returns the names of the tables in the database. The names are sorted in increasing order.
func (*Connection) SetTimeout ¶
func (conn *Connection) SetTimeout(timeout time.Duration)
SetTimeout sets the timeout. A negative timeout is interpreted to mean no timeout.
func (*Connection) String ¶
func (conn *Connection) String() string
String returns a string description of the connection.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor describes a stream of records as given by a record.Iterator.
func NewCursor ¶
NewCursor wraps the given record.Iterator as a cursor. A finaliser is set of the cursor to ensure that it is closed.
func ValueToCursor ¶
ValueToCursor turns a lua value to a *Cursor, if possible.
func (*Cursor) Advance ¶
Advance advances the cursor. If the end of the cursor is reached, this will return io.EOF.
func (*Cursor) Buffered ¶
Buffered returns true iff the next call to Advance is guaranteed not to block.
func (*Cursor) GetTimeout ¶
GetTimeout returns the timeout.
func (*Cursor) SetTimeout ¶
SetTimeout sets the timeout. A negative timeout is interpreted to mean no timeout.
type Table ¶
Table wraps a keyvalue.Table.
func NewTable ¶
NewTable wraps the given keyvalue.Table as a Table. A finaliser is set on the table to ensure that it is closed.
func ValueToTable ¶
ValueToTable turns a lua value to a *Table, if possible.
func (*Table) CountWhere ¶
CountWhere returns the number of records in the table that satisfy condition "cond" (which may be nil if there are no conditions).
func (*Table) Delete ¶
Delete deletes those records in the table that match "selector". Returns the number of records deleted.
func (*Table) DeleteWhere ¶
DeleteWhere deletes those records in the table that satisfy condition "cond" (which may be nil if there are no conditions). Returns the number of records deleted.
func (*Table) Describe ¶
Describe returns a best-guess template for the data in this table.
Note that the accuracy of this template depends on the underlying storage engine. It might not be possible to return an exact description (for example, in a schema-less database), and in this case we return a good guess based on a sample of the data available.
func (*Table) GetTimeout ¶
GetTimeout returns the timeout.
func (*Table) InsertRecords ¶
InsertRecords inserts the given records into the table.
func (*Table) Select ¶
func (t *Table) Select(ctx context.Context, template record.Record, selector record.Record, order sort.OrderBy) (record.Iterator, error)
Select returns the records matching "selector", sorted as specified by "order" (which may be nil if there is no sort order required). The returned records will be in the form specified by "template".
func (*Table) SelectLimit ¶
func (t *Table) SelectLimit(ctx context.Context, template record.Record, selector record.Record, order sort.OrderBy, n int64) (record.Iterator, error)
SelectLimit returns at most n records matching "selector", sorted as specified by "order" (which may be nil if there is no sort order required). The returned records will be in the form specified by "template".
func (*Table) SelectOne ¶
func (t *Table) SelectOne(ctx context.Context, template record.Record, selector record.Record, order sort.OrderBy) (record.Record, error)
SelectOne returns the first record matching "selector", sorted as specified by "order" (which may be nil if there is no sort order required). The returned record will be in the form specified by "template". If no records match, then a nil record will be returned.
func (*Table) SelectOneWhere ¶
func (t *Table) SelectOneWhere(ctx context.Context, template record.Record, cond condition.Condition, order sort.OrderBy) (record.Record, error)
SelectOneWhere returns the first record satisfying condition "cond" (which may be nil if there are no conditions), sorted as specified by "order" (which may be nil if there is no sort order required). The returned record will be in the form specified by "template". If no records match, then a nil record will be returned.
func (*Table) SelectWhere ¶
func (t *Table) SelectWhere(ctx context.Context, template record.Record, cond condition.Condition, order sort.OrderBy) (record.Iterator, error)
SelectWhere returns the results satisfying condition "cond" (which may be nil if there are no conditions), sorted as specified by "order" (which may be nil if there is no sort order required). The returned records will be in the form specified by "template".
func (*Table) SelectWhereLimit ¶
func (t *Table) SelectWhereLimit(ctx context.Context, template record.Record, cond condition.Condition, order sort.OrderBy, n int64) (record.Iterator, error)
SelectWhereLimit returns at most n results satisfying condition "cond" (which may be nil if there are no conditions), sorted as specified by "order" (which may be nil if there is no sort order required). The returned records will be in the form specified by "template".
func (*Table) SetTimeout ¶
SetTimeout sets the timeout. A negative timeout is interpreted to mean no timeout.
func (*Table) Update ¶
func (t *Table) Update(ctx context.Context, replacement record.Record, selector record.Record) (int64, error)
Update updates all records in the table that match "selector" by setting all keys present in "replacement" to the given values. Returns the number of records updated.
func (*Table) UpdateWhere ¶
func (t *Table) UpdateWhere(ctx context.Context, replacement record.Record, cond condition.Condition) (int64, error)
UpdateWhere updates all records in the table that satisfy condition "cond" (which may be nil if there are no conditions) by setting all keys present in "replacement" to the given values. Returns the number of records updated.