Documentation ¶
Index ¶
- func Drivers() (names []string)
- func NewReader(r io.Reader, opts ReaderOptions) (record.Iterator, error)
- func Register(name string, d driver.Driver)
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) ConnectToTable(ctx context.Context, name string) (*Table, error)
- func (c *Connection) CreateTable(ctx context.Context, name string, template record.Record) error
- func (c *Connection) DataSource() string
- func (c *Connection) DeleteTable(ctx context.Context, name string) error
- func (c *Connection) DriverName() string
- func (c *Connection) ListTables(ctx context.Context) ([]string, error)
- func (c *Connection) RenameTable(ctx context.Context, oldname string, newname string) error
- func (c *Connection) SetMetrics(m metrics.Interface)
- type ReaderError
- type ReaderOptions
- type Table
- func (t *Table) AddIndex(ctx context.Context, key string) error
- func (t *Table) AddKey(ctx context.Context, key string, value interface{}) error
- func (t *Table) AddKeys(ctx context.Context, rec record.Record) error
- func (t *Table) AddUniqueIndex(ctx context.Context, key string) error
- 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) DeleteIndex(ctx context.Context, key string) error
- func (t *Table) DeleteKey(ctx context.Context, key string) error
- func (t *Table) DeleteKeys(ctx context.Context, keys []string) 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) Insert(ctx context.Context, itr record.Iterator) error
- func (t *Table) InsertRecords(ctx context.Context, records ...record.Record) error
- func (t *Table) ListIndices(ctx context.Context) ([]string, error)
- func (t *Table) Log() log.Interface
- func (t *Table) Metrics() metrics.Interface
- 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) 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 Drivers ¶
func Drivers() (names []string)
Drivers returns a sorted list of the names of the registered drivers.
Types ¶
type Connection ¶
type Connection struct { log.BasicLogable metrics.BasicMetricsable // contains filtered or unexported fields }
Connection provides a database connection.
func Open ¶
func Open(ctx context.Context, dataSource string) (*Connection, error)
Open opens a connection using the given data source.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes the connection to the database.
func (*Connection) ConnectToTable ¶
ConnectToTable connects to the indicated table in the database.
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 (c *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 (c *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 (c *Connection) DriverName() string
DriverName returns the name of the associated driver.
func (*Connection) ListTables ¶
func (c *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) RenameTable ¶ added in v0.1.29
RenameTable changes the name of a table in the database.
func (*Connection) SetMetrics ¶
func (c *Connection) SetMetrics(m metrics.Interface)
SetMetrics sets a metrics endpoint.
type ReaderError ¶
type ReaderError interface { Error() string // Error returns a string representation of the error. Line() uint64 // Line returns the line number on which the error occurred. Index() uint64 // Index returns the record index for which the error occurred (indexed from 1). Key() string // Key returns the key associated with this error, if known. }
ReaderError is the interface satisfied by some errors returned by a "key: value" parser.
type ReaderOptions ¶
type ReaderOptions struct { Template record.Record // Specifies the value types. AllowDuplicateKeys bool // If true, duplicate keys are allowed, with only the most recently read value appearing in the read record. AllowEmptyKeys bool // If true, allow the read record to have empty keys. AllowMissingKeys bool // If true, allow read records not to have all the keys in Template; that is, there may be keys in Template that are missing from the read record. AllowUnknownKeys bool // If true, allow read records to have keys not in Template; that is, there may be keys in the read record that are missing from Template. The type of the associated value will be a string. Note that if IgnoreUnknownKeys is true then AllowUnknownKeys is ignored. IgnoreUnknownKeys bool // If true, ignore any keys not in Template; that is, any keys not in Template will be skipped and will be omitted from the read record. Note that IgnoreUnknownKeys takes priority over AllowUnknownKeys. }
ReaderOptions specified options for a reader.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table provides a database connection.
func (*Table) AddIndex ¶
AddIndex adds an index on the given key. If an index already exists, this index is unmodified and nil is returned.
func (*Table) AddKey ¶ added in v0.1.29
AddKey updates each record r in t, adding the given key-value pair if key is not already present in r.
func (*Table) AddKeys ¶ added in v0.1.29
AddKeys updates each record r in t, adding any keys in rec that are not already present along with the corresponding values. Any keys that are already present in r will be left unmodified.
func (*Table) AddUniqueIndex ¶
AddUniqueIndex adds an index on the given key and the constraint that, for each value of this key, there is at most one record with that value. This operation may fail if there is an existing index on that key, and will fail if the existing values in the table do not satisfy the uniqueness constraint.
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) DeleteIndex ¶
DeleteIndex deletes the index on the given key. If no index is present, nil is returned.
func (*Table) DeleteKey ¶ added in v0.1.29
DeleteKey updates each record r in t, deleting the specified key if present.
func (*Table) DeleteKeys ¶ added in v0.1.29
DeleteKeys updates each record r in t, deleting all the specified keys if present.
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) InsertRecords ¶
InsertRecords inserts the given records into the table.
func (*Table) ListIndices ¶
ListIndices lists the keys for which indices are present.
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) 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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
kvdbdriver
Package kvdbdriver implements the kvdb keyvalue driver.
|
Package kvdbdriver implements the kvdb keyvalue driver. |
Package mongodb implements the keyvalue interfaces when working with mongodb.
|
Package mongodb implements the keyvalue interfaces when working with mongodb. |
Package parse defines a parser for parsing SQL-formatted queries.
|
Package parse defines a parser for parsing SQL-formatted queries. |
Package postgres implements the keyvalue interfaces when working with PostgreSQL.
|
Package postgres implements the keyvalue interfaces when working with PostgreSQL. |