Documentation ¶
Index ¶
- Variables
- func ReplaceObjectIds(data interface{}) (interface{}, error)
- type CursorIterator
- type Datasource
- func (ds *Datasource) Close() error
- func (ds *Datasource) Count(collectionName string, lookups *wst.A) (int64, error)
- func (ds *Datasource) Create(collectionName string, data *wst.M) (*wst.M, error)
- func (ds *Datasource) DeleteById(collectionName string, id interface{}) (DeleteResult, error)
- func (ds *Datasource) DeleteMany(collectionName string, whereLookups *wst.A) (result DeleteResult, err error)
- func (ds *Datasource) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
- func (ds *Datasource) Initialize() error
- func (ds *Datasource) SetTimeout(seconds float32)
- func (ds *Datasource) UpdateById(collectionName string, id interface{}, data *wst.M) (*wst.M, error)
- type DeleteResult
- type MemoryKVConnector
- func (connector *MemoryKVConnector) Connect(parentContext context.Context) error
- func (connector *MemoryKVConnector) Count(collectionName string, lookups *wst.A) (int64, error)
- func (connector *MemoryKVConnector) Create(collectionName string, data *wst.M) (*wst.M, error)
- func (connector *MemoryKVConnector) DeleteById(collectionName string, id interface{}) (DeleteResult, error)
- func (connector *MemoryKVConnector) DeleteMany(collectionName string, whereLookups *wst.A) (DeleteResult, error)
- func (connector *MemoryKVConnector) Disconnect() error
- func (connector *MemoryKVConnector) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
- func (connector *MemoryKVConnector) GetClient() interface{}
- func (connector *MemoryKVConnector) GetName() string
- func (connector *MemoryKVConnector) Ping(parentCtx context.Context) error
- func (connector *MemoryKVConnector) SetConfig(dsViper *viper.Viper)
- func (connector *MemoryKVConnector) SetTimeout(seconds float32)
- func (connector *MemoryKVConnector) UpdateById(collectionName string, id interface{}, data *wst.M) (*wst.M, error)
- type MongoCursorI
- type MongoDBConnector
- func (connector *MongoDBConnector) Connect(parentContext context.Context) error
- func (connector *MongoDBConnector) Count(collectionName string, lookups *wst.A) (int64, error)
- func (connector *MongoDBConnector) Create(collectionName string, data *wst.M) (*wst.M, error)
- func (connector *MongoDBConnector) DeleteById(collectionName string, id interface{}) (result DeleteResult, err error)
- func (connector *MongoDBConnector) DeleteMany(collectionName string, whereLookups *wst.A) (result DeleteResult, err error)
- func (connector *MongoDBConnector) Disconnect() error
- func (connector *MongoDBConnector) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
- func (connector *MongoDBConnector) GetClient() interface{}
- func (connector *MongoDBConnector) GetName() string
- func (connector *MongoDBConnector) Ping(parentCtx context.Context) error
- func (connector *MongoDBConnector) SetConfig(dsViper *viper.Viper)
- func (connector *MongoDBConnector) SetTimeout(seconds float32)
- func (connector *MongoDBConnector) UpdateById(collectionName string, id interface{}, data *wst.M) (*wst.M, error)
- type MongoDBDatasourceOptions
- type Options
- type PersistedConnector
Constants ¶
This section is empty.
Variables ¶
var ( RegexDaysAgo = regexp.MustCompile(`^\$(\d+)dago$`) RegexWeeksAgo = regexp.MustCompile(`^\$(\d+)wago$`) RegexMonthsAgo = regexp.MustCompile(`^\$(\d+)mago$`) RegexYearsAgo = regexp.MustCompile(`^\$(\d+)yago$`) RegexSecondsAgo = regexp.MustCompile(`^\$(\d+)Sago$`) RegexMinutesAgo = regexp.MustCompile(`^\$(\d+)Mago$`) RegexHoursAgo = regexp.MustCompile(`^\$(\d+)Hago$`) RegexDaysFromNow = regexp.MustCompile(`^\$(\d+)dfromnow$`) RegexWeeksFromNow = regexp.MustCompile(`^\$(\d+)wfromnow$`) RegexMonthsFromNow = regexp.MustCompile(`^\$(\d+)mfromnow$`) RegexYearsFromNow = regexp.MustCompile(`^\$(\d+)yfromnow$`) RegexSecondsFromNow = regexp.MustCompile(`^\$(\d+)Sfromnow$`) RegexMinutesFromNow = regexp.MustCompile(`^\$(\d+)Mfromnow$`) RegexHoursFromNow = regexp.MustCompile(`^\$(\d+)Hfromnow$`) )
Functions ¶
func ReplaceObjectIds ¶ added in v1.2.12
func ReplaceObjectIds(data interface{}) (interface{}, error)
Types ¶
type CursorIterator ¶ added in v1.6.0
type CursorIterator chan interface{}
type Datasource ¶
type Datasource struct { Name string Db interface{} Viper *viper.Viper Key string Context context.Context Options *Options SubViper *viper.Viper // contains filtered or unexported fields }
func (*Datasource) Close ¶ added in v1.6.13
func (ds *Datasource) Close() error
func (*Datasource) DeleteById ¶
func (ds *Datasource) DeleteById(collectionName string, id interface{}) (DeleteResult, error)
func (*Datasource) DeleteMany ¶ added in v1.6.13
func (ds *Datasource) DeleteMany(collectionName string, whereLookups *wst.A) (result DeleteResult, err error)
whereLookups is in the form of [
{ "$match": { "name": "John" } }
] and is used to filter the documents to delete. It cannot be nil or empty.
func (*Datasource) FindMany ¶
func (ds *Datasource) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
FindMany retrieves data from the specified collection based on the provided lookup conditions using the appropriate data source connector specified in the configuration file. @param collectionName string: the name of the collection from which to retrieve data. @param lookups *wst.A: a pointer to an array of conditions to be used as lookup criteria. If nil, all data in the collection will be returned. @return MongoCursorI: a cursor to the result set that matches the lookup criteria, or an error if an error occurs while attempting to retrieve the data. The cursor needs to be closed outside of the function. Implementations for Redis and memorykv connectors are not yet implemented and will result in an error.
func (*Datasource) Initialize ¶
func (ds *Datasource) Initialize() error
func (*Datasource) SetTimeout ¶ added in v1.6.14
func (ds *Datasource) SetTimeout(seconds float32)
func (*Datasource) UpdateById ¶
type DeleteResult ¶ added in v1.6.13
type DeleteResult struct { // DeletedCount is the number of documents deleted. DeletedCount int64 }
DeleteResult is the result of a DeleteMany operation.
type MemoryKVConnector ¶ added in v1.6.1
type MemoryKVConnector struct {
// contains filtered or unexported fields
}
MemoryKVConnector implements the PersistedConnector interface
func (*MemoryKVConnector) Connect ¶ added in v1.6.1
func (connector *MemoryKVConnector) Connect(parentContext context.Context) error
func (*MemoryKVConnector) DeleteById ¶ added in v1.6.13
func (connector *MemoryKVConnector) DeleteById(collectionName string, id interface{}) (DeleteResult, error)
func (*MemoryKVConnector) DeleteMany ¶ added in v1.6.13
func (connector *MemoryKVConnector) DeleteMany(collectionName string, whereLookups *wst.A) (DeleteResult, error)
func (*MemoryKVConnector) Disconnect ¶ added in v1.6.1
func (connector *MemoryKVConnector) Disconnect() error
func (*MemoryKVConnector) FindMany ¶ added in v1.6.13
func (connector *MemoryKVConnector) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
func (*MemoryKVConnector) GetClient ¶ added in v1.6.1
func (connector *MemoryKVConnector) GetClient() interface{}
func (*MemoryKVConnector) GetName ¶ added in v1.6.1
func (connector *MemoryKVConnector) GetName() string
func (*MemoryKVConnector) Ping ¶ added in v1.6.1
func (connector *MemoryKVConnector) Ping(parentCtx context.Context) error
func (*MemoryKVConnector) SetConfig ¶ added in v1.6.13
func (connector *MemoryKVConnector) SetConfig(dsViper *viper.Viper)
func (*MemoryKVConnector) SetTimeout ¶ added in v1.6.14
func (connector *MemoryKVConnector) SetTimeout(seconds float32)
func (*MemoryKVConnector) UpdateById ¶ added in v1.6.13
type MongoCursorI ¶ added in v1.6.0
type MongoCursorI interface { Next(ctx context.Context) bool Decode(val interface{}) error All(ctx context.Context, val interface{}) error Close(ctx context.Context) error }
func NewFixedMongoCursor ¶ added in v1.6.0
func NewFixedMongoCursor(registry *bsoncodec.Registry, rawInputs [][]byte) MongoCursorI
type MongoDBConnector ¶ added in v1.6.1
type MongoDBConnector struct {
// contains filtered or unexported fields
}
func (*MongoDBConnector) Connect ¶ added in v1.6.1
func (connector *MongoDBConnector) Connect(parentContext context.Context) error
func (*MongoDBConnector) DeleteById ¶ added in v1.6.13
func (connector *MongoDBConnector) DeleteById(collectionName string, id interface{}) (result DeleteResult, err error)
func (*MongoDBConnector) DeleteMany ¶ added in v1.6.13
func (connector *MongoDBConnector) DeleteMany(collectionName string, whereLookups *wst.A) (result DeleteResult, err error)
func (*MongoDBConnector) Disconnect ¶ added in v1.6.1
func (connector *MongoDBConnector) Disconnect() error
func (*MongoDBConnector) FindMany ¶ added in v1.6.13
func (connector *MongoDBConnector) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)
func (*MongoDBConnector) GetClient ¶ added in v1.6.1
func (connector *MongoDBConnector) GetClient() interface{}
func (*MongoDBConnector) GetName ¶ added in v1.6.1
func (connector *MongoDBConnector) GetName() string
func (*MongoDBConnector) Ping ¶ added in v1.6.1
func (connector *MongoDBConnector) Ping(parentCtx context.Context) error
func (*MongoDBConnector) SetConfig ¶ added in v1.6.13
func (connector *MongoDBConnector) SetConfig(dsViper *viper.Viper)
func (*MongoDBConnector) SetTimeout ¶ added in v1.6.14
func (connector *MongoDBConnector) SetTimeout(seconds float32)
func (*MongoDBConnector) UpdateById ¶ added in v1.6.13
type MongoDBDatasourceOptions ¶ added in v1.5.46
type MongoDBDatasourceOptions struct { Registry *bsoncodec.Registry Monitor *event.CommandMonitor Timeout float32 }
type Options ¶ added in v1.3.3
type Options struct { RetryOnError bool MongoDB *MongoDBDatasourceOptions }
type PersistedConnector ¶ added in v1.6.1
type PersistedConnector interface { // GetName Returns the name of the connector GetName() string // SetConfig Sets the configuration for the datasource SetConfig(dsViper *viper.Viper) // Connect Connects to the datasource Connect(parentContext context.Context) error // FindMany Finds many documents in the datasource FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error) // Count Counts documents in the datasource Count(collectionName string, lookups *wst.A) (int64, error) // Create Creates a document in the datasource Create(collectionName string, data *wst.M) (*wst.M, error) // UpdateById Updates a document in the datasource UpdateById(collectionName string, id interface{}, data *wst.M) (*wst.M, error) // DeleteById Deletes a document in the datasource DeleteById(collectionName string, id interface{}) (DeleteResult, error) // DeleteMany Deletes many documents in the datasource DeleteMany(collectionName string, whereLookups *wst.A) (DeleteResult, error) // Disconnect Disconnects from the datasource Disconnect() error // Ping Pings the datasource Ping(parentCtx context.Context) error // GetClient Returns the client for the datasource GetClient() interface{} // SetTimeout Sets the timeout for the datasource SetTimeout(seconds float32) // contains filtered or unexported methods }
func NewMemoryKVConnector ¶ added in v1.6.1
func NewMemoryKVConnector(registry *bsoncodec.Registry, dsKey string) PersistedConnector
NewMemoryKVConnector Factory method for MemoryKVConnector
func NewMongoDBConnector ¶ added in v1.6.1
func NewMongoDBConnector(mongoOptions *MongoDBDatasourceOptions) PersistedConnector
NewMongoDBConnector Factory method for MongoDBConnector