Collect
| Information | |
|---|---|
| Type | Data Function |
| Namespace | moxlib:api/data/collect |
| Versions | 1.15+ |
Overview
Collects Objects in target based on whether they Compare with key. If they do,
they are returned in output.match. Otherwise, they are returned in output.remain.
Example
In this example, key is set to {id:1}, meaning any Object containing
an id of 1 will be returned in output.match.
data modify storage moxlib:api/data/collect target set value [{id:1,a:1},{id:1,b:1},{id:2,c:1}]
data modify storage moxlib:api/data/collect key set value {id:1}
function moxlib:api/data/collect
Contents of storage moxlib:api/data/collect
{
output: {
match: [{id:1,a:1},{id:1,b:1}],
remain: [{id:2,c:1}]
}
success: true
}
API
Expects
- Object Array
target - Object
key
Returns
- Object Array
output.match
Objects matching the given key.
- Object Array
output.remain
Objects not matching the given key.
- Boolean
success
If any match was found, true. Otherwise, false.