UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Reserved Words
    • Data Types
    • Alias
    • Operators
    • Expression
    • Filter
    • Prefix
    • Node and Edge Templates
    • Homologous and Heterologous Data
    • Clause Execution Times
    • Graphset
    • Schema
    • Property
    • Insert
    • Overwrite
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • Find Subgraphs
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • BATCH
      • Schema Checker
      • Equal
      • Not Equal
      • Less Than
      • Greater Than
      • Less Than or Equal
      • Greater Than or Equal
      • Between
      • Between or Equal
      • Beong to
      • Not Belong To
      • CONTAINS | String
      • CONTAINS | Full-Text
      • Regular Match
      • IS NULL
      • IS NOT NULL
      • And
      • Or
      • Not
      • Exclusive OR
      • DISTINCT
      • toString()
      • toInteger()
      • toFloat()
      • toDouble()
      • toDecimal()
      • toSet()
      • castToRaw()
      • now()
      • dateAdd()
      • dateDiff()
      • year()
      • month()
      • day()
      • dayOfWeek()
      • dateFormat()
      • point()
      • distance()
      • pointInPolygon()
      • lower()
      • upper()
      • reverse()
      • startsWith()
      • endsWith()
      • JSON_decode()
      • JSON_merge()
      • trim()
      • ltrim()
      • rtrim()
      • left()
      • right()
      • substring()
      • replace()
      • split()
      • intersection()
      • difference()
      • listUnion()
      • size()
      • head()
      • reduce()
      • listContains()
      • append()
      • pi()
      • pow()
      • sqrt()
      • abs()
      • floor()
      • ceil()
      • round()
      • sin()
      • cos()
      • tan()
      • cot()
      • asin()
      • acos()
      • atan()
      • length()
      • pnodes()
      • pedges()
      • count()
      • sum()
      • max()
      • min()
      • avg()
      • stddev()
      • collect()
      • dedup()
      • CASE
      • table()
      • coalesce()
      • ifnull()
    • Acceleration
    • Index
    • Full-text
    • LTE
    • Real-time Process
    • Backend Task
    • Analytics Node
    • Server Statistics
    • Server Backup
    • Privilege
    • Policy
    • User
  • Trigger
  1. Docs
  2. /
  3. UQL
  4. /
  5. Insert | Update | Delete

Update

Overview

The update() clauses is used to update values of properties (except _id and _uuid) of nodes and edges that meet the given conditions.

Syntax

Syntax
// Update nodes
update().nodes(<filter>)
  .set({<property1>: <value1>, <property2>: <value2> ...})
  .limit(<N>)

// Update edges
update().edges(<filter>)
  .set({<property1>: <value1>, <property2>: <value2> ...})
  .limit(<N>)
  • The nodes or edges to be updated must meet the conditions specified in the nodes() or edges() method. Leave it blank to specify all nodes or edges.
  • Provide new values for properties in the set() method.
  • Optionally use the limit() method to restrict the number of nodes or edges to update.
  • Allow to define an alias for the clause, with the data type being either NODE or EDGE.

Example Graph

Run these UQLs row by row in an empty graphset to create this graph:

UQL
create().node_schema("user").edge_schema("follow")
create().node_property(@user, "name").node_property(@user, "age", int32).edge_property(@follow, "time", datetime)
Click to expand

Examples

Update Nodes

UQL
update().nodes({name == "Tim"}).set({name: "Tom"})

This updates the name property of nodes whose name is Tim. The node with _id U002 is updated.

Update Edges

UQL
update().edges({time > "2021-5-1"}).set({time: dateAdd(time, 1, "day")}) as edges
return edges{*}

This updates the time property of edges whose time is later than 2021-5-1, to one day after.

Result:

_uuid_from_to
_from_uuid
_to_uuid
time
1U004U001412021-09-11 00:00:00
3U004U002422023-07-31 00:00:00

Update All Nodes/Edges

UQL
update().nodes().set({age: age + 1}) as n
return table(n.name, n.age)

Result:

nameage
Jason31
Tomnull
Grace26
Ted27

Update Limited Nodes/Edges

UQL
update().nodes({@user}).set({name: lower(name)}).limit(2) as nodes
return nodes{*}

This updates the name property of @user nodes to lowercase characters, but only for two nodes.

Result:

_id_uuidnameage
U0011jason31
U0022tomnull

Common Reasons for Failures

  • Update fails when _uuid or _id is included in the set() method, as unique identifier properties cannot be updated.