Overview
Properties are associated with a node or edge schema to describe attributes of nodes and edges. For example, a node schema card
may have properties balance
and openedDate
, while an edge schema transfers
may have properties amount
and time
.
In UQL, the operator .
extracts a property from a schema. The expression @<schema>.<property>
specifies a certain property of a schema, such as @company.name
.
System Property
Each node has two system properties serving as unique identifiers: _id
and _uuid
. The _id
value can be manually assigned, ensuring distinct identification of nodes, while the _uuid
value is always generated by the system.
System Property |
Value Type | Description |
---|---|---|
_id |
string |
A string-type (with a length of up to 128 bytes) unique identifier for a node. |
_uuid |
uint64 |
A numeric unique identifier for a node. |
Each edge has only the _uuid
as its unique identifier, also generated by the system. Each edge connects a source node to a destination node, its _from
/_to
and _from_uuid
/_to_uuid
identify its two end nodes.
System Property |
Value Type | Description |
---|---|---|
_uuid |
uint64 |
A numeric unique identifier for an edge. |
_from |
string |
The _id of the source node of an edge. |
_to |
string |
The _id of the destination node of an edge. |
_from_uuid |
uint64 |
The _uuid of the source node of an edge. |
_to_uuid |
uint64 |
The _uuid of the destination node of an edge. |
Showing Properties
To retrieve information about properties in current graphset:
// Shows all properties
show().property()
// Shows all node properties
show().node_property()
// Shows properties associated with a specified node schema
show().node_property(@card)
// Shows all edge properties
show().edge_property()
// Shows properties associated with a specified edge schema
show().edge_property(@transfers)
The information about properties is organized into different tables:
- Node properties: Stored in
_nodeProperty
(all properties) and_nodeProperty_shard_N
(properties with data in shardN
) tables. - Edge properties: Stored in
_edgeProperty
(all properties) and_edgeProperty_shard_N
(properties with data in shardN
) tables.
Each table includes fields that provide essential details about each property:
Field |
Description |
---|---|
name |
The property name. |
type |
The property value type. |
lte |
Whether the property is loaded to the shards' memory for query acceleration. |
read |
Whether the current database user can read the property. 1 for true, 0 for false. |
write |
Whether the current database user can write the property. 1 for true, 0 for false. |
schema |
The schema that the property is associated with. |
description |
The description given to the property. |
encrypt |
The encryption method used for the property. |
Creating Properties
You can create one or more properties using a single create()
statement. Each property is specified by chaining a node_property()
or edge_property()
method. To encrypt a property, use the encrypt()
method.
create()
.node_property(<schema>, "<propName>", <propValueType?>, "<propDesc?>").encrypt("<encMeth?>")
.edge_property(<schema>, "<propName>", <propValueType?>, "<propDesc?>").encrypt("<encMeth?>")
...
Method | Param | Description |
---|---|---|
node_property() or edge_property() |
<schema> |
Specifies the node or edge schema (e.g., @user ); @* denotes all node or edge schemas. |
<propName> |
Property name. Naming conventions are:
|
|
<propValueType?> |
Optional. Property value type. When it is omitted, string is used by default. See all supported property value types. Note that the type cannot be modified after the property is created. |
|
<propDesc?> |
Optional. Description of the property. | |
encrypt() |
<encMeth?> |
Optional. Encrypts property values using one of the supported encryption methods: AES128 (default), AES256 , RSA and ECC . |
Integral Properties
The supported integral property value types include int32
, uint32
, int64
and uint64
.
create().node_property(@user, "age", uint32)
Decimal Properties
The supported decimal property value types include float
, double
, and decimal
.
create()
.edge_property(@links, "distance", float)
.edge_property(@links, "weight", "decimal(25,10)", "Weight of the relation")
The decimal(25,10)
specifies a decimal
type with a precision of 25 (total digits, excluding the decimal point) and a scale of 10 (digits after the decimal point). You may set the precision between 1 to 65, and the scale between 0 to 30. Specifically, decimal(<precision>, <scale>)
must be declared within quotes.
Textual Properties
The supported textual property value types include string
and text
, with string
set as the default type. When defining a property as string
, you can omit specifying the type during creation.
create()
.node_property(@post, "title")
.node_property(@post, "content", text)
Temporal Properties
The supported temporal property value types include datetime
and timestamp
.
create()
.node_property(@post, "createdOn", timestamp, "When the post is created")
.node_property(@post, "publishedOn", datetime, "When the post is published")
Boolean Properties
The supported boolean property value type is bool
.
create().node_property(@city, "isCapital", bool, "Indicates whether it is the capital city")
Spatial Properties
The supported spatial property value type is point
.
create().node_property(@city, "position", point, "Location of the city")
List Properties
The list property value type includes sub types int32
, int64
, uint32
, uint64
, float
, double
, string
, text
, datetime
and timestamp
.
create().node_property(@user, "interests", "string[]", "user interest tags")
Specifically, the <subtype>[]
must be declared within quotes.
Set Properties
The set property value type includes sub types int32
, int64
, uint32
, uint64
, float
, double
, string
, text
, datetime
and timestamp
.
create()
.node_property(@user, "heights", "set(float)", "Store user heights history as a set")
Specifically, the set(<subtype>)
must be declared within quotes.
Creating a Property for All Schemas
To create the property time
for all edge schemas:
create().edge_property(@*, "time", datetime)
Encrypting a Property
To create the property password
and encrypt it using AES256
:
create().node_property(@user, "password", string).encrypt("AES256")
Altering Name and Description
You can modify name and description of a property using the alter().node_property().set()
or alter().edge_property().set()
statement.
In the node_property()
or edge_property()
method, you can specify a particular property in the form of @<schema>.<property>
, or target all properties with the same name in the form of @*.<property>
.
To alter both name and description of the node property @user.name
:
alter().node_property(@user.name).set({name: "Name", description: "Full name"})
To alter name of all the edge properties time
:
alter().edge_property(@*.time).set({name: "createdOn"})
Dropping Properties
You can drop one or more properties using a single drop()
statement. Each property is specified by chaining a node_property()
or edge_property()
method. When a property is dropped, all related data — including the property values, associated indexes, full-text indexes, and any LTE-ed values held in memory — are removed.
In the node_property()
or edge_property()
method, you can specify a particular property in the form of @<schema>.<property>
.
To drop the node property @user.name
:
drop().node_property(@user.name)
To drop the edge property @links.time
:
drop().edge_property(@links.time)
To drop multiple properties:
drop().node_property(@user.age).edge_property(@links.time)