neo4j

package module
v0.0.0-...-4b60109 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

README

Phi Skills Neo4j Client for Go

Homepage https://phiskills.com
GitHub https://github.com/phiskills

Overview

This project contains the Go module to create a Neo4j client.

Installation

go get github.com/phiskills/neo4j-client.go

Quick start

package main
import "github.com/phiskills/neo4j-client.go"

client := &neo4j.Client{
	Host: "localhost",
	Port: 7687,
	Username: "neo4j",
	Password: "test",
}
result, err := client.Write(func(job neo4j.Job) (neo4j.Result, error) {
    user := &neo4j.Node{
        Id:     "user",
        Labels: []string{"User", "Customer"},
        Props:  neo4j.Records{"name": "John", "age": 20},
    }
    query := client.NewRequest()
    query = query.Create(user).Return(user.Property("id"))
    records, err := job.Execute(query)
    return records, err
})
for _, record := range result {
    fmt.Printf("user.id = %", record["user.id"])
}

For more details, see Neo4j - CYPHER MANUAL: Chapter 3. Clauses.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host     string
	Port     int
	Username string
	Password string
}

func (*Client) NewRequest

func (c *Client) NewRequest() Query

func (*Client) Read

func (c *Client) Read(transaction Transaction) ([]Records, error)

func (*Client) Write

func (c *Client) Write(transaction Transaction) ([]Records, error)

type Data

type Data interface {
	Property(name string) Property
	Properties(names ...string) []Property
}

type Destination

type Destination interface {
	// contains filtered or unexported methods
}

type Direction

type Direction int
const (
	NoDirection Direction = iota
	FromOriginToDestination
	FromDestinationToOrigin
)

type Job

type Job interface {
	Execute(Query) ([]Records, error)
}

type Node

type Node struct {
	Id     string
	Labels []string
	Props  Records
}

func (*Node) Properties

func (n *Node) Properties(names ...string) []Property

func (*Node) Property

func (n *Node) Property(name string) Property

type Operation

type Operation interface {
	Then(Operation) Operation
	And(Operation) Operation
	Or(Operation) Operation
	XOr(Operation) Operation
	// contains filtered or unexported methods
}

func Not

func Not(i invertible) Operation

type Path

type Path struct {
	Origin       *Node
	Relationship *Relationship
	Destination  Destination
}

type Property

type Property interface {
	Get() Operation
	IsEqual(interface{}) Operation
	IsNotEqual(interface{}) Operation
	LessThan(interface{}) Operation
	LessEqual(interface{}) Operation
	GreaterThan(interface{}) Operation
	GreaterEqual(interface{}) Operation
	StartsWith(string) Operation
	EndsWith(string) Operation
	Contains(interface{}) Operation
	In([]interface{}) Operation
	Matches(string) Operation
	IsNull() Operation
	IsNotNull() Operation
	// contains filtered or unexported methods
}

type Query

type Query interface {
	Custom(string, Records) Query
	Create(structure structure) Query
	Set(Data, Records) Query
	Delete(...string) Query
	Match(structure structure) Query
	Merge(structure structure) Query
	OnCreate() Query
	OnMatch() Query
	Optional() Query
	OrderBy(...Property) Query
	Desc() Query
	Limit(int) Query
	Skip(int) Query
	Where(Operation) Query
	With(...string) Query
	Return(...Property) Query

	String() string
	// contains filtered or unexported methods
}

type Records

type Records map[string]interface{}

func (Records) Equals

func (r Records) Equals(o Records) bool

func (Records) GetOrElse

func (r Records) GetOrElse(key string, defaultValue interface{}) interface{}

func (Records) Keys

func (r Records) Keys() []string

func (Records) Merge

func (r Records) Merge(records Records) Records

type Relationship

type Relationship struct {
	Id, Type  string
	Props     Records
	Direction Direction
}

func (*Relationship) Properties

func (r *Relationship) Properties(names ...string) []Property

func (*Relationship) Property

func (r *Relationship) Property(name string) Property

type Result

type Result interface{}

type Transaction

type Transaction func(Job) (Result, error)

Jump to

Keyboard shortcuts

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