Property is a component of schema that describes the data dimension of entities and relations in the graph. For example, node schema @card (Bank Card) has card number, balance, opening time and other node properties; edge schema @transaction (Transaction) has amount, transfer time and other edge properties.
Node properties _id
, _uuid
and edge properties _uuid
, _from
, _to
, _from_uuid
, _to_uuid
are created automatically along with node schema and edge schema. These system properties are not deletable. Each schema may contain multiple properties.
Property features:
- Supported data types of property are: int32, int64, uint32, uint64, float, double, string, text, datetime, timestamp;
Property Type | Description |
---|---|
float | 4 bytes with a data precision of 6 significant digits |
double | 8 bytes with a data precision of 15 significant digits |
string | Maximum of 65,535 bytes |
text | No limit on length |
datetime | Valid input formats are yyyy-mm-dd hh:mm:ss and yyyy-mm-dd hh:mm:ss.ssssss , the string will be stored as an uint64 that equals the number of milliseconds from 1900-01-01 00:00:00 UTC onwards |
timestamp | Valid input formats are yyyy-mm-dd hh:mm:ss , yyyy-mm-dd , yyyymmddhhmmss and yyyymmdd , the string will be stored as an uint32 that equals the number of seconds from 1970-01-01 00:00:00 UTC onwards, the time zone could be set via RequestConfig of the desired SDK |
- Property is usually combined with schema in the form of @<schema>.<property>, interpreted as “the value of property
<property>
of nodes/edges of schema<schema>
"; independent property expression without schema <property> indicates the value of property<property>
for nodes or edges of any schema, or empty value if the property does not exist.
Naming Conventions
Properties are named by developers. A same name can be shared between two properties of different schemas, but not between properties of a same schema.
- 2 ~ 64 characters
- Not allow to start with wave line '~'
- Not allow to contain back quote '`'
- Not allow to use Reserved Words listed in Basic Concepts
Show Property
Returned table name: _nodeProperty
and/or _edgeProperty
Returned table header: name
| type
| lte
| schema
| description
(the name, data type, whether LTEed, schema and description of the property)
Syntax:
// To show properties of all schemas in the current graphset (node properties and edges properties in separated tables)
show().property()
// To show properties of all node schemas in the current graphset
show().node_property()
// To show properties of all edge schemas in the current graphset
show().edge_property()
// To show properties of a certain node schema in the current graphset
show().node_property(@<schema>)
// To show properties of a certain edge schema in the current graphset
show().edge_property(@<schema>)
Create Property
string is used by default if data type is ignored when creating property.
Syntax:
// To create a node property under a certain node schema in the current graphset
create().node_property(@<schema>, "<name>", <type?>, "<desc?>")
// To create a node property under all node schemas in the current graphset
create().node_property(@*, "<name>", <type?>, "<desc?>")
// To create an edge property under a certain edge schema in the current graphset
create().edge_property(@<schema>, "<name>", <type?>, "<desc?>")
// To create an edge property under all edge schemas in the current graphset
create().edge_property(@*, "<name>", <type?>, "<desc?>")
// To create multiple node/edge properties by using the four methods above
create()
.node_property(@<schema>, "<name>", <type?>, "<desc?>")
.node_property(@*, "<name>", <type?>, "<desc?>")
.edge_property(@<schema>, "<name>", <type?>, "<desc?>")
.edge_property(@*, "<name>", <type?>, "<desc?>")
Example: Using one UQL to create node properties "card balance" and "level" under @card and edge property "time" for all edge schemas
create().node_property(@card, "sum," double, "card balance")
.node_property(@card, "level", int, "card level")
.edge_property(@*, "time", datetime)
Example: Using one UQL to create edge properties "transaction number", "time" and "amount" under @transaction
create().edge_property(@transaction, "no", "", "transaction number")
.edge_property(@transaction, "time", datetime)
.edge_property(@transaction, "amount", double)
Example: Using one UQL to create node properties "card balance", "level" under @card and edge properties "transaction number", "time" and "amount" under @transaction
create().node_property(@card, "sum", double, "card balance")
.node_property(@card, "level", int, "card level")
.edge_property(@transaction, "no", "", "transaction number")
.edge_property(@transaction, "time", datetime)
.edge_property(@transaction, "amount", double)
Alter Property (Name, Description)
Syntax:
// To modify the name, description of a certain node property under a certain node schema in the current graphset
alter().node_property(@<schema>.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain node property (if has) under all node schemas in the current graphset
alter().node_property(@*.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain edge property under a certain edge schema in the current graphset
alter().edge_property(@<schema>.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain edge property (if has) under all edge schemas in the current graphset
alter().edge_property(@*.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
Example: Rename @card property "sum" as "balance"
alter().node_property(@card.sum)
.set({name: "balance"})
Example: Rename property "time" as "createTime" for all edges
alter().edge_property(@*.time)
.set({name: "createTime"})
Drop Property
User may delete properties that are no longer needed to save disk space. Deleting property operation can be executed in real time, and there will not be a considerable wait time. Once executed, the property is deleted immediately.
Except for system properties _id
, _uuid
, _from
, _to
, _from_uuid
and _to_uuid
which are not allowed to be deleted, all the other properties of schema can be deleted.
Syntax:
// To delete a certain node property under a certain node schema from the current graphset
drop().node_schema(@<schema>.<property>)
// To delete a certain node property (if has) under all node schemas from the current graphset
drop().node_schema(@*.<property>)
// To delete a certain edge property under a certain edge schema from the current graphset
drop().edge_schema(@<schema>.<property>)
// To delete a certain edge property (if has) under all edge schemas from the current graphset
drop().edge_schema(@*.<property>)
// To delete multiple node/edge properties by using the four methods above
drop()
.node_schema(@<schema>.<property>)
.node_schema(@*.<property>)
.edge_schema(@<schema>.<property>)
.edge_schema(@*.<property>)
Example: Delete node property "branch" under @card and edge property "time" for all edges
drop().node_property(@card.branch).edge_property(@*.time)
Example: Delete @default edge property "test"
drop().edge_property(@default.test)