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, datetime, timestamp;
- and its corresponding arrays: []int32, []int64, []uint32, []uint64, []float, []double, []string, []datetime, []timestamp (under development);
- A property name can be shared between different schemas, but not within a schema;
- Please refer to chapter Basic Concepts for the naming conventions of property;
- 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.
The difference between
datetime
andtimestamp
is: The data formats ofdatetime
includeyyyy-mm-dd hh:mm:ss
andyyyy-mm-dd hh:mm:ss.ssssss
; the string will be converted and stored as an uint64 that equals the number of milliseconds from1900-01-01 00:00:00 UTC
onwards. Thetimestamp
calls for a string in the formatyyyy-mm-dd hh:mm:ss
and stores the represented value as an uint32 that equals the number of seconds from1970-01-01 00:00:00 UTC
onwards.
Integer type
int32
is used by default if only writesint
. String typestring
supports a maximum of 65,535 bytes. Decimal typefloat
has 4 bytes with a data precision of 6 significant digits;double
has 8 bytes with a data precision of 15 significant digits. Choose the appropriate decimal type based on the practical usage and amount of the data, as well as the size of the disk.
V4.1 Use array index to refer to one or more elements in an array. The index starts from 0 and supported formats include:
[n]
(the element with index 0)、[n1:n2]
(an array formed by elements from index n1 to n2)、[:n]
(an array formed by elements from index 0 to n)、[n:]
(an array formed by elements from index n to the last).
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_property(@<schema>.<property>)
// To delete a certain node property (if has) under all node schemas from the current graphset
drop().node_property(@*.<property>)
// To delete a certain edge property under a certain edge schema from the current graphset
drop().edge_property(@<schema>.<property>)
// To delete a certain edge property (if has) under all edge schemas from the current graphset
drop().edge_property(@*.<property>)
// To delete multiple node/edge properties by using the four methods above
drop()
.node_property(@<schema>.<property>)
.node_property(@*.<property>)
.edge_property(@<schema>.<property>)
.edge_property(@*.<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)