Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

features/graph #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type CollectionOptions struct {
Volatile bool `json:"isVolatile,omitempty"`
Keys map[string]interface{} `json:"keyOptions,omitempty"`
// Count
Count int64 `json:"count"`
Count int64 `json:"count"`
// Cluster
Shards int `json:"numberOfShards,omitempty"`
ShardKeys []string `json:"shardKeys,omitempty"`
Shards int `json:"numberOfShards,omitempty"`
ShardKeys []string `json:"shardKeys,omitempty"`
}

func NewCollectionOptions(name string, sync bool) *CollectionOptions {
Expand Down
7 changes: 4 additions & 3 deletions document.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
)

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

Error bool `json:"error,omitempty"`
Message string `json:"errorMessage,omitempty"`
Expand Down
66 changes: 56 additions & 10 deletions edge.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
package aranGO

import "errors"

type Edge struct {
Id string `json:"_id,omitempty" `
From string `json:"_from"`
To string `json:"_to" `
Error bool `json:"error,omitempty"`
/*
Only vital info?
Message string `json:"errorMessage,omitempty"`
Code int `json:"code,omitempty"`
Num int `json:"errorNum,omitempty"`
*/
Id string `json:"_id,omitempty"`
Key string `json:"_key,omitempty"`
Rev string `json:"_rev,omitempty"`
Oldrev string `json:"_oldRev,omitempty"`
From string `json:"_from"`
To string `json:"_to"`
Label string `json:"$label,omitempty"` // Not realized in v3.2

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

type edgeStats struct {
Scanned int `json:"scannedIndex"`
Filtered int `json:"filtered"`
}

type edgesResponce struct {
Edges []Edge `json:"edges"`
Stats edgeStats `json:"stats"`

Code int `json:"code"`
Error bool `json:"error"`

}
// Read in- or outbound edges
// GET /_api/edges/{collection-id}
func (db *Database) Edges(edgeCol string, startVertex string, direction string) ([]Edge, error) {
if edgeCol == "" || startVertex == "" {
return nil, errors.New("Invalid key or collection")
}

// TODO: Make URL parce in DB communication functions
uri := edgeCol + "?vertex=" + startVertex
if direction == "in" || direction == "out" {
uri += "&direction=" + direction
}

var eresp edgesResponce
res, err := db.get("edges", uri, "GET", nil, &eresp, &eresp)
if err != nil {
return nil, err
}

switch res.Status() {
case 200:
return eresp.Edges, nil
case 400:
return nil, errors.New("Request contains invalid parameters")
case 404:
return nil, errors.New("Edge collection was not found")
default:
return nil, errors.New("DB error")
}
}
Loading