Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { // CreateIfNotExists creates the storage object in the database if it // doesn't already exist CreateIfNotExists(ctx context.Context, e base.Object) error // Create creates the storage object in the database Create(ctx context.Context, e base.Object) error // Get gets the storage object from the database Get(ctx context.Context, e base.Object, fieldsToRead ...string) ( map[string]interface{}, error) // GetAll gets all the storage objects for the partition key from the // database GetAll(ctx context.Context, e base.Object) ([]map[string]interface{}, error) // GetAllIter provides an iterative way to fetch all storage objects // for the partition key GetAllIter(ctx context.Context, e base.Object) (Iterator, error) // Update updates the storage object in the database // The fields to be updated can be specified as fieldsToUpdate which is // a variable list of field names and is to be optionally specified by // the caller. If not specified, all fields in the object will be updated // to the DB Update(ctx context.Context, e base.Object, fieldsToUpdate ...string) error // Delete deletes the storage object from the database Delete(ctx context.Context, e base.Object) error }
Client defines the methods to operate with storage objects
type Connector ¶
type Connector interface { // CreateIfNotExists creates a row in the DB for the base object if it // doesn't already exist CreateIfNotExists( ctx context.Context, e *base.Definition, values []base.Column, ) error // Create creates a row in the DB for the base object Create(ctx context.Context, e *base.Definition, values []base.Column) error // Get fetches a row by primary key of base object Get( ctx context.Context, e *base.Definition, keys []base.Column, colNamesToRead ...string, ) (map[string]interface{}, error) // GetAll fetches a list of base objects for the partition key // and the given clustering keys GetAll( ctx context.Context, e *base.Definition, keys []base.Column, ) ([]map[string]interface{}, error) GetAllIter( ctx context.Context, e *base.Definition, keys []base.Column, ) (Iterator, error) // Update updates a row in the DB for the base object Update( ctx context.Context, e *base.Definition, values []base.Column, keys []base.Column, ) error // Delete deletes a row from the DB for the base object Delete(ctx context.Context, e *base.Definition, keys []base.Column) error }
Connector is the interface that must be implemented for a backend service
type Iterator ¶
type Iterator interface { // Next fetches the next row of the result. On reaching the end of // results, it returns nil. Error is returned if there is a failure // during iteration. Next should not be called once error is returned // or Close is called. Next() ([]base.Column, error) // Close indicates that iterator is no longer required and so any // clean-up actions may be performed. Close() }
Iterator allows the caller to iterate over the results of a query.
type Table ¶
type Table struct { base.Definition // map from DB column name -> object field name ColToField map[string]string // map of base field name to DB column name FieldToCol map[string]string }
Table is an ORM internal representation of storage object. Storage object is translated into Definition that contains the primary key information as well as column to datatype map It also contains maps used to translate storage object fields into DB columns and viceversa and this is used during read and write operations
func TableFromObject ¶
TableFromObject creates a orm.Table from a storage.Object instance.
func (*Table) GetKeyRowFromObject ¶
GetKeyRowFromObject is a helper for generating a row of partition and clustering key column values to be used in a select query.
func (*Table) GetPartitionKeyRowFromObject ¶
GetPartitionKeyRowFromObject is a helper for generating a row of partition key column values to be used in a GetAll query.
func (*Table) GetRowFromObject ¶
GetRowFromObject is a helper for generating a row from the storage object selectedFields will be used to restrict the number of columns in that row This will be used to convert only select fields of an object to a row. selectedFields if empty will be ignored. It will be empty in case this function is called when handling Create operation since in that case, all fields of the object must be converted to a row. Update can be used to update specific fields of the object