Skip to content

Set

Information
Type Data Function
Namespace moxlib:api/data/set
Versions 1.15+

Overview

If a record in target successfully Compares with key, that record has data merged into it.

If no record is found, a new record is created, and appended to target, merging key and data together.

The modified target is returned as output.

Example

In this example, the record in target, {id:2,b:1}, is updated to have a value of {b:2}.

data modify storage moxlib:api/data/set target set value [{id:1,a:1},{id:2,b:1},{id:3,c:1}]
data modify storage moxlib:api/data/set key set value {id:2}
data modify storage moxlib:api/data/set data set value {b:2}
function moxlib:api/data/set
Output of storage moxlib:api/data/set
{
  output: [{id:1,a:1},{id:2,b:2},{id:3,c:1}],
  success: true
}

API

Expects

Returns

The same array as target, but containing the new or updated record.


If modification was successful, true. Otherwise, false.