Documentation ¶
Index ¶
- Constants
- Variables
- func EscapeSearch(str string) string
- type AdminOperation
- type AdvancedError
- type Collection
- func (collection *Collection) ConfigureRevisions(ctx context.Context, config *api.RevisionConfig) error
- func (collection *Collection) Delete(ctx context.Context, model Model) error
- func (collection *Collection) Enforce(enforcer Enforcer) *Collection
- func (collection *Collection) Exists(ctx context.Context, id string) (bool, error)
- func (collection *Collection) Get(ctx context.Context, id string, dest interface{}, opts ...IncludeOption) error
- func (collection *Collection) GetMulti(ctx context.Context, ids []string, dest interface{}, opts ...IncludeOption) error
- func (collection *Collection) Put(ctx context.Context, model Model) error
- func (collection *Collection) TryGet(ctx context.Context, id string, model interface{}, opts ...IncludeOption) error
- type ConfigureExpirationOperation
- type Counter
- type Credentials
- type Database
- func (db *Database) Collection(golden Model) *Collection
- func (db *Database) ConfigureDefaultRevisions(ctx context.Context, config *api.RevisionConfig) error
- func (db *Database) Create(ctx context.Context, replicationFactor int64) error
- func (db *Database) CreateIndex(ctx context.Context, name string, index Index) error
- func (db *Database) Descriptor(ctx context.Context) (*api.Database, error)
- func (db *Database) Exists(ctx context.Context) (bool, error)
- func (db *Database) Maintenance(ctx context.Context, operations ...AdminOperation) error
- func (db *Database) NewSession(ctx context.Context) (context.Context, *Session)
- func (db *Database) Patch(ctx context.Context, query *RQLQuery) (*Operation, error)
- func (db *Database) QueryIndex(index string, golden Model) *Query
- func (db *Database) RQLQuery(query *RQLQuery) *DirectQuery
- func (db *Database) UpsertIdentity(ctx context.Context, name string, value int64) error
- type Date
- type DateTime
- type DirectQuery
- func (q *DirectQuery) Checksum() uint32
- func (q *DirectQuery) Clone() *DirectQuery
- func (q *DirectQuery) ForceStrongConsistency() *DirectQuery
- func (q *DirectQuery) GetAll(ctx context.Context, dest interface{}) error
- func (q *DirectQuery) RQL() (string, map[string]interface{})
- func (q *DirectQuery) Stats() QueryStats
- func (q *DirectQuery) String() string
- type Enforcer
- type FieldIndexing
- type IncludeOption
- type Index
- type IndexModel
- type Model
- type ModelEnforcer
- type ModelMetadata
- type ModelTracking
- type MultiError
- type OpenOption
- type Operation
- type OperationProgress
- type Params
- type Query
- func (q *Query) Checksum() uint32
- func (q *Query) Clone() *Query
- func (q *Query) Count(ctx context.Context) (int64, error)
- func (q *Query) DeleteEverything(ctx context.Context) error
- func (q *Query) Filter(field string, value interface{}) *Query
- func (q *Query) FilterBetween(field string, start, end interface{}) *Query
- func (q *Query) FilterContainsAll(field string, values ...interface{}) *Query
- func (q *Query) FilterEndsWith(field, suffix string) *Query
- func (q *Query) FilterHasField(field string) *Query
- func (q *Query) FilterIn(field string, values ...interface{}) *Query
- func (q *Query) FilterNotExact(field string, value interface{}) *Query
- func (q *Query) FilterSearch(field, search string, opts ...SearchOption) *Query
- func (q *Query) FilterStartsWith(field, prefix string) *Query
- func (q *Query) FilterSub(filters ...QueryFilter) *Query
- func (q *Query) First(ctx context.Context, dest interface{}, opts ...IncludeOption) error
- func (q *Query) ForceStrongConsistency() *Query
- func (q *Query) GetAll(ctx context.Context, dest interface{}, opts ...IncludeOption) error
- func (q *Query) GetAllIDs(ctx context.Context) ([]string, error)
- func (q *Query) GetAllMetadata(ctx context.Context) ([]ModelMetadata, error)
- func (q *Query) HasResults(ctx context.Context) (bool, error)
- func (q *Query) Limit(limit int64) *Query
- func (q *Query) Offset(offset int64) *Query
- func (q *Query) OrderBy(field string) *Query
- func (q *Query) OrderByAlpha(field string) *Query
- func (q *Query) OrderByAlphaNumeric(field string) *Query
- func (q *Query) OrderByNumeric(field string) *Query
- func (q *Query) Project(golden interface{}, fields ...string) *Query
- func (q *Query) RQL() (string, map[string]interface{})
- func (q *Query) RandomOrder() *Query
- func (q *Query) Select(fields ...string) *Query
- func (q *Query) Stats() QueryStats
- func (q *Query) String() string
- type QueryEnforcer
- type QueryFilter
- func And(children ...QueryFilter) QueryFilter
- func Filter(field string, value interface{}) QueryFilter
- func FilterBetween(field string, start, end interface{}) QueryFilter
- func FilterContainsAll(field string, values ...interface{}) QueryFilter
- func FilterEndsWith(field, suffix string) QueryFilter
- func FilterHasField(field string) QueryFilter
- func FilterIn(field string, values ...interface{}) QueryFilter
- func FilterNotExact(field string, value interface{}) QueryFilter
- func FilterSearch(field, search string, opts ...SearchOption) QueryFilter
- func FilterStartsWith(field, prefix string) QueryFilter
- func Or(children ...QueryFilter) QueryFilter
- type QueryStats
- type RQLQuery
- type SearchOption
- type Session
- type UnexpectedStatusError
Constants ¶
const ( FieldIndexingExact = "Exact" FieldIndexingSearch = "Search" )
const SearchOptionAnd = SearchOption("and")
const SearchOptionOr = SearchOption("or")
Variables ¶
Functions ¶
func EscapeSearch ¶
Types ¶
type AdminOperation ¶ added in v1.87.0
type AdminOperation interface { URL() string Body() interface{} }
type AdvancedError ¶
type AdvancedError struct { URL string `json:"Url"` Type string Message string Stack string `json:"Error"` }
func (*AdvancedError) Error ¶
func (err *AdvancedError) Error() string
type Collection ¶
type Collection struct { *Query // contains filtered or unexported fields }
func (*Collection) ConfigureRevisions ¶
func (collection *Collection) ConfigureRevisions(ctx context.Context, config *api.RevisionConfig) error
ConfigureRevisions for this collection to store every change.
func (*Collection) Delete ¶
func (collection *Collection) Delete(ctx context.Context, model Model) error
func (*Collection) Enforce ¶
func (collection *Collection) Enforce(enforcer Enforcer) *Collection
func (*Collection) Get ¶
func (collection *Collection) Get(ctx context.Context, id string, dest interface{}, opts ...IncludeOption) error
Get fetchs an entity by its ID. If it doesn't exists or it's enforced it returns ErrNoSuchEntity.
func (*Collection) GetMulti ¶
func (collection *Collection) GetMulti(ctx context.Context, ids []string, dest interface{}, opts ...IncludeOption) error
GetMulti fetches multiple models. If one of them doesn't exists it will return ErrNoSuchEntity.
func (*Collection) TryGet ¶
func (collection *Collection) TryGet(ctx context.Context, id string, model interface{}, opts ...IncludeOption) error
TryGet tries to fetch the entity, but returns successfully even if it doesn't exist. The model will be untouched in case it doesn't exists.
type ConfigureExpirationOperation ¶ added in v1.87.0
func DisableExpiration ¶ added in v1.87.0
func DisableExpiration() *ConfigureExpirationOperation
func EnableExpiration ¶ added in v1.87.0
func EnableExpiration() *ConfigureExpirationOperation
func (*ConfigureExpirationOperation) Body ¶ added in v1.87.0
func (op *ConfigureExpirationOperation) Body() interface{}
func (*ConfigureExpirationOperation) SetFrequency ¶ added in v1.87.0
func (op *ConfigureExpirationOperation) SetFrequency(freq int)
func (*ConfigureExpirationOperation) URL ¶ added in v1.87.0
func (op *ConfigureExpirationOperation) URL() string
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
type Credentials ¶ added in v1.94.0
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func OpenCredentials ¶ added in v1.94.0
func OpenCredentials(credentials Credentials, dbname string, opts ...OpenOption) (*Database, error)
func OpenSecret ¶ added in v1.94.0
func (*Database) Collection ¶
func (db *Database) Collection(golden Model) *Collection
func (*Database) ConfigureDefaultRevisions ¶
func (db *Database) ConfigureDefaultRevisions(ctx context.Context, config *api.RevisionConfig) error
ConfigureDefaultRevisions for all the collections of this database storing every change.
func (*Database) CreateIndex ¶
func (*Database) Descriptor ¶
func (*Database) Maintenance ¶ added in v1.87.0
func (db *Database) Maintenance(ctx context.Context, operations ...AdminOperation) error
Maintenance sends admin operations to the server one by one.
func (*Database) NewSession ¶
func (*Database) RQLQuery ¶
func (db *Database) RQLQuery(query *RQLQuery) *DirectQuery
type DirectQuery ¶
type DirectQuery struct {
// contains filtered or unexported fields
}
func (*DirectQuery) Checksum ¶
func (q *DirectQuery) Checksum() uint32
Checksum returns a checksum of the filters, conditions, table name, ... and other internal data of the collection that identifies it.
func (*DirectQuery) Clone ¶
func (q *DirectQuery) Clone() *DirectQuery
func (*DirectQuery) ForceStrongConsistency ¶
func (q *DirectQuery) ForceStrongConsistency() *DirectQuery
func (*DirectQuery) GetAll ¶
func (q *DirectQuery) GetAll(ctx context.Context, dest interface{}) error
func (*DirectQuery) RQL ¶
func (q *DirectQuery) RQL() (string, map[string]interface{})
func (*DirectQuery) Stats ¶
func (q *DirectQuery) Stats() QueryStats
Stats return general statistics about the query AFTER it is performed. Calling it before retrieving results would return a nil value.
func (*DirectQuery) String ¶
func (q *DirectQuery) String() string
type Enforcer ¶
type Enforcer struct { Model ModelEnforcer Query QueryEnforcer }
type FieldIndexing ¶
type FieldIndexing string
type IncludeOption ¶
type IncludeOption func(cnf *includesConfig)
func Include ¶
func Include(includes ...string) IncludeOption
func IncludeAllCounters ¶
func IncludeAllCounters() IncludeOption
type IndexModel ¶
type IndexModel struct { }
func (*IndexModel) ChangeVector ¶
func (model *IndexModel) ChangeVector() string
func (*IndexModel) Collection ¶
func (model *IndexModel) Collection() string
func (*IndexModel) Tracking ¶ added in v1.87.0
func (model *IndexModel) Tracking() *ModelTracking
type Model ¶
type Model interface { // To be implemented by the model struct. It should return the name of the // collection like "Users" or "Sites". Collection() string // Returns the change vector associated to the model when it was last // retrieved from the server. Automatically implemented with rdb.ModelTracking. // Deprecated: Use Tracking().ChangeVector() instead. ChangeVector() string // Returns tracking info like expiration or change vector. // Automatically implemented with rdb.ModelTracking. Tracking() *ModelTracking // contains filtered or unexported methods }
type ModelEnforcer ¶
type ModelMetadata ¶
type ModelMetadata = api.ModelMetadata
type ModelTracking ¶
type ModelTracking struct {
// contains filtered or unexported fields
}
func (*ModelTracking) ChangeVector ¶
func (tracking *ModelTracking) ChangeVector() string
func (*ModelTracking) Expire ¶ added in v1.87.0
func (tracking *ModelTracking) Expire(t time.Time)
func (*ModelTracking) Expires ¶ added in v1.87.0
func (tracking *ModelTracking) Expires() time.Time
func (*ModelTracking) NeverExpire ¶ added in v1.87.0
func (tracking *ModelTracking) NeverExpire()
func (*ModelTracking) Tracking ¶ added in v1.87.0
func (tracking *ModelTracking) Tracking() *ModelTracking
type MultiError ¶
type MultiError []error
MultiError stores a list of error when retrieving multiple models and only some of them may fail.
func (MultiError) Error ¶
func (merr MultiError) Error() string
func (MultiError) HasError ¶
func (merr MultiError) HasError() bool
HasError returns if the multi error really contains any error or all the rows have been successfully retrieved. You don't have to check this method most of the time because GetMulti, GetAll, etc. will return nil if there is no errors instead of an empty MultiError to avoid hard to debug bugs.
type OpenOption ¶
type OpenOption func(db *Database)
func WithLocalCreate ¶
func WithLocalCreate() OpenOption
WithLocalCreate creates automatically the database if it doesn't exists. It can only be used in a local environment as it applies a pretty large hit to performance.
func WithStrongConsistency ¶
func WithStrongConsistency() OpenOption
WithStrongConsistency forces every query to wait for the index to be ready and with no pending indexing operations.
This is probably only needed in tests and other rapidly changing environments, but not a normal production application.
func WithTestingMode ¶
func WithTestingMode(t *testing.T) OpenOption
WithTestingMode enables flags and behaviours suited for unit tests. It implies WithLocalCreate() and WithStrongConsistency() and also creates a new database for each package tests.
We don't use the argument, but we require it to avoid errors when calling this function outside tests.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
type OperationProgress ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) Checksum ¶
Checksum returns a checksum of the filters, conditions, table name, ... and other internal data of the collection that identifies it.
func (*Query) FilterBetween ¶
func (*Query) FilterContainsAll ¶
func (*Query) FilterEndsWith ¶
func (*Query) FilterHasField ¶
func (*Query) FilterNotExact ¶
func (*Query) FilterSearch ¶
func (q *Query) FilterSearch(field, search string, opts ...SearchOption) *Query
func (*Query) FilterStartsWith ¶
func (*Query) FilterSub ¶
func (q *Query) FilterSub(filters ...QueryFilter) *Query
func (*Query) First ¶
func (q *Query) First(ctx context.Context, dest interface{}, opts ...IncludeOption) error
func (*Query) ForceStrongConsistency ¶
func (*Query) GetAll ¶
func (q *Query) GetAll(ctx context.Context, dest interface{}, opts ...IncludeOption) error
func (*Query) GetAllMetadata ¶
func (q *Query) GetAllMetadata(ctx context.Context) ([]ModelMetadata, error)
func (*Query) OrderByAlpha ¶
func (*Query) OrderByAlphaNumeric ¶
func (*Query) OrderByNumeric ¶
func (*Query) RandomOrder ¶
func (*Query) Stats ¶
func (q *Query) Stats() QueryStats
Stats return general statistics about the query AFTER it is performed. Calling it before retrieving results would return a nil value.
type QueryEnforcer ¶
type QueryFilter ¶
func And ¶
func And(children ...QueryFilter) QueryFilter
func Filter ¶
func Filter(field string, value interface{}) QueryFilter
func FilterBetween ¶
func FilterBetween(field string, start, end interface{}) QueryFilter
func FilterContainsAll ¶
func FilterContainsAll(field string, values ...interface{}) QueryFilter
func FilterEndsWith ¶
func FilterEndsWith(field, suffix string) QueryFilter
func FilterHasField ¶
func FilterHasField(field string) QueryFilter
func FilterIn ¶
func FilterIn(field string, values ...interface{}) QueryFilter
func FilterNotExact ¶
func FilterNotExact(field string, value interface{}) QueryFilter
func FilterSearch ¶
func FilterSearch(field, search string, opts ...SearchOption) QueryFilter
func FilterStartsWith ¶
func FilterStartsWith(field, prefix string) QueryFilter
func Or ¶
func Or(children ...QueryFilter) QueryFilter
type QueryStats ¶
type QueryStats struct { // Total number of results of the query or collection ignoring pagination. TotalResults int64 // Number of fake results skipped server side. This occurs during Distinct // queries and fan out indexes only. SkippedResults int64 // Duration server side in milliseconds. DurationInMs int64 // If the results are from an index, this flag tells us if the results // might be stale because the index was being rebuilt. IsStale bool // Name of the index or collection used to extract the results. IndexName string // Number of results of this page, or TotalResults if pagination // with Limit and Offset was not applied. ResultSize int64 }
type RQLQuery ¶
type RQLQuery struct {
// contains filtered or unexported fields
}
func NewRQLQuery ¶
type SearchOption ¶
type SearchOption string
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func SessionFromContext ¶
type UnexpectedStatusError ¶
type UnexpectedStatusError struct { RequestMethod string RequestURL *url.URL Status string StatusCode int Advanced *AdvancedError }
func NewUnexpectedStatusError ¶
func NewUnexpectedStatusError(r *http.Request, resp *http.Response) UnexpectedStatusError
func (UnexpectedStatusError) Error ¶
func (err UnexpectedStatusError) Error() string