{"id":21068945,"url":"https://github.com/cloudprivacylabs/opencypher","last_synced_at":"2025-06-16T05:36:22.370Z","repository":{"id":43895287,"uuid":"482879604","full_name":"cloudprivacylabs/opencypher","owner":"cloudprivacylabs","description":"An embedded in-memory openCypher implementation for Go","archived":false,"fork":false,"pushed_at":"2024-01-21T21:33:22.000Z","size":252,"stargazers_count":13,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-16T03:36:08.021Z","etag":null,"topics":["graph-algorithms","graphs","neo4j","opencypher"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudprivacylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-18T14:36:17.000Z","updated_at":"2025-04-21T02:57:07.000Z","dependencies_parsed_at":"2023-12-27T07:31:38.197Z","dependency_job_id":"240ca704-9699-403e-ac7c-e4847ce500b6","html_url":"https://github.com/cloudprivacylabs/opencypher","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/cloudprivacylabs/opencypher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Fopencypher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Fopencypher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Fopencypher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Fopencypher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudprivacylabs","download_url":"https://codeload.github.com/cloudprivacylabs/opencypher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Fopencypher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260106786,"owners_count":22959724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-algorithms","graphs","neo4j","opencypher"],"created_at":"2024-11-19T18:29:38.660Z","updated_at":"2025-06-16T05:36:22.341Z","avatar_url":"https://github.com/cloudprivacylabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/cloudprivacylabs/opencypher?status.svg)](https://godoc.org/github.com/cloudprivacylabs/opencypher)\n[![Go Report Card](https://goreportcard.com/badge/github.com/cloudprivacylabs/opencypher)](https://goreportcard.com/report/github.com/cloudprivacylabs/opencypher)\n[![Build Status](https://github.com/cloudprivacylabs/opencypher/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/cloudprivacylabs/opencypher/actions/workflows/CI.yml)\n# Embedded openCypher interpreter\n\nopenCypher is a query language for labeled property graphs. This Go\nmodule contains an openCypher interpreter (partial) that works on the\nGo LPG implementation given in\nhttps://github.com/cloudprivacylabs/lpg.\n\nMore information on openCypher can be found here:\n\nhttps://opencypher.org/\n\n## openCypher\n\nAt this point, this library provides partial support for openCypher\nexpressions. More support will be added as needed. \n  \nopenCypher expressions are evaluated using an evaluation context. \n\n### Create Nodes\n\nSee examples/create directory.\n\n```\nimport (\n\t\"fmt\"\n\n\t\"github.com/cloudprivacylabs/opencypher\"\n\t\"github.com/cloudprivacylabs/lpg\"\n)\n\nfunc main() {\n\tgrph := graph.NewGraph()\n\tectx := opencypher.NewEvalContext(grph)\n\t_, err := opencypher.ParseAndEvaluate(`CREATE (n:Person), (m)`, ectx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tv, err := opencypher.ParseAndEvaluate(`MATCH (x:Person) return x as person`, ectx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(v.Get().(opencypher.ResultSet).Rows[0][\"person\"])\n}\n```\n\n### Evaluation Context\n\nVariables defined in an expression will be in the evaluation context,\nand can be used to affect the results of subsequent expression.\n\nSee examples/context.\n\n```\nfunc main() {\n\t// Create an empty graph\n\tgrph := graph.NewGraph()\n\t// Evaluation context knows the graph we are working on\n\tectx := opencypher.NewEvalContext(grph)\n\t// CREATE a path\n\t_, err := opencypher.ParseAndEvaluate(`CREATE (andy {name:\"Andy\"})-[:KNOWS]-\u003e (stephen {name:\"Stephen\"})`, ectx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// ectx knows andy and stephen. So this will only update stephen, and not andy\n\tv, err := opencypher.ParseAndEvaluate(`MATCH (stephen) SET stephen.age=34 return stephen`, ectx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tage, _ := v.Get().(opencypher.ResultSet).Rows[0][\"1\"].Get().(*graph.Node).GetProperty(\"age\")\n\tfmt.Println(age) // This will print 34\n}\n```\n\n### Querying and result sets\n\nUsing the example in https://neo4j.com/docs/cypher-manual/current/clauses/match/\n\n```\n\t// Get all nodes\n\tectx = opencypher.NewEvalContext(grph)\n\tres, err := opencypher.ParseAndEvaluate(`match (n) return n`, ectx)\n\tfmt.Println(\"match (n) return n:\", res.Get().(opencypher.ResultSet).Rows)\n\n\t// Get all movies\n\tectx = opencypher.NewEvalContext(grph)\n\tres, err = opencypher.ParseAndEvaluate(`match (n:Movie) return n.title`, ectx)\n\tfmt.Println(\"match (n:Movie) return n.title:\", res.Get().(opencypher.ResultSet).Rows)\n\n\t// Get related node\n\tectx = opencypher.NewEvalContext(grph)\n\tres, err = opencypher.ParseAndEvaluate(`match (director {name: 'Oliver Stone'}) --(movie:Movie) return movie.title`, ectx)\n\tfmt.Println(\"match (director {name: 'Oliver Stone'}) --(movie:Movie) return movie.title:\", res.Get().(opencypher.ResultSet).Rows)\n\tectx = opencypher.NewEvalContext(grph)\n\tres, err = opencypher.ParseAndEvaluate(`match (director {name: 'Oliver Stone'}) --\u003e (movie:Movie) return movie.title`, ectx)\n\tfmt.Println(\"match (director {name: 'Oliver Stone'}) --\u003e (movie:Movie) return movie.title:\", res.Get().(opencypher.ResultSet).Rows)\n\n\t// Get relationship type\n\tectx = opencypher.NewEvalContext(grph)\n\tres, err = opencypher.ParseAndEvaluate(`match (:Person {name: 'Oliver Stone'}) -[r]-\u003e(movie) return r`, ectx)\n\tfmt.Println(\"match (:Person {name: 'Oliver Stone'}) -[r]-\u003e(movie) return r:\", res.Get().(opencypher.ResultSet).Rows)\n```\n\n### Values\n\nOpencypher expressions return an object of type `Value`. `Value.Get`\nreturns the value contained in the value object. For most queries,\nthis value is of type `opencypher.ResultSet`. A `ResultSet` contains\n`Rows` that are `map[string]Value` objects. If the query explicitly\nnames its columns, the map will contains those names as the\nkeys. Otherwise, the columns will be \"1\", \"2\", etc. \n\nThe number of rows in the result set:\n\n```\nrs:=value.Get().(opencypher.ResultSet)\nnumResults:=len(rs.Rows)\n```\n\nIterate the results:\n\n```\nfor _,row := range resultSet.Rows {\n   for colName, colValue := range row {\n      // colName is the column name\n      // colValue is an opencypher.Value object\n      fmt.Println(colName,value.Get())\n   }\n}\n```\n\nThe return type of `Value.Get` is one of the following:\n  * int\n  * float64\n  * bool\n  * string\n  * Duration\n  * Date\n  * Time\n  * LocalDateTime\n  * LocalTime\n  * []Value\n  * map[string]Value\n  * lpg.StringSet\n  * *lpg.Node\n  * *lpg.Path\n  * ResultSet\n\n\nThis Go module is part of the [Layered Schema\nArchitecture](https://layeredschemas.org).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Fopencypher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudprivacylabs%2Fopencypher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Fopencypher/lists"}