Documentation
¶
Index ¶
- func Collections(db *Database) error
- func Inc(field string, n int64) error
- func Tag(obj interface{}, fname, key string) string
- func Tags(obj interface{}, key string) map[string]string
- func Unique(m interface{}, db *Database, update bool, err Error)
- func Validate(m interface{}, db *Database, col string, update bool, err Error)
- type Applier
- type ApplierConf
- type ApplierProgress
- type ApplierState
- type AqlCollect
- type AqlFilter
- type AqlFunction
- type AqlInsert
- type AqlLet
- type AqlLimit
- type AqlRemove
- type AqlReplace
- type AqlSort
- type AqlStruct
- func (aq *AqlStruct) Collect(sentence string) *AqlStruct
- func (aq *AqlStruct) Execute(db *Database) (*Cursor, error)
- func (aq *AqlStruct) Filter(f ...interface{}) *AqlStruct
- func (aq *AqlStruct) For(v string, in interface{}) *AqlStruct
- func (aq *AqlStruct) Generate() string
- func (aq *AqlStruct) Insert(obj Obj, col string) *AqlStruct
- func (aq *AqlStruct) Let(v string, i interface{}) *AqlStruct
- func (aq *AqlStruct) Limit(s ...int64) *AqlStruct
- func (aq *AqlStruct) Remove(id interface{}, col string, options interface{}) *AqlStruct
- func (aq *AqlStruct) Replace(id interface{}, replace Obj, col string, options interface{}) *AqlStruct
- func (aq *AqlStruct) Return(view interface{}) *AqlStruct
- func (aq *AqlStruct) Sort(i ...interface{}) *AqlStruct
- func (aq *AqlStruct) Update(doc interface{}, with Obj, col string, options interface{}) *AqlStruct
- type AqlStructer
- type AqlUpdate
- type Collection
- func (c *Collection) All(skip, limit int) (*Cursor, error)
- func (c *Collection) Any(doc interface{}) error
- func (c *Collection) ConditionBitArray(condition string, skip int, limit int, index string) (*Cursor, error)
- func (c *Collection) ConditionSkipList(condition string, skip int, limit int, index string) (*Cursor, error)
- func (col *Collection) Count() int64
- func (c *Collection) CreateFullText(min int, fields ...string) error
- func (c *Collection) CreateGeoIndex(unique bool, geojson bool, fields ...string) error
- func (c *Collection) CreateHash(unique bool, fields ...string) error
- func (c *Collection) CreateSkipList(unique bool, fields ...string) error
- func (col *Collection) Delete(key string) error
- func (c *Collection) DeleteIndex(id string) error
- func (col *Collection) Edges(start string, direction string, result interface{}) error
- func (c *Collection) Example(doc interface{}, skip, limit int) (*Cursor, error)
- func (c *Collection) First(example, doc interface{}) error
- func (c *Collection) FullText(q string, atr string, skip, limit int) (*Cursor, error)
- func (col *Collection) Get(key string, doc interface{}) error
- func (c *Collection) Indexes() (map[string]Index, error)
- func (col *Collection) Load() error
- func (c *Collection) Near(lat float64, lon float64, distance bool, geo string, skip, limit int) (*Cursor, error)
- func (col *Collection) Patch(key string, doc interface{}) error
- func (col *Collection) Relate(from string, to string, label interface{}) error
- func (col *Collection) Replace(key string, doc interface{}) error
- func (col *Collection) Save(doc interface{}) error
- func (col *Collection) SaveEdge(doc interface{}, from string, to string) error
- func (c *Collection) SetCap(size int64, bysize int64) error
- func (c *Collection) Unique(key string, value interface{}, update bool, index string) (bool, error)
- func (c *Collection) WithIn(radius float64, lat float64, lon float64, distance bool, geo string, ...) (*Cursor, error)
- type CollectionDump
- type CollectionOptions
- func (opt *CollectionOptions) IsDocument()
- func (opt *CollectionOptions) IsEdge()
- func (opt *CollectionOptions) IsVolatile()
- func (opt *CollectionOptions) Journal(size int)
- func (opt *CollectionOptions) MustSync()
- func (opt *CollectionOptions) Shard(num int)
- func (opt *CollectionOptions) ShardKey(keys []string)
- type CollectionParameters
- type Context
- func (c *Context) BulkSave(models []Modeler) map[int]Error
- func (c *Context) Delete(m Modeler) Error
- func (c *Context) Get(m Modeler) Error
- func (c *Context) NewRelation(main Modeler, label map[string]interface{}, edgecol string, dierection string, ...) (*Relation, Error)
- func (c *Context) Save(m Modeler) Error
- type Cursor
- func (c Cursor) Count() int
- func (c *Cursor) Delete() error
- func (c Cursor) ErrCode() int
- func (c Cursor) Error() bool
- func (c *Cursor) FetchBatch(r interface{}) error
- func (c *Cursor) FetchOne(r interface{}) bool
- func (c *Cursor) FullCount() int
- func (c Cursor) HasMore() bool
- func (c *Cursor) Next(r interface{}) bool
- type Database
- func (db *Database) Applier() (*Applier, error)
- func (db *Database) ApplierConf() (*ApplierConf, error)
- func (d *Database) CheckCollection(name string) *CollectionOptions
- func (db Database) Col(name string) *Collection
- func (db *Database) ColExist(name string) bool
- func (d *Database) CreateCollection(c *CollectionOptions) error
- func (db *Database) CreateGraph(name string, eds []EdgeDefinition) (*Graph, error)
- func (d *Database) DropCollection(name string) error
- func (db *Database) DropGraph(name string) error
- func (d *Database) Execute(q *Query) (*Cursor, error)
- func (d *Database) ExecuteTran(t *Transaction) error
- func (db *Database) Graph(name string) *Graph
- func (db *Database) Inventory() (*ReplicationInventory, error)
- func (d *Database) IsValid(q *Query) bool
- func (db *Database) ListGraphs() ([]Graph, error)
- func (db *Database) LoggerState() (*Logger, error)
- func (db *Database) ServerID() string
- func (db *Database) SetApplierConf(appconf *ApplierConf) error
- func (db *Database) StartReplication() error
- func (db *Database) StopReplication() error
- func (d *Database) TruncateCollection(name string) error
- type Databases
- type Document
- type Edge
- type EdgeDefinition
- type Error
- type Extra
- type Filter
- type Graph
- func (g *Graph) AddEdgeDef(ed *EdgeDefinition) error
- func (g *Graph) AddEdgeDefinition(ed EdgeDefinition) error
- func (g *Graph) AddVertexCol(col string) error
- func (g *Graph) E(col string, edge interface{}) error
- func (g *Graph) GetE(col string, key string, edge interface{}) error
- func (g *Graph) GetV(col string, key string, doc interface{}) error
- func (g *Graph) ListEdgesDef() ([]string, error)
- func (g *Graph) ListVertexCol() ([]string, error)
- func (g *Graph) PatchE(col string, key string, doc interface{}, patch interface{}) error
- func (g *Graph) PatchV(col string, key string, doc interface{}, patch interface{}) error
- func (g *Graph) RemoveE(col string, key string) error
- func (g *Graph) RemoveEdgeDef(col string) error
- func (g *Graph) RemoveV(col string, key string) error
- func (g *Graph) RemoveVertexCol(col string) error
- func (g *Graph) ReplaceE(col string, key string, doc interface{}, patch interface{}) error
- func (g *Graph) ReplaceEdgeDef(name string, ed *EdgeDefinition) error
- func (g *Graph) ReplaceV(col string, key string, doc interface{}, patch interface{}) error
- func (g *Graph) Traverse(t *Traversal, r interface{}) error
- func (g *Graph) V(col string, doc interface{}) error
- type Index
- type Indexes
- type List
- type Logger
- type Modeler
- type Obj
- type ObjTran
- type PostDeleter
- type PostSaver
- type PostUpdater
- type PreDeleter
- type PreSaver
- type PreUpdater
- type Query
- type Relation
- type ReplicationInventory
- type ReplicationState
- type ServerInfo
- type Session
- type Sort
- type Stats
- type Transaction
- type Traversal
- type Uniqueness
- type User
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Applier ¶
type Applier struct {
State ApplierState `json:"state"`
Server ServerInfo `json:"server"`
Endpoint string `json:"endpoint"`
Database string `json:"database"`
}
type ApplierConf ¶
type ApplierConf struct {
Endpoint string `json:"endpoint,omitempty"`
Database string `json:"database,omitempty"`
Username string `json:"username,omitempty"`
Ssl int `json:"sslProtocol,omitempty"`
ReConnect int `json:"maxConnectRetries,omitempty"`
ConnectTimeout int `json:"connectTimeOut,omitempty"`
RequestTimeout int `json:"requestTimeOut,omitempty"`
Chunk int `json:"chunkSize,omitempty"`
AutoStart bool `json:"autoStart,omitempty"`
AdaptPolling bool `json:"adaptivePolling,omitempty"`
// contains filtered or unexported fields
}
type ApplierProgress ¶
type ApplierState ¶
type AqlCollect ¶
type AqlCollect struct {
Sentence string `json:"collect"`
}
func (AqlCollect) Generate ¶
func (aqc AqlCollect) Generate() string
type AqlFilter ¶
type AqlFilter struct {
DefaultKey string `json:"key"`
// never include in json parsing
Custom string `json:"-"`
// Function filters
Functions []AqlFunction `json:"functions"`
// Filters
Filters []Filter `json:"filters"`
// Match all the filters or any of them
Any bool `json:"any"`
}
type AqlFunction ¶
type AqlFunction struct {
Name string
Params []interface{}
}
Aql functions
func Fun ¶
func Fun(name string, i ...interface{}) AqlFunction
Creates a AqlFunction to use into AqlStruct
func (AqlFunction) Generate ¶
func (f AqlFunction) Generate() string
type AqlLimit ¶
type AqlReplace ¶
func (AqlReplace) Generate ¶
func (aqr AqlReplace) Generate() string
type AqlStruct ¶
type AqlStruct struct {
// contains filtered or unexported fields
}
Basic Aql struct to build Aql Query
func NewAqlStruct ¶
func NewAqlStruct() *AqlStruct
func (*AqlStruct) Filter ¶
Aql filter add Filter() to AqlQuery Could be use like:
- Filter(custom ... string) example: Filter("u.name == 'Diego' && u.age > 20") out: FILTER u.name == 'Diego' && u.age > 21
- Filter(key string,fil ... Filter || AqlFunction, any bool) example: Filter("u",Fil("sum","eq",213),Fil("age","gt",21),true) out: FILTER u.sum == 213 || u.age > 21 Filter("u",Fil("sum","eq",213),FilField("id","==","adm.id"),false) out: FILTER u.sum == 213 FILTER u.id == adm.id Filter("u",Fil("sum","eq",213),FilField("id","==","adm.id"),false) out: FILTER u.sum == 213 FILTER u.id == adm.id Filter("u",Fun("LIKE",Atr("u","name"),"di%",true) out: FILTER u.age > 21 || LIKE(u.name,'di%',true) -FILTER(jsonFilter string) example: Filter(`{ "key" : "u" , "filters": [{ "name": "name", "like": "gt", "val": "die%" },{ "name": "status", "op": "eq", "val":"A"}] }`) out: FILTER (IS_NULL(u.name) == false && LIKE(u.name,'die%',true)) && u.status == 'A' Filter(`{ "key" : "u" , "filters": [{ "name": "status", "op": "==", "val": "P" },{ "name": "status", "op": "eq", "val":"A"}], "any" : true }`) out: FILTER u.status == 'P' || u.status == 'A' Filter(`{ "key" : "u" , "filters": [{ "name": "id", "op": "==", "field": "adm.id" },{ "name": "status", "op": "eq", "val":"A"}], "any" : true }`) out: Filter(`{ "key" : "u" , "filters": [{ "name": "id", "op": "==", "field": "adm.id" },{ "name": "status", "op": "eq", "val":"A"}], "any" : true }`)
func (*AqlStruct) Insert ¶
Aql INSERT Usage:
Insert(Obj{ "name" : Atr("u","name") , "test" : 2},"backup")
func (*AqlStruct) Replace ¶
func (aq *AqlStruct) Replace(id interface{}, replace Obj, col string, options interface{}) *AqlStruct
Aql Replace Usage:
Replace("u._id",Obj{ "name" : "Diego" },"users",nil)
type AqlStructer ¶
type AqlStructer interface {
Generate() string
}
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
}
Basic Collection struct
func (*Collection) ConditionBitArray ¶
func (c *Collection) ConditionBitArray(condition string, skip int, limit int, index string) (*Cursor, error)
Coditional query using bitarray index
func (*Collection) ConditionSkipList ¶
func (c *Collection) ConditionSkipList(condition string, skip int, limit int, index string) (*Cursor, error)
Coditional query using skiplist index
func (*Collection) CreateFullText ¶
func (c *Collection) CreateFullText(min int, fields ...string) error
func (*Collection) CreateGeoIndex ¶
func (c *Collection) CreateGeoIndex(unique bool, geojson bool, fields ...string) error
func (*Collection) CreateHash ¶
func (c *Collection) CreateHash(unique bool, fields ...string) error
func (*Collection) CreateSkipList ¶
func (c *Collection) CreateSkipList(unique bool, fields ...string) error
func (*Collection) Delete ¶
func (col *Collection) Delete(key string) error
func (*Collection) Edges ¶
func (col *Collection) Edges(start string, direction string, result interface{}) error
Get vertex relations
func (*Collection) Example ¶
func (c *Collection) Example(doc interface{}, skip, limit int) (*Cursor, error)
Simple query by example
func (*Collection) First ¶
func (c *Collection) First(example, doc interface{}) error
Returns first document in example query
func (*Collection) Indexes ¶
func (c *Collection) Indexes() (map[string]Index, error)
Get all indexs
func (*Collection) Patch ¶
func (col *Collection) Patch(key string, doc interface{}) error
func (*Collection) Relate ¶
func (col *Collection) Relate(from string, to string, label interface{}) error
Relate documents in edge collection
func (*Collection) Replace ¶
func (col *Collection) Replace(key string, doc interface{}) error
Replace document
func (*Collection) Save ¶
func (col *Collection) Save(doc interface{}) error
Save saves doc into collection, doc should have Document Embedded to retrieve error and Key later.
func (*Collection) SaveEdge ¶
func (col *Collection) SaveEdge(doc interface{}, from string, to string) error
Save Edge into Edges collection
func (*Collection) SetCap ¶
func (c *Collection) SetCap(size int64, bysize int64) error
Create cap constraint
type CollectionDump ¶
type CollectionDump struct {
Parameters CollectionParameters `json:"parameters"`
Indexes []Index
}
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"`
}
Options to create collection
func NewCollectionOptions ¶
func NewCollectionOptions(name string, sync bool) *CollectionOptions
func (*CollectionOptions) IsDocument ¶
func (opt *CollectionOptions) IsDocument()
func (*CollectionOptions) IsEdge ¶
func (opt *CollectionOptions) IsEdge()
func (*CollectionOptions) IsVolatile ¶
func (opt *CollectionOptions) IsVolatile()
Sets if collection must be Volatile.
func (*CollectionOptions) Journal ¶
func (opt *CollectionOptions) Journal(size int)
Sets custom journal size
func (*CollectionOptions) MustSync ¶
func (opt *CollectionOptions) MustSync()
Sets always-sync to true
func (*CollectionOptions) Shard ¶
func (opt *CollectionOptions) Shard(num int)
Sets the number of shards for a collection
func (*CollectionOptions) ShardKey ¶
func (opt *CollectionOptions) ShardKey(keys []string)
type CollectionParameters ¶
type CollectionParameters struct {
CollectionOptions
Id string `json:"cid"`
Version int `json:"version"`
Deleted bool `json:"deleted"`
}
type Context ¶
Context to share state between hook and track transaction state
func NewContext ¶
func (*Context) NewRelation ¶
type Cursor ¶
type Cursor struct {
Id string `json:"Id"`
Index int `json:"-"`
Result []interface{} `json:"result"`
More bool `json:"hasMore"`
Amount int `json:"count"`
Data Extra `json:"extra"`
Err bool `json:"error"`
ErrMsg string `json:"errorMessage"`
Code int `json:"code"`
Time time.Duration `json:"time"`
// contains filtered or unexported fields
}
func (*Cursor) FetchBatch ¶
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) ApplierConf ¶
func (db *Database) ApplierConf() (*ApplierConf, error)
func (*Database) CheckCollection ¶
func (d *Database) CheckCollection(name string) *CollectionOptions
CheckCollection returns collection option based on name, nil otherwise
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) CreateGraph ¶
func (db *Database) CreateGraph(name string, eds []EdgeDefinition) (*Graph, error)
Creates graphs
func (*Database) DropCollection ¶
Drop Collection
func (*Database) ExecuteTran ¶
func (d *Database) ExecuteTran(t *Transaction) error
ExecuteTran executes transaction into the database
func (*Database) Inventory ¶
func (db *Database) Inventory() (*ReplicationInventory, error)
Returns replication inventory
func (*Database) ListGraphs ¶
func (*Database) LoggerState ¶
func (*Database) SetApplierConf ¶
func (db *Database) SetApplierConf(appconf *ApplierConf) error
func (*Database) StartReplication ¶
func (*Database) StopReplication ¶
func (*Database) TruncateCollection ¶
Truncate collection
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 EdgeDefinition ¶
type EdgeDefinition struct {
Collection string `json:"collection"`
From []string `json:"from"`
To []string `json:"to"`
}
func NewEdgeDefinition ¶
func NewEdgeDefinition(col string, from []string, to []string) *EdgeDefinition
type Filter ¶
type Filter struct {
AtrR string `json:"name"`
// compare to value or function depending on operand
Value interface{} `json:"val,omitempty"`
// compare to field, need to check if it's valid variable!
Field string `json:"field,omitempty"`
// could be AqlFunction too
Function *AqlFunction `json:"-"`
// Operator
Oper string `json:"op"`
}
type Graph ¶
type Graph struct {
Id string `json:"_id,omitempty"`
Key string `json:"_key"`
Name string `json:"name"`
EdgesDef []EdgeDefinition `json:"edgeDefinitions"`
Orphan []string `json:"orphanCollections"`
// contains filtered or unexported fields
}
Graph structure
func (*Graph) AddEdgeDef ¶
func (g *Graph) AddEdgeDef(ed *EdgeDefinition) error
func (*Graph) AddEdgeDefinition ¶
func (g *Graph) AddEdgeDefinition(ed EdgeDefinition) error
func (*Graph) ListEdgesDef ¶
func (*Graph) ListVertexCol ¶
func (*Graph) RemoveVertexCol ¶
Remove vertex collections
func (*Graph) ReplaceEdgeDef ¶
func (g *Graph) ReplaceEdgeDef(name string, ed *EdgeDefinition) error
type Logger ¶
type Logger struct {
State ReplicationState `json:"state"`
Server ServerInfo `json:"server"`
Client []string `json:"clients"`
}
type PostDeleter ¶
type PostDeleter interface {
PostDelete(c *Context)
}
type PostUpdater ¶
type PostUpdater interface {
PostUpdate(c *Context)
}
type PreDeleter ¶
type PreDeleter interface {
PreDelete(c *Context)
}
type PreUpdater ¶
type PreUpdater interface {
PreUpdate(c *Context)
}
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 NewQueryWithVars ¶
func (*Query) SetFullCount ¶
type Relation ¶
type ReplicationInventory ¶
type ReplicationInventory struct {
Collections []CollectionDump `json:"collections"`
State ReplicationState `json:"state"`
Tick string `json:"tick"`
}
type ReplicationState ¶
type ServerInfo ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) AvailableDBs ¶
List available databases
type Sort ¶
type Sort struct {
Variable interface{} `json:"field"`
Direction string `json:"direction,omitempty"`
}
type Transaction ¶
type Transaction struct {
Collections map[string][]string `json:"collections"`
Action string `json:"action"`
Result interface{} `json:"result,omitempty"`
//Optional
Sync bool `json:"waitForSync,omitempty"`
Lock int `json:"lockTimeout,omitempty"`
Replicate bool `json:"replicate,omitempty"`
Params map[string]interface{} `json:"params,omitempty"`
Time time.Duration `json:"time,omitempty"`
//ErrorInfo
Error bool `json:"error,omitempty"`
Code int `json:"code,omitempty"`
Num int `json:"errorNum,omitempty"`
}
func NewTransaction ¶
func NewTransaction(q string, write []string, read []string) *Transaction
func (*Transaction) Execute ¶
func (t *Transaction) Execute(db *Database) error
type Traversal ¶
type Traversal struct {
StartVertex string `json:"startVertex"`
Filter string `json:"filter"`
MinDepth int `json:"minDepth"`
MaxDepth int `json:"maxDepth"`
Visitor string `json:"visitor"`
Direction string `json:"direction"`
Init string `json:"init"`
Expander string `json:"expander"`
Sort string `json:"sort"`
Strategy string `json:"strategy"`
Order string `json:"order"`
ItemOrder string `json:"itemOrder"`
Unique Uniqueness `json:"uniqueness"`
MaxIter int `json:"maxIterations"`
// contains filtered or unexported fields
}