Documentation
¶
Index ¶
- func FixedLenRandomString(length int) string
- func NewSessionDb(connP *ConnectParams) (*Session, *Database, error)
- func RandomInt(num int) (int, error)
- func RandomString(min, max int) string
- type ConnectParams
- type Database
- func (d *Database) BeginTransaction(ctx context.Context, opts *TransactionOptions) (*TransactionHandler, error)
- func (d *Database) Collection(name string) (driver.Collection, error)
- func (d *Database) Count(query string) (int64, error)
- func (d *Database) CountWithParams(query string, bindVars map[string]interface{}) (int64, error)
- func (d *Database) CreateCollection(name string, opt *driver.CreateCollectionOptions) (driver.Collection, error)
- func (d *Database) Do(query string, bindVars map[string]interface{}) error
- func (d *Database) DoRun(query string, bindVars map[string]interface{}) (*Result, error)
- func (d *Database) Drop() error
- func (d *Database) EnsureGeoIndex(coll string, fields []string, opts *driver.EnsureGeoIndexOptions) (driver.Index, bool, error)
- func (d *Database) EnsureHashIndex(coll string, fields []string, opts *driver.EnsureHashIndexOptions) (driver.Index, bool, error)
- func (d *Database) EnsurePersistentIndex(coll string, fields []string, opts *driver.EnsurePersistentIndexOptions) (driver.Index, bool, error)
- func (d *Database) EnsureSkipListIndex(coll string, fields []string, opts *driver.EnsureSkipListIndexOptions) (driver.Index, bool, error)
- func (d *Database) Exec(query string) error
- func (d *Database) FindOrCreateCollection(name string, opt *driver.CreateCollectionOptions) (driver.Collection, error)
- func (d *Database) FindOrCreateGraph(name string, defs []driver.EdgeDefinition) (driver.Graph, error)
- func (d *Database) Get(query string) (*Result, error)
- func (d *Database) GetRow(query string, bindVars map[string]interface{}) (*Result, error)
- func (d *Database) Handler() driver.Database
- func (d *Database) Run(query string) (*Result, error)
- func (d *Database) Search(query string) (*Resultset, error)
- func (d *Database) SearchRows(query string, bindVars map[string]interface{}) (*Resultset, error)
- func (d *Database) Truncate(names ...string) error
- func (d *Database) ValidateQ(q string) error
- type DocExistsParams
- type DocParams
- type Result
- type Resultset
- type Session
- type TransactionHandler
- func (t *TransactionHandler) Abort() error
- func (t *TransactionHandler) Commit() error
- func (t *TransactionHandler) Context() context.Context
- func (t *TransactionHandler) Do(query string, bindVars map[string]interface{}) error
- func (t *TransactionHandler) DoRun(query string, bindVars map[string]interface{}) (*Result, error)
- func (t *TransactionHandler) ID() driver.TransactionID
- func (t *TransactionHandler) Status() (driver.TransactionStatusRecord, error)
- type TransactionOptions
- type TxParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixedLenRandomString ¶ added in v0.4.0
func NewSessionDb ¶
func NewSessionDb(connP *ConnectParams) (*Session, *Database, error)
NewSessionDb connects to arangodb and returns a new session and database instances.
func RandomString ¶ added in v0.4.0
Generates a random string between a range(min and max) of length.
Types ¶
type ConnectParams ¶
type ConnectParams struct {
User string `validate:"required"`
Pass string `validate:"required"`
Database string `validate:"required"`
Host string `validate:"required"`
Port int `validate:"required"`
Istls bool
}
ConnectParams are the parameters required for connecting to arangodb.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database struct.
func (*Database) BeginTransaction ¶ added in v0.8.0
func (d *Database) BeginTransaction( ctx context.Context, opts *TransactionOptions, ) (*TransactionHandler, error)
func (*Database) Collection ¶
func (d *Database) Collection(name string) (driver.Collection, error)
Collection returns collection attached to current database.
func (*Database) CountWithParams ¶
CountWithParams query the database with bind parameters that is expected to return count of result.
func (*Database) CreateCollection ¶
func (d *Database) CreateCollection( name string, opt *driver.CreateCollectionOptions, ) (driver.Collection, error)
CreateCollection creates a collection in the database.
func (*Database) Do ¶
Do is to run data modification query with bind parameters that is not expected to return any result.
func (*Database) DoRun ¶
DoRun is to run data modification query with bind parameters that is expected to return a result. It is an alias for GetRow.
func (*Database) EnsureGeoIndex ¶ added in v0.2.0
func (d *Database) EnsureGeoIndex( coll string, fields []string, opts *driver.EnsureGeoIndexOptions, ) (driver.Index, bool, error)
EnsureGeoIndex finds or creates a geo index on a specified collection.
func (*Database) EnsureHashIndex ¶ added in v0.2.0
func (d *Database) EnsureHashIndex( coll string, fields []string, opts *driver.EnsureHashIndexOptions, ) (driver.Index, bool, error)
EnsureHashIndex finds or creates a hash index on a specified collection.
func (*Database) EnsurePersistentIndex ¶ added in v0.2.0
func (d *Database) EnsurePersistentIndex( coll string, fields []string, opts *driver.EnsurePersistentIndexOptions, ) (driver.Index, bool, error)
EnsurePersistentIndex finds or creates a persistent index on a specified collection.
func (*Database) EnsureSkipListIndex ¶ added in v0.2.0
func (d *Database) EnsureSkipListIndex( coll string, fields []string, opts *driver.EnsureSkipListIndexOptions, ) (driver.Index, bool, error)
EnsureSkipListIndex finds or creates a skip list index on a specified collection.
func (*Database) Exec ¶
Exec is to run data modification query that is not expected to return any result.
func (*Database) FindOrCreateCollection ¶
func (d *Database) FindOrCreateCollection( name string, opt *driver.CreateCollectionOptions, ) (driver.Collection, error)
FindOrCreateCollection finds or creates a collection in the database. The method is expected to be called by the user who has privileges to create the collection.
func (*Database) FindOrCreateGraph ¶
func (d *Database) FindOrCreateGraph( name string, defs []driver.EdgeDefinition, ) (driver.Graph, error)
FindOrCreateGraph finds or creates a named graph in the database.
func (*Database) GetRow ¶
GetRow query the database with bind parameters that is expected to return single row of result.
func (*Database) Run ¶
Run is to run data modification query that is expected to return a result It is a convenient alias for Get method.
func (*Database) Search ¶
Search query the database that is expected to return multiple rows of result.
func (*Database) SearchRows ¶
SearchRows query the database with bind parameters that is expected to return multiple rows of result.
type DocExistsParams ¶ added in v0.8.0
type DocExistsParams struct {
T *testing.T
DB *Database
Coll driver.Collection
FirstName string
LastName string
ShouldExist bool
}
DocExistsParams defines parameters for checking document existence
type DocParams ¶ added in v0.8.0
type DocParams struct {
T *testing.T
TX *TransactionHandler
Coll driver.Collection
FirstName string
LastName string
}
DocParams defines parameters for document operations
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is a cursor for single row of data.
type Resultset ¶
type Resultset struct {
// contains filtered or unexported fields
}
Resultset is a cursor for multiple rows of result.
func (*Resultset) Close ¶
Close closes the resultset and releases resources. If the resultset is empty (r.empty is true), the cursor is nil and no closing operation is needed.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a connected database client.
func NewSessionFromClient ¶
NewSessionFromClient creates a new Session from an existing client
You could also do this
&Session{client}
Funny isn't it
func (*Session) CreateDB ¶
func (s *Session) CreateDB( name string, opt *driver.CreateDatabaseOptions, ) error
CreateDB creates database.
func (*Session) CreateUser ¶
CreateUser creates user.
type TransactionHandler ¶ added in v0.8.0
type TransactionHandler struct {
// contains filtered or unexported fields
}
TransactionHandler represents a transaction with begin/commit/abort capabilities
func (*TransactionHandler) Abort ¶ added in v0.8.0
func (t *TransactionHandler) Abort() error
Abort aborts the transaction
func (*TransactionHandler) Commit ¶ added in v0.8.0
func (t *TransactionHandler) Commit() error
Commit commits the transaction
func (*TransactionHandler) Context ¶ added in v0.8.0
func (t *TransactionHandler) Context() context.Context
Context returns the transaction context which should be used for all operations within the transaction
func (*TransactionHandler) Do ¶ added in v0.8.0
func (t *TransactionHandler) Do( query string, bindVars map[string]interface{}, ) error
Do executes a query within the transaction.
func (*TransactionHandler) DoRun ¶ added in v0.8.0
func (t *TransactionHandler) DoRun( query string, bindVars map[string]interface{}, ) (*Result, error)
DoRunTransaction executes a query within a transaction that returns a result.
func (*TransactionHandler) ID ¶ added in v0.8.0
func (t *TransactionHandler) ID() driver.TransactionID
ID returns the transaction ID
func (*TransactionHandler) Status ¶ added in v0.8.0
func (t *TransactionHandler) Status() (driver.TransactionStatusRecord, error)
Status retrieves the current status of the transaction
type TransactionOptions ¶ added in v0.8.0
type TransactionOptions struct {
// ReadCollections is a list of collections that will be read during the transaction
ReadCollections []string
// WriteCollections is a list of collections that will be written to during the transaction
WriteCollections []string
// ExclusiveCollections is a list of collections that will be exclusively locked during the transaction
ExclusiveCollections []string
// WaitForSync if set to true, will force the transaction to write all data to disk before returning
WaitForSync bool
// AllowImplicit if set to true, allows reading from undeclared collections (only for Transaction)
AllowImplicit bool
// LockTimeout the timeout for waiting on collection locks (in seconds)
LockTimeout int
// MaxTransactionSize the maximum size of the transaction in bytes
MaxTransactionSize int
}
TransactionOptions represents options for transaction operations
func DefaultTransactionOptions ¶ added in v0.8.0
func DefaultTransactionOptions() *TransactionOptions
DefaultTransactionOptions returns default options for transactions
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
command
|
|
|
Package testarango is a golang library to write unit tests for arangodb based packages and applications.
|
Package testarango is a golang library to write unit tests for arangodb based packages and applications. |