orango

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Orango

go get github.com/iraycd/orango

Golang driver for ArangoDB.

Here are the things you can do until now:

  • Databases : create
  • Collections : drop, create, list, truncate
  • Documents : save, replace,patch, query (simple query,AQL,Transactions)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Name   string `json:"name"`
	System bool   `json:"isSystem"`
	Status int    `json:"status"`
	// 3 = Edges , 2 =  Documents
	Type int `json:"type"`
	// contains filtered or unexported fields
}

func (*Collection) Replace

func (col *Collection) Replace(key string, doc interface{}) (DocumentMeta, error)

Replace document

func (*Collection) Save

func (col *Collection) Save(doc interface{}) (DocumentMeta, error)

Save saves doc into collection, doc should have Document Embedded to retrieve error and Key later.

type CollectionOptions

type CollectionOptions struct {
	Name        string                 `json:"name"`
	Type        uint                   `json:"type"`
	Sync        bool                   `json:"waitForSync,omitempty"`
	Compact     bool                   `json:"doCompact,omitempty"`
	JournalSize int                    `json:"journalSize,omitempty"`
	System      bool                   `json:"isSystem,omitempty"`
	Volatile    bool                   `json:"isVolatile,omitempty"`
	Keys        map[string]interface{} `json:"keyOptions,omitempty"`
	// Count
	Count int64 `json:"count"`
	// Cluster
	Shards    int      `json:"numberOfShards,omitempty"`
	ShardKeys []string `json:"shardKeys,omitempty"`
}

type Context

type Context struct {
	Keys map[string]interface{}
	Db   *Database
}

Context to share state between hook and track transaction state

func NewContext

func NewContext(db *Database) (*Context, error)

type Cursor

type Cursor struct {
	Id string `json:"Id"`

	Index  int           `json:"-"`
	Result []interface{} `json:"result"`
	More   bool          `json:"hasMore"`
	Amount int           `json:"count"`

	Err    bool   `json:"error"`
	ErrMsg string `json:"errorMessage"`
	Code   int    `json:"code"`

	Time time.Duration `json:"time"`
	// contains filtered or unexported fields
}

func NewCursor

func NewCursor(db *Database) *Cursor

func (*Cursor) FetchOne

func (c *Cursor) FetchOne(r interface{}) bool

FetchOne iterates over cursor, returns false when no more values into batch, fetch next batch if necesary.

type Database

type Database struct {
	Name        string `json:"name"`
	Id          string `json:"id"`
	Path        string `json:"path"`
	System      bool   `json:"isSystem"`
	Collections []Collection
	// contains filtered or unexported fields
}

Database struct

func (Database) Col

func (db Database) Col(name string) *Collection

Col returns Collection attached to current Database

func (*Database) CreateCollection

func (d *Database) CreateCollection(c *CollectionOptions) error

Create collections

func (*Database) Execute

func (d *Database) Execute(q *Query) (*Cursor, error)

Execute AQL query into server and returns cursor struct

type Databases

type Databases struct {
	List []string `json:"result" `
}

type Document

type Document struct {
	Id  string `json:"_id,omitempty"              `
	Rev string `json:"_rev,omitempty"             `
	Key string `json:"_key,omitempty"             `

	Error   bool   `json:"error,omitempty"`
	Message string `json:"errorMessage,omitempty"`
}

type DocumentMeta

type DocumentMeta struct {
	driver.DocumentMeta
}

type Edge

type Edge struct {
	Id    string `json:"_id,omitempty"  `
	From  string `json:"_from"`
	To    string `json:"_to"  `
	Error bool   `json:"error,omitempty"`
}

type Index

type Index struct {
	Id        string   `json:"id"`
	Type      string   `json:"type"`
	Unique    bool     `json:"unique"`
	MinLength int      `json:"minLength"`
	Fields    []string `json:"fields"`
	Size      int64    `json:"size"`
}

type Query

type Query struct {
	// mandatory
	Aql string `json:"query,omitempty"`
	//Optional values Batch    int                    `json:"batchSize,omitempty"`
	Count    bool                   `json:"count,omitempty"`
	BindVars map[string]interface{} `json:"bindVars,omitempty"`
	Options  map[string]interface{} `json:"options,omitempty"`
	// opetions fullCount bool
	// Note that the fullCount sub-attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.
	// Control
	Validate bool   `json:"-"`
	ErrorMsg string `json:"errorMessage,omitempty"`
}

Aql query

func NewQuery

func NewQuery(query string) *Query

type Session

type Session struct {
	Client driver.Client
	// contains filtered or unexported fields
}
var Sess Session

func Connect

func Connect(host, user, password string) (*Session, error)

Connects to Database

func (*Session) AvailableDBs

func (s *Session) AvailableDBs() []string

List available databases

func (*Session) CreateDB

func (s *Session) CreateDB(name string) error

// Create database

func (*Session) DB

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

DB returns database

func (*Session) DropDB

func (s *Session) DropDB(name string) error

Drops database

func (*Session) Safe

func (s *Session) Safe(safe bool)

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Active   bool   `json:"active"`
	Extra    string `json:"extra"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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