Commands

Basic

CREATE class <className> [extends <super-class>] [cluster <clusterId>]
ALTER class <className> <attributeName> <attributeName>
DROP class <className>
TRUNCATE class <className>

刪除class中所有資料

DELETE vertex Person

extends

  1. 建立Lead繼承至V
create class Lead extends V
  1. V建立一個property
create property V.createAt date
  1. 查看Lead是否具有父類別的property Command模式
info class Lead

UI模式 Lead Info UI

alter class

建立尚未繼承的class Person

create class Person

Create Class

修改Person繼承至V

alter class Person superclass V

Alter Superclass

abstract

建立抽象類別

create class Vehicle extends V abstract

新增一筆資料至抽象類別將發生錯誤

insert into Vehicle set name = "My Car"

Insert Abstract Error

再建立一個類別Car繼承自抽象類別Vehicle

create class Car extends Vehicle

Extends Abstract

新增一筆資料至Car類別

insert into Car set name="Toyota"

Person類別建立一個property

create property Person.name string

修改Personname的property為必填

alter property Person.name mandatory true

嘗試新增一筆propertyage的紀錄將發生錯誤, 因為name設定為必填

insert into Person set age = 10

Insert Mandatory Error

重新新增一筆包含name的資料

insert into Person content {"name": "Charlie", "age": 10}

Cluster

  • 一個class可以對應至多個cluster
  • 查詢時可以指定某個cluster進行查詢

創建Cluster

create cluster USA
create cluster Europe

修改Cluster壓縮類型

alter cluster Europe compression gzip

Person加入USAEurope cluster

alter class Person addcluster USA
alter class Person addcluster Europe

對某個cluster進行查詢

select from cluster:Europe

sql functions

  • out: 獲得從當前記錄為頂點開始向外的相鄰頂點,應取得company的id
select out(WorkAt) as companyId from Person
  • in: 獲得從當前記錄為頂點開始向內的相鄰頂點
select in(WorkAt) as personId from Company
  • both: 獲得從當前記錄為頂點開始向內向外的相鄰頂點
select both() from Person
  • outE: 獲得從當前記錄為頂點開始向外的相鄰邊,應取得WorkAt的id
select outE() from Person
  • inE: 獲得從當前記錄為頂點開始向內的相鄰邊
select inE() from Person
  • bothE: 獲得從當前記錄為頂點開始向內向外的相鄰邊
select bothE() from Person
  • outV: 查詢從當前記錄為某個邊由外向內的頂點
select outV() from WorkAt
-- Person - WorkAt -> Company 結果為person id
  • inV: 查詢
select inV() from WorkAt
-- Person - WorkAt -> Company 結果為company id