new upsert(resourceType, query, data, optionsopt, callbackopt) → {Operation}
Upsert a record. A generic helper function used to atomically either insert a row, or on the basis of the row already existing, UPDATE that existing row instead.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
resourceType |
string | The type of a resource to `upsert`. E.g. `trackedEntityInstances` | |
query |
Object | A query object that allows to uniquely identify the resource to update. If no matches found, then the resource will be created. | |
data |
Object | The data to use for update or create depending on the result of the query. | |
options |
Object |
<optional> |
Optional configuration that will be applied to both the `get` and the `create` or `update` operations. |
callback |
function |
<optional> |
Optional callback to handle the response |
- Source:
Throws:
-
- Throws range error
- Type
- RangeError
Returns:
- Type
- Operation
Example
upsert('trackedEntityInstances', {
ou: 'TSyzvBiovKh',
filter: ['w75KJ2mc4zz:Eq:Qassim'],
}, {
orgUnit: 'TSyzvBiovKh',
trackedEntityType: 'nEenWmSyUEp',
attributes: [
{
attribute: 'w75KJ2mc4zz',
value: 'Qassim',
},
],
});