gleopoldo / ex-cypher Goto Github PK
View Code? Open in Web Editor NEWTop-level DSL interface to interact with Neo4J via Cypher
Top-level DSL interface to interact with Neo4J via Cypher
The library should provide support to all comparison operators described in the cypher language docs: https://neo4j.com/docs/cypher-manual/current/syntax/operators/#query-operators-comparison
We currently only provide support to equality operators (=
)
We must add other elixir versions to the github workflows in order to check the language versions supported by the project
We need to change the syntax for nodes or relations with multiple labels to separate them with a pipe |
instead of a comma ,
as it's being done currently. This is compliant with the cypher docs, and thus is believed to be the most recent and supported syntax.
It'll be awesome to have support for maps inside queries. Something like this:
person = %{name: "bob", age: 12}
cypher do
match node([:Person], %{name: person.name, age: person.age})
end
This should return the following match query:
MATCH (:Person {name:"bob",age:12})
People needs to update nodes and relationships. We must provide support to SET
statements too
We need to add support to merging relations instead of only nodes.
This example might be satisfied by the implementation:
iex> cypher do
...> merge node(:p, [:Player], %{nick: "like4boss"})
...> merge node(:p2, [:Player], %{nick: "marioboss"})
...> merge node(:p) -- rel([:IN_LOBBY]) -> node(:p2)
...> return "p.name"
...> end
~S|MERGE (p:Player {"nick":"like4boss"}) MERGE (p2:Player {"nick":"marioboss"}) MERGE (p)-[:IN_LOBBY]->(p2) RETURN p.name|
We should avoid conflicting the original purpose of =
in elixir (for binding and pattern matching) with the cypher's one (equality operator). WHERE
statements should use elixir's ==
operator instead, in order to make equality comparisons in Cypher.
We don't have yet support to DELETE statements, it would be very nice to include it into the DSL.
Doc links: https://neo4j.com/docs/cypher-manual/current/clauses/delete/
When trying to return more complex statements, such as only some properties of the matched nodes, we must use a string instead of a more elixir-like syntax.
We need to support aliasing using the AS
operator
The actual implementation of cypher
macro allows very different combinations of cypher commands into the query, but provides little debug information when building invalid queries.
In this example below, the following command is invalid since where
statements should be placed before the return
statement. The corresponding error coming from the Bolt.Sips
isn't helpful:
Example:
query = cypher do
match (node(:person, [:Person]) -- rel([:WORKS_IN]) -> node(:company, [:Company]))
return person.name
where company.name == "Acme"
order {person.name, :asc}
end
Running the code above, we get this:
%Bolt.Sips.Error{
code: "Neo.ClientError.Statement.SyntaxError",
message: "Invalid input 'H': expected 'i/I' (line 1, column 74 (offset: 73))\n\"MATCH (person:Person)-[:WORKS_IN]->(company:Company) RETURN person.name WHERE company.name = \"Acme\" ORDER BY person.name ASC\"\n
^"
}
One would expect to get a more informative error, such as:
{:error, "WHERE statements shouldn't come after RETURN statements."} = cypher do
# ...
end
Some statements that were originally integers or booleans are being converted when applying MERGE
, MATCH
or CREATE
commands.
The only one that isn't converting stuff is the WHERE
statement, that already manipulates the AST to provide support to more advanced matches. Maybe it could be a nice opportunity to merge both the relationship building logic with the Where
's AST structure manipulation.
It would be nice to have the following example working:
name = "sarah"
query =
cypher do
match node(:p, [:Person])
where p.name = name
return p
end
However, the name
variable will be printed along with the cypher query. The expected result would be to include the "sarah"
string in the query
A little review in the docs is needed in order to make it clearer and expose the API in a friendly format
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.