Cypher Cheat Sheet
How the cheat sheet works
Example structure
| 1 | Add a role for each cheat-sheet that the example applies to. Leave blank if it applies in all cases. |
| 2 | Use an example block to contain the Cypher example and description. |
| 3 | Add an optional block for a Cypher example, specifying [source, cypher,`role=noheader]. |
| 4 | Add a required description block. |
| 5 | If the description consists of more than one paragraph of text, use an open block. |
| 6 | If you need to, you can add extra content, which is displayed below the example code and description. |
Playbook configuration
asciidoc:
attributes:
page-cheatsheet-product: Neo4j (1)
page-cheatsheet-products: (2)
- name: 'Neo4j Enterprise Edition' (3)
label: 'Enterprise Edition' (4)
class: 'neo4j-ee' (5)
default: true (6)
- name: 'Neo4j Community Edition'
class: 'neo4j-ce'
- name: 'Deprecated'
class: 'deprecated'
label-only: true (7)
| 1 | Add a product name to displayed before Version in the version selector. The default value is Product. |
| 2 | Add a page-cheatsheet-products section to the playbook to define the different views that a user can choose from. In this example we’ve added two views: Neo4j Enterprise Edition and Neo4j Community Edition. |
| 3 | Add a name for each view. This text is displayed in the dropdown that you use to select which Cheat Sheet you want to view. |
| 4 | [Optional] Add label text. When an example is not applicable in all views, a label is displayed to indicate which views it applies to. If no label value is specified, the value of name is used. |
| 5 | Specify a class for each view. This is used to add a role to the example block. For example, the class neo4j-ee is specified by [.neo4j-ee]. |
| 6 | Specify a default view. This is the view that is displayed when the page is loaded. |
| 7 | If you want to display a label for some entries without that label appearing in the dropdown, you can use the label-only attribute. In this example, entries that have the [.deprecated] role will have the Deprecated label displayed, but 'Deprecated' is not an option you can select from the dropdown. In this preview build, both Configuration and Deprecated have been added as label-only views. |
Write queries
Write queries subsection
<CYPHER EXAMPLE>
Text describing the example. This example has no role, and therefore no labels. It is displayed in all views.
Title with link
This entry has no example code.
This entry has no example code.
It contains:
-
more than one paragraph
-
a list
Therefore it is formatted as an open block
MATCH (n:A&B)
RETURN n.name AS name
This example is displayed in all views.
AuraDB Enterprise
MATCH (n:A&B)
RETURN n.name AS name
This example is displayed for AuraDB Enterprise ([.aura-dbe])
AuraDB Enterprise
AuraDB Free
MATCH (n:A|B)
RETURN n.name AS name
This example is displayed for both AuraDB Free and AuraDB Enterprise.
Deprecated
Deprecated examples
This section contains deprecated examples. The section has a [.deprecated] role, and the subsection and examples also have the role.
That’s a lot of labels.
(neo4j:Neo4j {name: "Neo4j"})
(neo4j)-[:INCLUDES]->(browser:Product {name: "Neo4j Browser"})
(browser)-[:HAS]->(:Feature {name: "Cypher"})
(browser)-[:HAS]->(:Feature {name: "Dev Tools"})
(browser)-[:HAS]->(:Feature {name: "Visualization"})
(neo4j)-[:CONNECTS_WITH]->(drivers:Drivers {name: "Drivers"})
(drivers)-[:SUPPORTS]->(:Language {name: "Java"})
Deprecated cypher example.
Functions
Temporal functions
date('2018-04-05')
Returns a date parsed from a string.
localtime('12:45:30.25')
Returns a time with no time zone.
time('12:45:30.25+01:00')
Returns a time in a specified time zone.
localdatetime('2018-04-05T12:34:00')
Returns a datetime with no time zone.
datetime('2018-04-05T12:34:00[Europe/Berlin]')
Returns a datetime in the specified time zone.
datetime({epochMillis: 3360000})
Transforms 3360000 as a UNIX Epoch time into a normal datetime.
AuraDB Enterprise
Neo4j Community Edition
date({year: $year, month: $month, day: $day})
All of the temporal functions can also be called with a map of named components. This example returns a date from year, month and day components. Each function supports a different set of possible components.
datetime({date: $date, time: $time})
Temporal types can be created by combining other types. This example creates a datetime from a date and a time.
date({date: $datetime, day: 5})
Temporal types can be created by selecting from more complex types, as well as overriding individual components. This example creates a date by selecting from a datetime, as well as overriding the day component.
WITH date('2018-04-05') AS d
RETURN d.year, d.month, d.day, d.week, d.dayOfWeek
Accessors allow extracting components of temporal types.
