base

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFromOptionalToRawType

func ConvertFromOptionalToRawType(value reflect.Value) interface{}

ConvertFromOptionalToRawType returns an interface of raw type understandable by the DB layer, extracted from a custom optional type Currently only support OptionalString, OptionalUInt64 type, but can be extended for additional optional types

func ConvertFromRawToOptionalType

func ConvertFromRawToOptionalType(value reflect.Value,
	typ reflect.Type) reflect.Value

ConvertFromRawToOptionalType returns a value representing an optional type built from the raw type fetched from DB

func IsOfTypeOptional

func IsOfTypeOptional(value reflect.Value) bool

IsOfTypeOptional returns whether a value is of type custom optional Currently only support OptionalString, OptionalUInt64 type, but can be extended for additional optional types

Types

type ClusteringKey

type ClusteringKey struct {
	// Name of the clustering key
	Name string
	// Clustering order
	Descending bool
}

ClusteringKey stores name and ordering of a clustering key

type Column

type Column struct {
	// Name of the column
	Name string
	// Value of the column
	Value interface{}
}

Column holds a column name and value for one row.

type Definition

type Definition struct {
	// normalized object name
	Name string
	// Primary key of the object
	Key *PrimaryKey
	// Column name to data type mapping of the object
	ColumnToType map[string]reflect.Type
}

Definition stores schema information about an Object

func (*Definition) GetColumnsToRead

func (o *Definition) GetColumnsToRead() []string

GetColumnsToRead returns a list of column names to be read for this object in a select operation

type Object

type Object interface {
	// contains filtered or unexported methods
}

Object is a marker interface method that is used to add connector specific annotations to storage objects. Users can embed this interface in any storage object structure definition.

For example: ValidObject is a representation of the orm annotations

type ValidObject struct {
	base.Object `cassandra:"name=valid_object, primaryKey=((id), name)"`
	ID          uint64 `column:"name=id"`
	Name        string `column:"name=name"`
	Data        string `column:"name=data"`
}

Here, base.Object is embedded in a ValidObject just to specify cassandra specific annotations that describe the primary key information as well as table name of that object. The partition key is `id` and clustering key is `name` while table name is `valid_object`.

The `cassandra` keyword denotes that this annotation is for Cassandra connector. The only primary key format supported right now is: ((PK1,PK2..), CK1, CK2..)

type OptionalString

type OptionalString struct {
	Value string
}

OptionalString type can be used for primary key of type string to be evaluated as either nil or some string value different than empty string

func NewOptionalString

func NewOptionalString(v interface{}) *OptionalString

NewOptionalString returns either new *OptionalString or nil

func (*OptionalString) String

func (s *OptionalString) String() string

String for *OptionalString type

type OptionalUInt64

type OptionalUInt64 struct {
	Value uint64
}

OptionalUInt64 type can be used for primary key of type uint64 to be evaluated as either nil or some uint64 value different than empty uint64

func NewOptionalUInt64

func NewOptionalUInt64(v interface{}) *OptionalUInt64

NewOptionalUInt64 returns either new *OptionalUInt64 or nil

func (*OptionalUInt64) UInt64

func (s *OptionalUInt64) UInt64() uint64

UInt64 for *OptionalUInt64 type

type PrimaryKey

type PrimaryKey struct {
	// List of partition key names
	PartitionKeys []string
	// List of clustering key objects (clustering key name and order)
	ClusteringKeys []*ClusteringKey
}

PrimaryKey stores information about partition keys and clustering keys

Jump to

Keyboard shortcuts

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