# README
SQL-like datastore
The sql
package defines the API for accessing a data store using SQL.
The Broker
interface allows reading and manipulating with data.
The Watcher
API provides functions for monitoring of changes
in a data store.
Features
- The user of the API has full control over the SQL statements,
types & bindings passed to the
Broker
. - Expressions:
- Helper functions alleviate the need to write SQL strings.
- The user can choose to only write expressions using helper functions
- The user can write portions of SQL statements by a hand
(the
sql.Exp
helper function) and combine them with other expressions
- The user can optionally use reflection to simplify repetitive work with Iterators & Go structures
- The API will be reused for different databases. A specific implementation will be provided for each database.
# Packages
Package cassandra is the implementation of the SQL Data Broker client API for the Cassandra data store.
# Functions
AND keyword of SQL expression
Example usage (alternative 1 - spare sequence of partenthesis):
WHERE(FieldEQ(&JamesBond.FirstName), AND(), FieldEQ(&JamesBond.LastName))
Example usage (alternative 2 - useful for nesting):
WHERE(AND(FieldEQ(&JamesBond.FirstName), FieldEQ(&JamesBond.LastName))).
DELETE keyword of an SQL statement.
EntityTableName returns the table name, possibly prefixed with the schema name, associated with the <entity>.
EQ operator "=" used in SQL expressions.
Exp function creates instance of sql.Expression from string statement & optional binding.
ExpsToString joins (without separator) individual expression string representations.
Field is a helper function to address field of a structure.
FieldEQ is combination of Field & EQ on the same pointerToAField.
FROM keyword of an SQL expression.
GT operator ">" used in SQL expressions.
GTE operator "=>" used in SQL expressions.
IN operator of SQL expression FROM(UserTable,WHERE(FieldEQ(&UserTable.FirstName, IN(JamesBond.FirstName, PeterBond.FirstName))).
LT operator "<" used in SQL expressions.
LTE operator "=<" used in SQL expressions.
OR keyword of SQL expression
Example usage 1 (generated string does not contain parenthesis surrounding OR):
WHERE(FieldEQ(&PeterBond.FirstName), OR(), FieldEQ(&JamesBond.FirstName))
Example usage 2 (generated string does not contain parenthesis surrounding OR):
WHERE(FieldEQ(&PeterBond.LastName), OR(FieldEQ(&PeterBond.FirstName), FieldEQ(&JamesBond.FirstName)))
.
Parenthesis expression that surrounds "inside Expression" with "(" and ")".
PK is alias FieldEQ (user for better readability)
Example usage: FROM(JamesBond, Where(PK(&JamesBond.LastName)) // generates, for example, "WHERE last_name='Bond'" // because JamesBond is a pointer to an instance of a structure that in field LastName contains "Bond".
SELECT keyword of an SQL expression.
SliceIt reads everything from the ValIterator and stores it to pointerToASlice.
ToChan TODO (not implemented yet).
WHERE keyword of an SQL statement.
# Structs
FieldExpression is used for addressing field of an entity in an SQL expression.
PrefixedExp covers many SQL constructions.
# Interfaces
Broker executes SQL statements in the data store.
BrokerPlugin provides unifying interface for different SQL-like datastore implementations.
Expression represents part of SQL statement and optional binding ("?").
SchemaName interface specifies custom schema name for SQL statements.
TableName interface specifies custom table name for SQL statements.
Txn allows to group operations into the transaction or batch (depending on a particular data store).
ValIterator is an iterator returned by ListValues call.
Visitor is used for traversing an expression tree.
Watcher defines API for monitoring changes in a datastore.
WatchResp represents a notification about change.