Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Markdown cheatsheet

Create

Insert

Update

Delete

Select

Match

Create class

Syntax:

CREATE CLASS <class> 
[EXTENDS <super-class>] 
[CLUSTER <clusterId>*]

Usage:

CREATE CLASS Car 
EXTENDS Vehicle

Create cluster

Syntax:

CREATE CLUSTER <name> <type> 
[DATASEGMENT <data-segment>|default] 
[LOCATION <path>|default] 
[POSITION <position>|append]

Usage:

CREATE CLUSTER account PHYSICAL

Create edge

Syntax:

CREATE EDGE [<class>] 
[CLUSTER <cluster>] 
FROM <rid>|(<query>)|[<rid>]* 
TO <rid>|(<query>)|[<rid>]* 
[SET <field> = <expression>[,]*]

Usage:

CREATE EDGE Drives 
FROM #10:3 
TO #11:4 
SET brand = 'fiat', 
    name = 'wow',
    created_at = '2019-06-20 14:28:00';

Create vertex

Syntax:

CREATE VERTEX [<class>] 
[CLUSTER <cluster>] 
[SET <field> = <expression>[,]*]

Usage:

CREATE VERTEX Car 
SET brand = 'fiat', 
    name = 'wow'

Insert

Syntax:

INSERT INTO <Class>|cluster:<cluster>|index:<index> [<cluster>](cluster) 
[VALUES (<expression>[,]((<field>[,]*))*)]|[<field> = <expression>[,](SET)*]

Usage:

INSERT INTO Profile 
SET name = 'Jay', 
    surname = 'Miner'
INSERT INTO Profile 
CLUSTER profile_recent 
SET name = 'Jay', 
    surname = 'Miner'

Update

Syntax:

UPDATE <class>|cluster:<cluster>|<recordID> 
SET|INCREMENT [= <field-value>](<field-name>)
[<field-name> = <field-value>](,)* 
[<conditions>](WHERE) 
[<max-records>](LIMIT)

Collections:

UPDATE <class>|cluster:<cluster>|<recordID> 
[[<field-name> = <field-value>](ADD|REMOVE])
[<field-name> = <field-value>](,)* 
[<conditions>](WHERE)

Maps:

UPDATE <class>|cluster:<cluster>|<recordID> 
[[<field-name> = <map-key> [,<map-value>]](PUT|REMOVE])
[<field-name> = <map-key> [,<map-value>]](,)* 
[<conditions>](WHERE)

Delete

Syntax:

DELETE FROM <Class>|cluster:<cluster>|index:<index> 
[<Condition>*](WHERE) 
[BY <Fields>* [ASC|DESC](ORDER)*] 
[<MaxRecords>](LIMIT)

Usage:

DELTE FROM Profile WHERE surname = 'unknown'

Select

Syntax:

SELECT 
[FROM <Target> 
[LET <Assignment>*](<Projections>]) 
[<Condition>*](WHERE) 
[BY <Field>](GROUP) 
[BY <Fields>* [ASC|DESC](ORDER)*] 
[<SkipRecords>](SKIP) 
[<MaxRecords>](LIMIT)

Usage:

SELECT foo, bar 
FROM Person 
WHERE foo LIKE 'bar%'
Contains item
SELECT foo, bar, languages
FROM Profile
WHERE languages CONTAINS 'English'
Contains document with item
SELECT foo, bar, Tags
FROM Articles
WHERE Tags CONTAINS (title = 'Java')

Match

MATCH
    {class: Domain, as: D, where: (name='example.com')} 
RETURN $pathelements;
MATCH 
   {class:Person, as:A} -FriendOf- {class:Person, as:B},     /* A and B are friends */
   {as:A} -FriendOf- {as:C} -FriendOf- {as:B},               /* C is a friend of both A ad B */
   {as:C} -HasA-> {class:Dog},                               /* A has a dog */
   {as:B} -WorksAt-> {class:Company, where:(name="Google")}, /* B works at Google */
RETURN A.name as name, B.name as friendName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.