arangomanager

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: BSD-2-Clause Imports: 19 Imported by: 1

README

arangomanager

License
Continuous integration GoDoc codecov Maintainability
Last commit
Funding

Golang based various reusable utilities to work with arangodb.

Misc. badges

Issues Open Issues Closed Issues
Total PRS Open PRS Closed PRS Merged PRS
Commits Last commit Branches Tags
GitHub repo size GitHub code size in bytes Lines of Code

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedLenRandomString added in v0.4.0

func FixedLenRandomString(length int) string

func NewSessionDb

func NewSessionDb(connP *ConnectParams) (*Session, *Database, error)

NewSessionDb connects to arangodb and returns a new session and database instances.

func RandomInt added in v0.4.0

func RandomInt(num int) (int, error)

Generate a random number using crypto/rand.

func RandomString added in v0.4.0

func RandomString(min, max int) string

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) Collection

func (d *Database) Collection(name string) (driver.Collection, error)

Collection returns collection attached to current database.

func (*Database) Count

func (d *Database) Count(query string) (int64, error)

Count query the database that is expected to return count of result.

func (*Database) CountWithParams

func (d *Database) CountWithParams(
	query string,
	bindVars map[string]interface{},
) (int64, error)

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

func (d *Database) Do(query string, bindVars map[string]interface{}) error

Do is to run data modification query with bind parameters that is not expected to return any result.

func (*Database) DoRun

func (d *Database) DoRun(
	query string,
	bindVars map[string]interface{},
) (*Result, error)

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) Drop

func (d *Database) Drop() error

Drop removes the database.

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

func (d *Database) Exec(query string) error

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) Get

func (d *Database) Get(query string) (*Result, error)

Get query the database to return single row of result.

func (*Database) GetRow

func (d *Database) GetRow(
	query string,
	bindVars map[string]interface{},
) (*Result, error)

GetRow query the database with bind parameters that is expected to return single row of result.

func (*Database) Handler

func (d *Database) Handler() driver.Database

Handler returns the raw arangodb database handler.

func (*Database) Run

func (d *Database) Run(query string) (*Result, error)

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

func (d *Database) Search(query string) (*Resultset, error)

Search query the database that is expected to return multiple rows of result.

func (*Database) SearchRows

func (d *Database) SearchRows(
	query string,
	bindVars map[string]interface{},
) (*Resultset, error)

SearchRows query the database with bind parameters that is expected to return multiple rows of result.

func (*Database) Truncate added in v0.3.0

func (d *Database) Truncate(names ...string) error

Truncate removes all data from the collections without touching the indexes.

func (*Database) ValidateQ

func (d *Database) ValidateQ(q string) error

ValidateQ validates the query.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is a cursor for single row of data.

func (*Result) IsEmpty

func (r *Result) IsEmpty() bool

IsEmpty checks for empty result.

func (*Result) Read

func (r *Result) Read(iface interface{}) error

Read read the row of data to i interface.

type Resultset

type Resultset struct {
	// contains filtered or unexported fields
}

Resultset is a cursor for multiple rows of result.

func (*Resultset) Close

func (r *Resultset) Close() error

Close closed the resultset.

func (*Resultset) IsEmpty

func (r *Resultset) IsEmpty() bool

IsEmpty checks for empty resultset.

func (*Resultset) Read

func (r *Resultset) Read(iface interface{}) error

Read read the row of data to interface i.

func (*Resultset) Scan

func (r *Resultset) Scan() bool

Scan advances resultset to the next row of data.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is a connected database client.

func Connect

func Connect(
	host, user, password string,
	port int,
	istls bool,
) (*Session, error)

Connect is a constructor for new client.

func NewSessionFromClient

func NewSessionFromClient(client driver.Client) *Session

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

func (s *Session) CreateUser(user, pass string) error

CreateUser creates user.

func (*Session) CurrentDB

func (s *Session) CurrentDB() (*Database, error)

CurrentDB gets the default database(_system).

func (*Session) DB

func (s *Session) DB(name string) (*Database, error)

DB gets the database.

func (*Session) GrantDB

func (s *Session) GrantDB(database, user, grant string) error

GrantDB grants user permission to a database.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL