Documentation
¶
Overview ¶
Package data provides a data structure for defining simple database filters. This is not able to represent every imaginable query criteria, but it does a good job of making common criteria simple to format and pass around in your application.
Index ¶
Constants ¶
const OperatorEqual = "="
OperatorEqual represents an "equals" comparison, when used in Predicates and Criteria
const OperatorGreaterOrEqual = ">="
OperatorGreaterOrEqual represents an "equals" comparison, when used in Predicates and Criteria
const OperatorGreaterThan = ">"
OperatorGreaterThan represents an "equals" comparison, when used in Predicates and Criteria
const OperatorLessOrEqual = "<="
OperatorLessOrEqual represents an "equals" comparison, when used in Predicates and Criteria
const OperatorLessThan = "<"
OperatorLessThan represents an "equals" comparison, when used in Predicates and Criteria
const OperatorNotEqual = "!="
OperatorNotEqual represents an "equals" comparison, when used in Predicates and Criteria
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
Datastore is an abstract representation of a database and its connection information.
type Expression ¶
type Expression []struct {
Name string // The name of the field being compared
Operator string // The type of comparison (=, !=, >, >=, <, <=). If this value is empty string, it is assumed to be "="
Value interface{} // The value that the field is being compared to
}
Expression represents a comparison or filter, to be used when loading objects from the database. Each service and database driver is expected to use this common format for query criteria, and then map it into the specific format required for that database.
func (*Expression) Add ¶
func (exp *Expression) Add(name string, operator string, value interface{}) *Expression
Add appends a new predicate to an existing criteria expression.
func (Expression) Join ¶
func (exp Expression) Join(criteriaToCombine ...Expression) Expression
Join merges together the predicates of all provided criteria expressions, into a single criteria expression.
func (Expression) Match ¶
func (exp Expression) Match(object interface{}) bool
Match uses reflection to compare this expression with an arbitrary struct. It is included here to simplify testing and development, but should not be used for production-ready code.
type Object ¶
type Object interface {
// ID returns the primary key of the object
ID() string
// IsNew returns TRUE if the object has not yet been saved to the database
IsNew() bool
// SetCreated stamps the CreateDate and UpdateDate of the object, and makes a note
SetCreated(comment string)
// SetUpdated stamps the UpdateDate of the object, and makes a note
SetUpdated(comment string)
// SetDeleted marks the object virtually "deleted", and makes a note
SetDeleted(comment string)
}
Object interface defines all of the methods that a Domain Object must provide to Presto
type Predicate ¶
type Predicate struct {
Name string // The name of the field being compared
Operator string // The type of comparison (=, !=, >, >=, <, <=). If this value is empty string, it is assumed to be "="
Value interface{} // The value that the field is being compared to
}
Predicate represents a single expression, such as [name = "John Connor"]
type Session ¶
type Session interface {
Load(collection string, filter Expression, target Object) *derp.Error
Save(collection string, object Object, note string) *derp.Error
Delete(collection string, object Object, note string) *derp.Error
Close()
}
Session represents a single database session, that is opened to support a single transactional request, and then closed when this transaction is complete