top

Package neoism is a client library providing access to the Neo4j graph database via its REST API.

Example Usage:

package main

import (
	"fmt"
	"github.com/jmcvetta/neoism"
)

func main() {
	// No error handling in this example - bad, bad, bad!
	//
	// Connect to the Neo4j server
	//
	db, _ := neoism.Connect("http://localhost:7474/db/data")
	kirk := "Captain Kirk"
	mccoy := "Dr McCoy"
	//
	// Create a node
	//
	n0, _ := db.CreateNode(neoism.Props{"name": kirk})
	defer n0.Delete()  // Deferred clean up
	n0.AddLabel("Person") // Add a label
	//
	// Create a node with a Cypher query
	//
	res0 := []struct {
		N neoism.Node // Column "n" gets automagically unmarshalled into field N
	}{}
	cq0 := neoism.CypherQuery{
		Statement: "CREATE (n:Person {name: {name}}) RETURN n",
		// Use parameters instead of constructing a query string
		Parameters: neoism.Props{"name": mccoy},
		Result:     &res0,
	}
	db.Cypher(&cq0)
	n1 := res0[0].N // Only one row of data returned
	n1.Db = db // Must manually set Db with objects returned from Cypher query
	//
	// Create a relationship
	//
	n1.Relate("reports to", n0.Id(), neoism.Props{}) // Empty Props{} is okay
	//
	// Issue a query
	//
	res1 := []struct {
		A   string `json:"a.name"` // `json` tag matches column name in query
		Rel string `json:"type(r)"`
		B   string `json:"b.name"`
	}{}
	cq1 := neoism.CypherQuery{
		// Use backticks for long statements - Cypher is whitespace indifferent
		Statement: `
			MATCH (a:Person)-[r]->(b)
			WHERE a.name = {name}
			RETURN a.name, type(r), b.name
		`,
		Parameters: neoism.Props{"name": mccoy},
		Result:     &res1,
	}
	db.Cypher(&cq1)
	r := res1[0]
	fmt.Println(r.A, r.Rel, r.B)
	//
	// Clean up using a transaction
	//
	qs := []*neoism.CypherQuery{
		&neoism.CypherQuery{
			Statement: `
				MATCH (n:Person)-[r]->()
				WHERE n.name = {name}
				DELETE r
			`,
			Parameters: neoism.Props{"name": mccoy},
		},
		&neoism.CypherQuery{
			Statement: `
				MATCH (n:Person)
				WHERE n.name = {name}
				DELETE n
			`,
			Parameters: neoism.Props{"name": mccoy},
		},
	}
	tx, _ := db.Begin(qs)
	tx.Commit()
}

Imported by 98 package(s)

  1. github.com/AuthorOfTheSurf/neoism/presentation
  2. github.com/Financial-Times/alphaville-series-rw-neo4j/alphavilleseries
  3. github.com/Financial-Times/annotations-api-neo
  4. github.com/Financial-Times/annotations-rw-neo4j
  5. github.com/Financial-Times/annotations-rw-neo4j/annotations
  6. github.com/Financial-Times/brands-api-neo
  7. github.com/Financial-Times/brands-api-neo/brands
  8. github.com/Financial-Times/brands-rw-neo4j/brands
  9. github.com/Financial-Times/content-rw-neo4j/content
  10. github.com/Financial-Times/memberships-api-neo
  11. github.com/Financial-Times/memberships-api-neo/memberships
  12. github.com/Financial-Times/memberships-rw-neo4j/memberships
  13. github.com/Financial-Times/neo-utils-go/neoutils
  14. github.com/Financial-Times/org-writer-neo
  15. github.com/Financial-Times/org-writer-neo/orgs
  16. github.com/Financial-Times/organisations-rw-neo4j/organisations
  17. github.com/Financial-Times/people-api-neo
  18. github.com/Financial-Times/people-api-neo/people
  19. github.com/Financial-Times/people-rw-neo4j/people
  20. github.com/Financial-Times/public-brands-api/brands
  21. github.com/Financial-Times/public-organisation-api/organisations
  22. github.com/Financial-Times/public-organisations-api/organisations
  23. github.com/Financial-Times/public-people-api/people
  24. github.com/Financial-Times/roles-rw-neo4j/roles
  25. github.com/Financial-Times/sections-rw-neo4j/sections
  26. github.com/Financial-Times/subjects-rw-neo4j/subjects
  27. github.com/Financial-Times/up-neoutil-go
  28. github.com/IIC2173-2015-2-Grupo2/news-api
  29. github.com/IIC2173-2015-2-Grupo2/news-api/controllers
  30. github.com/IIC2173-2015-2-Grupo2/news-api/database
  31. github.com/IIC2173-2015-2-Grupo2/news-api/models
  32. github.com/IIC2173-2015-2-Grupo2/news-api/tasks
  33. github.com/IceBucketScience/shared/graph
  34. github.com/MDCox/spectator
  35. github.com/MDCox/spectator/data
  36. github.com/MartinGarton/neoism/presentation
  37. github.com/Penlook/neo4j/presentation
  38. github.com/Snaphy-Cloud/snaphyAuth/models
  39. github.com/abijr/neoism/presentation
  40. github.com/agonzalezro/gotagmee/db
  41. github.com/agonzalezro/gotagmee/meetup
  42. github.com/akscram/neoism/presentation
  43. github.com/anupcshan/neoism/presentation
  44. github.com/azr/neoism/presentation
  45. github.com/dan-compton/neo4jaws
  46. github.com/dgraph-io/benchmarks/neo
  47. github.com/dolph2/twitch_graph
  48. github.com/dolph2/twitch_graph/graph
  49. github.com/ernestas-poskus/neoism/presentation
  50. github.com/gaigepr/hackathon-classbuilder
  51. github.com/glevine/burl
  52. github.com/glevine/burldemo
  53. github.com/gregzuro/neoism/presentation
  54. github.com/halk/in-common/graph
  55. github.com/ironbay/backend-template/core
  56. github.com/ironbay/dive/core
  57. github.com/ironbay/hog/core
  58. github.com/ironbay/mush/core
  59. github.com/ironbay/mush/tasks
  60. github.com/ironbay/napoleon/core
  61. github.com/jadengore/Ricetta/api/service/query
  62. github.com/jmcvetta/decisions/graph
  63. github.com/jmcvetta/neoism/presentation
  64. github.com/linkedin-inc/neoism/presentation
  65. github.com/littletwolee/golangapi/tools
  66. github.com/marcom-unimelb/ssdir/staffdir
  67. github.com/markmandel/recommendation-neo4j/lib
  68. github.com/markmandel/recommendation-neo4j/models
  69. github.com/markmandel/recommendation-neo4j/rescue
  70. github.com/markmandel/recommendation-neo4j/seed
  71. github.com/mateuszdyminski/flights-analyzer/feeder
  72. github.com/nathandao/git2neo4j
  73. github.com/nathandao/neo4jstore
  74. github.com/nathandao/vantaa/core/auth
  75. github.com/nathandao/vantaa/core/vantaadb
  76. github.com/nathandao/vantaa/services/models/post
  77. github.com/nathandao/vantaa/services/models/user
  78. github.com/nathandao/vantaa/testhelpers
  79. github.com/opinionated/analyzer-core/alchemy
  80. github.com/peg-one/civicdb/data
  81. github.com/penlook/neo4j/presentation
  82. github.com/penlooktmp/neo4j/presentation
  83. github.com/plimble/neoism/presentation
  84. github.com/resc/godel/apps/engine
  85. github.com/sir-wiggles/bcfs/drivers/neo
  86. github.com/srom/neoism/presentation
  87. github.com/styner32/neoism/presentation
  88. github.com/syabondama/adaptivelearning/models
  89. github.com/tgebhart/neoism/presentation
  90. github.com/vishalshah-org/neoism/presentation
  91. github.com/vly/ssdir/staffdir
  92. github.com/vly/uom-funnelback/tools/golang
  93. github.com/vsouza/neoism/presentation
  94. github.com/wwwdata/neoism/presentation
  95. github.com/wwwdata/norm
  96. github.com/yggie/github-data-challenge-2014/neo
  97. github.com/zachlatta/suck
  98. gopkg.in/jmcvetta/neoism.v1/presentation

Imported only in test by 1 package(s)

  1. github.com/Financial-Times/base-ft-rw-app-go/baseftrwapp

Imports 4 package(s)

  1. github.com/stretchr/testify/assert
  2. gopkg.in/jmcvetta/napping.v3
  3. github.com/jmcvetta/randutil
  4. github.com/kr/pretty