Skip to content

Commit

Permalink
property-ref-update (#103)
Browse files Browse the repository at this point in the history
* property-ref-update

* update
  • Loading branch information
amber-moe committed Jun 23, 2020
1 parent 962d13f commit 1481573
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,23 @@ There are four built-in properties in the edge:
* _src: source vertex ID of the edge
* _dst: destination ID of the edge
* _type: edge type
* _ranking: the edge's ranking
* _rank: the edge's rank

You can use `_src` and `_dst` to get the starting and ending vertices' ID, and they are very commonly used to show a graph path.

For example,

```ngql
nebula> GO FROM 100 OVER follow YIELD follow._src AS startVID /* starting vertex is 100 */, follow._dst AS endVID;
nebula> GO FROM 100 OVER follow YIELD follow._src, follow._dst, follow._type, follow._rank;
===========================================================
| follow._src | follow._dst | follow._type | follow._rank |
===========================================================
| 100 | 101 | 26 | 0 |
-----------------------------------------------------------
| 100 | 102 | 26 | 0 |
-----------------------------------------------------------
| 100 | 106 | 26 | 0 |
-----------------------------------------------------------
```

This statement returns all the neighbors of vertex `100` over edge type `follow`, by referencing `follow._src` as the starting vertex ID (which, of course, is `100`) and `follow._dst` as the ending vertex ID.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# DELETE EDGE Syntax

The `DELETE EDGE` statement is used to delete edges. Given an edge type, the source vertex and the dest vertex, **Nebula Graph** supports `DELETE` the edge, its associated properties and the edge ranking. You can also delete an edge with a certain rank. The syntax is as follows:
The `DELETE EDGE` statement is used to delete edges. Given an edge type, the source vertex and the dest vertex, **Nebula Graph** supports `DELETE` the edge, its associated properties and the edge rank. You can also delete an edge with a certain rank. The syntax is as follows:

```ngql
DELETE EDGE <edge_type> <vid> -> <vid>[@<ranking>] [, <vid> -> <vid> ...]
DELETE EDGE <edge_type> <vid> -> <vid>[@<rank>] [, <vid> -> <vid> ...]
```

For example,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ The `FETCH` usage of an edge is almost the same with vertex.
You can get properties from multiple edges with the same type.

```ngql
FETCH PROP ON <edge_type> <vid> -> <vid>[@<ranking>] [, <vid> -> <vid> ...] [YIELD [DISTINCT] <return_list>]
FETCH PROP ON <edge_type> <vid> -> <vid>[@<rank>] [, <vid> -> <vid> ...] [YIELD [DISTINCT] <return_list>]
```

`<edge_type>` specifies the edge's type. It must be the same as those in `<return_list>`.

`<vid> -> <vid>` denotes a starting vertex to (->) an ending vertex. Multiple edges are separated by comma(,).

`<ranking>` specifies the edge weight of the same edge type; it's optional.
`<rank>` specifies the edge weight of the same edge type; it's optional.

`[YIELD [DISTINCT] <return_list>]` is the property list returned.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```ngql
INSERT EDGE <edge_name> ( <prop_name_list> ) VALUES | VALUE
<src_vid> -> <dst_vid>[@<ranking>] : ( <prop_value_list> )
<src_vid> -> <dst_vid>[@<rank>] : ( <prop_value_list> )
[, <src_vid> -> <dst_vid> : ( <prop_value_list> ), ...]
<prop_name_list> ::=
Expand All @@ -17,14 +17,14 @@ INSERT EDGE <edge_name> ( <prop_name_list> ) VALUES | VALUE
* `<edge_name>` denotes the edge type, which must be created before `INSERT EDGE`.
* `<prop_name_list>` is the property name list as the given `<edge_name>`.
* `<prop_value_list>` must provide the value list according to `<prop_name_list>`. If no value matches the type, an error will be returned.
* `ranking` is optional, it specifies the edge ranking of the same edge type, if not specified, the default value is 0.
* `rank` is optional, it specifies the edge rank of the same edge type, if not specified, the default value is 0.

## Examples

```ngql
nebula> CREATE EDGE e1() -- create edge t1 with empty property or default values
nebula> INSERT EDGE e1 () VALUES 10->11:() -- insert an edge from vertex 10 to vertex 11 with empty property
nebula> INSERT EDGE e1 () VALUES 10->11@1:() -- insert an edge from vertex 10 to vertex 11 with empty property, the edge ranking is 1
nebula> INSERT EDGE e1 () VALUES 10->11@1:() -- insert an edge from vertex 10 to vertex 11 with empty property, the edge rank is 1
```

```ngql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ UPDATE EDGE <edge> SET <update_columns> [WHEN <condition>] [YIELD <columns>]

**NOTE:** `WHEN` and `YIELD` are optional.

- `edge` is the edge to be updated, the syntax is `<src> -> <dst> [@ranking] OF <edge_type>`.
- `edge` is the edge to be updated, the syntax is `<src> -> <dst> [@rank] OF <edge_type>`.
- `update_columns` is the properties of the edge to be updated.
- `condition` is some constraints, only when met, `UPDATE` will run successfully and expression operations are supported.
- `columns` is the columns to be returned, `YIELD` returns the latest updated values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ UPSERT {VERTEX <vid> | EDGE <edge>} SET <update_columns> [WHEN <condition>] [YIE
```

- `vid` is the ID of the vertex to be updated.
- `edge` is the edge to be updated, the syntax is `<src> -> <dst> [@ranking] OF <edge_type>`.
- `edge` is the edge to be updated, the syntax is `<src> -> <dst> [@rank] OF <edge_type>`.
- `update_columns` is the properties of the vertex or edge to be updated, for example, `tag1.col1 = $^.tag2.col2 + 1` means to update `tag1.col1` to `tag2.col2+1`.

**NOTE:**  `$^` indicates vertex to be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FIND SHORTEST | ALL PATH FROM <vertex_id_list> TO <vertex_id_list> OVER <edge_ty

## Examples

Path is displayed as `id <edge_name, ranking> id` in console.
Path is displayed as `id <edge_name, rank> id` in console.

```ngql
nebula> FIND SHORTEST PATH FROM 100 to 200 OVER *;
Expand Down
6 changes: 3 additions & 3 deletions docs/manual-EN/5.appendix/cypher-ngql.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
| --- | ------------ | ------------ |
| List all labels/tags | MATCH (n) RETURN distinct labels(n); <br/> call db.labels(); | SHOW TAGS |
| Insert a vertex with a specified type | CREATE (:Person {age: 16}) | INSERT VERTEX `<tag_name>` (prop_name_list) VALUES `<vid>`:(prop_value_list) |
| Insert an edge with specified edge type | CREATE (src)-[rel:LIKES]->(dst) <br/> SET rel.prop = V | INSERT EDGE `<edge_type>` ( prop_name_list ) VALUES `<src_vid>` -> `<dst_vid>`[`@<ranking>`]: ( prop_value_list ) |
| Insert an edge with specified edge type | CREATE (src)-[rel:LIKES]->(dst) <br/> SET rel.prop = V | INSERT EDGE `<edge_type>` ( prop_name_list ) VALUES `<src_vid>` -> `<dst_vid>`[`@<rank>`]: ( prop_value_list ) |
| Delete a vertex | MATCH (n) WHERE ID(n) = vid <br/> DETACH DELETE n | DELETE VERTEX `<vid>` |
| Delete an edge | MATCH ()-[r]->() WHERE ID(r)=edgeID <br/> DELETE r | DELETE EDGE `<edge_type>` `<src_vid>` -> `<dst_vid>`[`@<ranking>`] |
| Delete an edge | MATCH ()-[r]->() WHERE ID(r)=edgeID <br/> DELETE r | DELETE EDGE `<edge_type>` `<src_vid>` -> `<dst_vid>`[`@<rank>`] |
| Update a vertex property |SET n.name = V | UPDATE VERTEX `<vid>` SET `<update_columns>` |
| Fetch vertex prop| MATCH (n) <br/> WHERE ID(n) = vid <br/> RETURN properties(n) | FETCH PROP ON `<tag_name>` `<vid>`|
| Fetch edge prop | MATCH (n)-[r]->() <br/> WHERE ID(r)=edgeID <br/> return properties(r)| FETCH PROP ON `<edge_type>` `<src_vid>` -> `<dst_vid>`[`@<ranking>`]|
| Fetch edge prop | MATCH (n)-[r]->() <br/> WHERE ID(r)=edgeID <br/> return properties(r)| FETCH PROP ON `<edge_type>` `<src_vid>` -> `<dst_vid>`[`@<rank>`]|
| Query a vertex along specified edge type |MATCH (n)-[r:edge_type]->() WHERE ID(n) = vid| GO FROM `<vid>` OVER `<edge_type>` |
| Query a vertex along specified edge type reversely | MATCH (n)<-[r:edge_type]-() WHERE ID(n) = vid | GO FROM `<vid>` OVER `<edge_type>` REVERSELY |
| Get the N-Hop along a specified edge type |MATCH (n)-[r:edge_type*N]->() <br/> WHERE ID(n) = vid <br/> return r | GO N STEPS FROM `<vid>` OVER `<edge_type>` |
Expand Down

0 comments on commit 1481573

Please sign in to comment.