Overview
The insert()
statement inserts new nodes and edges into a single schema in a graphset.
// Inserts nodes
insert().into(<schema>).nodes([
{<property1?>: <value1?>, <property2?>: <value2?>, ...},
{<property1?>: <value1?>, <property2?>: <value2?>, ...},
...
])
// Inserts edges
insert().into(<schema>).edges([
{_from: <fromValue>, _to: <toValue>, <property1?>: <value1?>, <property2?>: <value2?>, ...},
{_from: <fromValue>, _to: <toValue>, <property1?>: <value1?>, <property2?>: <value2?>, ...},
...
])
Method |
Param |
Description |
---|---|---|
into() |
<schema> |
Specifies the node or edge schema (e.g., @user ). |
nodes() or edges() |
List of property specifications | Defines the node(s) or edge(s) to be inserted into the specified schema, with each property specification wrapped in {} . |
In the property specifications, each provided property will be assigned its given value, while any missing custom properties will default to null
.
Please note:
- Node
_id
values will be generated by the system if not provided, though custom unique values can be assigned if desired. - Node and edge
_uuid
values are always generated by the system and cannot be manually assigned. - Edge properties
_from
and_to
must be provided to specify the source and destination nodes of the edge.
Properties in Schema-Free Graphs
In a schema-free graph, you can directly insert nodes and edges, and the corresponding schemas and properties will be automatically created on the fly. When a property is created, its value type is inferred from the first value provided. See the examples below:
Value Example | Description | Inferred Property Value Type |
---|---|---|
-20 , 1315 |
Any integer from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,806 |
INT64 |
100000000000000001 |
Any integer from 9,223,372,036,854,775,807 to 18,446,744,073,709,551,614 |
UINT64 |
18.25 |
Any decimal with up to 15 significant digits | DOUBLE |
"graph database" |
Any string with a length up to 60,000 bytes |
STRING |
"graph database is ..." |
Any string exceeding 60,000 bytes in length |
TEXT |
date("1993-05-09") |
Values returned by the date() function |
DATE |
local_datetime("1993-05-09 03:02:11") |
Values returned by the local_datetime() function |
LOCAL DATETIME |
local_time("03:02:11") |
Values returned by the local_time() function |
LOCAL TIME |
zoned_datetime("1993-05-09T03:02:11-0600") |
Values returned by the zaoned_datetime() function |
ZONED DATETIME |
zoned_time("03:02:11-06:00") |
Values returned by the zoned_time() function |
ZONED TIME |
TRUE , FALSE |
Boolean values | BOOL |
point({latitude:39.9, longitude:116.3}) |
Values returned by the point() function |
POINT |
point3d({x:10, y:3.2, z:5}) |
Values returned by the point3d() function |
POINT3D |
["tennis", "football", "swimming"] |
Constructed lists | LIST |
Example Graph

To create the graph, execute each of the following UQL queries sequentially in an empty graphset:
create().node_schema("user").edge_schema("follow")
create().node_property(@user, "name").node_property(@user, "age", int32).node_property(@user, "location", point).node_property(@user, "isBlocked", bool).node_property(@user, "permissionCodes", "set(uint32)").edge_property(@follow, "time", datetime)
insert().into(@user).nodes([{_id:"U001", name:"Jason", age:30}, {_id:"U002", name:"Tim"}, {_id:"U003", name:"Grace", age:25}, {_id:"U004", name:"Ted", age:26}])
insert().into(@follow).edges([{_from:"U004", _to:"U001", time:"2021-9-10"}, {_from:"U003", _to:"U001", time:"2020-3-12"}, {_from:"U004", _to:"U002", time:"2023-7-30"}])
Inserting a Single Node/Edge
To insert a @user
node:
insert().into(@user).nodes({_id: "U005", name: "Alice"})
To insert a @follow
edge:
insert().into(@follow).edges({_from: "U002", _to: "U001", time: "2023-8-9"})
When inserting a single node or edge, the outer brackets
[]
innodes()
oredges()
can be omitted.
Inserting Multiple Nodes/Edges
To insert three @user
nodes:
insert().into(@user).nodes([
{_id: "U006", name: "Lee", age: 12},
{name: "Alex"},
{}
])
To insert two @follow
edges:
insert().into(@follow).edges([
{_from: "U001", _to: "U002"},
{_from: "U004", _to: "U003", time: "2023-9-10"}
])
Returning Inserted Data
To insert two @follow
edges and return all the information of the inserted edges:
insert().into(@follow).edges([
{_from: "U001", _to: "U004"},
{_from: "U001", _to: "U003", time: "2022-2-7"}
]) as e
return e{*}
Result: e
_uuid |
_from |
_to |
_from_uuid |
_to_uuid |
schema |
values |
---|---|---|---|---|---|---|
Sys-gen | U001 | U004 | UUID of U001 | UUID of U004 | follow | {time: null } |
Sys-gen | U001 | U003 | UUID of U001 | UUID of U003 | follow | {time: "2022-02-07 00:00:00"} |
Inserting Boolean Values
A property of the bool
type accepts only 1
(or true
) or 0
(or false
).
Any positive integer other than
0
will be automatically converted to1
. Assigning other values may result in unpredictable behavior.
To insert a @user
node with a value for the property isBlocked
of type bool
:
insert().into(@user).nodes({isBlocked: 0})
Inserting Point Values
Use the point()
function to assign a value to a property of type point
. For example, to insert a @user
node with a value for the property location
of type point
:
insert().into(@user).nodes([
{location: point({latitude: 132.1, longitude: -1.5})}
]) as n
return n.location
Result:
n.location |
---|
POINT(132.1 -1.5) |
Use the point3d()
function to assign a value to a property of type point3d
. For example, to insert a @city
node with a value for the property landmark
of type point3d
:
insert().into(@city).nodes([
{landmark: point3d({x: 10, y: 3.2, z: 5})}
]) as n
return n.landmark
Result:
n.landmark |
---|
POINT3D(10 3.2 5) |
Inserting Record Values
To insert a @product
node with a value for the property specs
of type record
:
insert().into(@product).nodes([
{specs: {weight: "2kg", color: "red", warranty: "1y"}}
])
Inserting Blob Values
To insert a @user
node with a value for the property avatar
of type blob
:
with "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAB2AAAAdgB+lymcgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAA5rSURBVHicvZtpcFzVlcd/573Xi1pq7ZJXiBfwIoPDsBljMJJNDbZJgBDJxjjJEHaYgplKKhNmUpmBSiUzVYQMkEBgCmJCAsGInYBDANk1kNixYxuwMQiMsWUbWbIsa7Fa3f2WMx9aS0tqSb0o8//U/e5955577r1nu+cJ/89YtOjGhfn5eUtU3UtA5gGn9jWpKo0islWEN8vKWv5YX1/v/q35kVwJLF58Q+mWLY+3j9XnnHNuDvn97k88T9cFAv4y0zTTGfcwcG95ecUj9fV3x3PlczTkJIAlS67/z3jcucs0rfVbt/7q+uHtS5feON+2edB17RpVzLy8PEzTzHSYv6rq2s2bH96XC6+jIScBXHDBt1td160AME3zGMiThmG+r+rNV/Wu9Tz3S6qJvj6fn0AgkO1QXSK6sqHh4T/n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g99F0hZjjrhED4G/XcJldXnTmqCoKomkY7LQW8FLmOibrAG4QFvAL8kVPK6iExI5cXElXEnQaMds3C8WmAVwhKyVWxgI/wJj42YRr3kFX8+gWwCfyMBJEPb24sIcCHKmYhWgcwlEWUWMvAtgnaCdAHHQBtR2Qu6m7hskdLStD/PzQb/BzXqR+4x42zOAAAAAElFTkSuQmCC" as base64_string
insert().into(@user).nodes([
{avatar: base64_string}
])
Inserting List Values
To insert a @user
node with a value for the property interests
of type string[]
:
insert().into(@user).nodes([
{interests: ["violin", "tennis", "movie"]}
])
Inserting Set Values
To insert a @user
node with a value for the property permissionCodes
of type set(uint32)
:
insert().into(@user).nodes([
{permissionCodes: [1002, 1002, 1003, 1004]}
]) as n
return n.permissionCodes
Result:
n.permissionCodes |
---|
[1003,1004,1002] |
Element values within a set are automatically deduplicated.