Documentation ¶
Overview ¶
Package db holds the database layer for the Proxeus core
Index ¶
- func NotFound(err error) bool
- type DB
- type GetOptions
- type MongoQuery
- func (q *MongoQuery) Each(kind interface{}, fn func(interface{}) error) error
- func (q *MongoQuery) Find(to interface{}) error
- func (q *MongoQuery) First(to interface{}) error
- func (q *MongoQuery) Limit(i int) Query
- func (q *MongoQuery) OrderBy(str ...string) Query
- func (q *MongoQuery) Reverse() Query
- func (q *MongoQuery) Skip(i int) Query
- type MongoShim
- func (s *MongoShim) All(to interface{}) error
- func (s *MongoShim) Begin(_ bool) (DB, error)
- func (s *MongoShim) Close() error
- func (s *MongoShim) Commit() error
- func (s *MongoShim) Count(data interface{}) (int, error)
- func (s *MongoShim) Delete(bucketName string, key interface{}) error
- func (s *MongoShim) DeleteStruct(data interface{}) error
- func (s *MongoShim) Get(bucketName string, key interface{}, to interface{}, opts ...*GetOptions) error
- func (s *MongoShim) Init(data interface{}) error
- func (s *MongoShim) One(fieldName string, value interface{}, to interface{}) error
- func (s *MongoShim) ReIndex(data interface{}) error
- func (s *MongoShim) Rollback() error
- func (s *MongoShim) Save(data interface{}) error
- func (s *MongoShim) Select(matchers ...q.Matcher) Query
- func (s *MongoShim) Set(bucketName string, key interface{}, value interface{}, opts ...*SetOptions) error
- func (s *MongoShim) Update(data interface{}) error
- func (s *MongoShim) WithBatch(enabled bool) DB
- type Query
- type SetOptions
- type StormQueryShim
- func (s StormQueryShim) Each(kind interface{}, fn func(interface{}) error) error
- func (s StormQueryShim) Find(to interface{}) error
- func (s StormQueryShim) First(to interface{}) error
- func (s StormQueryShim) Limit(i int) Query
- func (s StormQueryShim) OrderBy(str ...string) Query
- func (s StormQueryShim) Reverse() Query
- func (s StormQueryShim) Skip(i int) Query
- type StormShim
- func (s *StormShim) All(to interface{}) error
- func (s *StormShim) Begin(writable bool) (DB, error)
- func (s *StormShim) Close() error
- func (s *StormShim) Commit() error
- func (s *StormShim) Count(data interface{}) (int, error)
- func (s *StormShim) Delete(bucketName string, key interface{}) error
- func (s *StormShim) DeleteStruct(data interface{}) error
- func (s *StormShim) Get(bucketName string, key interface{}, to interface{}, opts ...*GetOptions) error
- func (s *StormShim) Init(data interface{}) error
- func (s *StormShim) One(fieldName string, value interface{}, to interface{}) error
- func (s *StormShim) ReIndex(data interface{}) error
- func (s *StormShim) Rollback() error
- func (s *StormShim) Save(data interface{}) error
- func (s *StormShim) Select(matchers ...q.Matcher) Query
- func (s *StormShim) Set(bucketName string, key interface{}, value interface{}, opts ...*SetOptions) error
- func (s *StormShim) Update(data interface{}) error
- func (s *StormShim) WithBatch(enabled bool) DB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB interface { // Get a value from a bucket Get(bucketName string, key interface{}, to interface{}, opts ...*GetOptions) error // Set a key/value pair into a bucket Set(bucketName string, key interface{}, value interface{}, opts ...*SetOptions) error // Delete deletes a key from a bucket Delete(bucketName string, key interface{}) error // Begin starts a new transaction Begin(writable bool) (DB, error) // WithBatch returns a new Node with the batch mode enabled. WithBatch(enabled bool) DB // Rollback rolls back the transaction Rollback() error // Commit commits the transaction Commit() error // Select a list of records that match a list of matchers. Select(matchers ...q.Matcher) Query // Init creates the indexes and buckets for a given structure Init(data interface{}) error // ReIndex rebuilds all the indexes of a bucket ReIndex(data interface{}) error // Save a structure Save(data interface{}) error // Update a structure Update(data interface{}) error // DeleteStruct deletes a structure from the associated bucket DeleteStruct(data interface{}) error // One returns one record by the specified index One(fieldName string, value interface{}, to interface{}) error // Count all the matching records Count(data interface{}) (int, error) // All gets all the records of a bucket. If there are no records it returns no error and the 'to' parameter is set to an empty slice. All(to interface{}) error Close() error }
DB represents common set of the db API.
func OpenDatabase ¶
OpenDatabase returns a handle to the respective database chosen by the engine specified
type GetOptions ¶
type GetOptions struct {
NoTTLRefresh bool
}
func OptionWithNoTTLRefresh ¶
func OptionWithNoTTLRefresh() *GetOptions
type MongoQuery ¶
type MongoQuery struct {
// contains filtered or unexported fields
}
func (*MongoQuery) Each ¶
func (q *MongoQuery) Each(kind interface{}, fn func(interface{}) error) error
Execute the given function for each element
func (*MongoQuery) Find ¶
func (q *MongoQuery) Find(to interface{}) error
Find a list of matching records
func (*MongoQuery) First ¶
func (q *MongoQuery) First(to interface{}) error
First gets the first matching record
func (*MongoQuery) Limit ¶
func (q *MongoQuery) Limit(i int) Query
Limit the results by the given number
func (*MongoQuery) OrderBy ¶
func (q *MongoQuery) OrderBy(str ...string) Query
Order by the given fields, in descending precedence, left-to-right.
func (*MongoQuery) Skip ¶
func (q *MongoQuery) Skip(i int) Query
Skip matching records by the given number
type MongoShim ¶
type MongoShim struct {
// contains filtered or unexported fields
}
func OpenMongo ¶
OpenMongo connects to the database using the specified URI and database name and returns a handle for accessing it
func (*MongoShim) All ¶
All gets all the records of a bucket. If there are no records it returns no error and the 'to' parameter is set to an empty slice.
func (*MongoShim) DeleteStruct ¶
DeleteStruct deletes a structure from the associated bucket
func (*MongoShim) Get ¶
func (s *MongoShim) Get(bucketName string, key interface{}, to interface{}, opts ...*GetOptions) error
Get a value from a bucket
func (*MongoShim) Select ¶
Select a list of records that match a list of matchers. Doesn't use indexes.
type Query ¶
type Query interface { // Skip matching records by the given number Skip(int) Query // Limit the results by the given number Limit(int) Query // Order by the given fields, in descending precedence, left-to-right OrderBy(str ...string) Query // Reverse the order of the results Reverse() Query // Find a list of matching records Find(to interface{}) error // First gets the first matching record First(to interface{}) error // Execute the given function for each element Each(kind interface{}, fn func(interface{}) error) error }
Query allows to operate searches.
type SetOptions ¶
func OptionWithTTL ¶
func OptionWithTTL(ttl time.Duration) *SetOptions
type StormQueryShim ¶
type StormQueryShim struct {
// contains filtered or unexported fields
}
func (StormQueryShim) Each ¶
func (s StormQueryShim) Each(kind interface{}, fn func(interface{}) error) error
Execute the given function for each element
func (StormQueryShim) Find ¶
func (s StormQueryShim) Find(to interface{}) error
Find a list of matching records
func (StormQueryShim) First ¶
func (s StormQueryShim) First(to interface{}) error
First gets the first matching record
func (StormQueryShim) Limit ¶
func (s StormQueryShim) Limit(i int) Query
Limit the results by the given number
func (StormQueryShim) OrderBy ¶
func (s StormQueryShim) OrderBy(str ...string) Query
Order by the given fields, in descending precedence, left-to-right
func (StormQueryShim) Reverse ¶
func (s StormQueryShim) Reverse() Query
Reverse the order of the results
func (StormQueryShim) Skip ¶
func (s StormQueryShim) Skip(i int) Query
Skip matching records by the given number
type StormShim ¶
type StormShim struct {
// contains filtered or unexported fields
}
func OpenStorm ¶
OpenStorm opens a connection to the Storm database at the location specified by its path and returns a handle
func (*StormShim) All ¶
All gets all the records of a bucket. If there are no records it returns no error and the 'to' parameter is set to an empty slice.
func (*StormShim) DeleteStruct ¶
DeleteStruct deletes a structure from the associated bucket
func (*StormShim) Get ¶
func (s *StormShim) Get(bucketName string, key interface{}, to interface{}, opts ...*GetOptions) error
Get a value from a bucket
func (*StormShim) Select ¶
Select a list of records that match a list of matchers. Doesn't use indexes.