UpdateImage

Updates existing Image objects that satisfy the specified constraints.

Parameters

ref and constraints are optional and are intersected when both are present. Scope warning: omitting all selectors targets every Image object. Always supply selectors for a scoped mutation.

Parameter

JSON type

Behavior

constraints

array expression

Optional. No property filter; the command-specific selector requirement still applies. Filters existing objects using the constraints expression language. When ref is supplied it filters that referenced set.

properties

object mapping property names to values

Optional. When omitted, existing user properties are unchanged except for keys listed in remove_props. Stores booleans, numbers, strings, supported arrays, or single-key _date, _blob, and _json wrappers. Bare null is rejected; property names and wrapped values are validated. See the properties reference for nested value rules. Replaces supplied property values without replacing the whole property map.

ref

integer, 1 through 100000

Optional. Select using the other supplied selectors; see the selection rule above. Uses an earlier compatible Image reference in this transaction; forward references, wrong types, and undeclared references are rejected.

remove_props

array of strings

Optional. When omitted, no properties are removed. Removes named properties from selected objects; missing keys have no effect. A value also supplied in properties is stored after removal.

Details

If the ref parameter is used, constraints will act as additional filters on the referenced result set.

If the ref parameter is specified, it must refer to the search result of a previous FindImage.

For more complex searches for objects to update, a Find command must be used first within the transaction.

Response and errors

An authenticated session with the objects update permission is required.

The response is an object under UpdateImage with integer status and, on success, integer count. Status 0 means the mutation completed; count is the number of selected objects affected, including zero when none match. No output blobs are returned.

Invalid field types, missing required fields, malformed expressions, and invalid references fail validation. Execution failures include a nonzero status and an info message; inspect the transaction response before assuming a mutation succeeded. This command updates metadata; it does not replace stored binary content.

Examples

Find the images with the “year_captured” property equal to 2007, and remove the “focal_length” property:

[{
    "UpdateImage": {
        "constraints": ["$year_captured", "==", 1990],
        "remove_props": ["focal_length"]
    }
}]

Successful response:

[{
    "UpdateImage": {
        "count": 1,
        "status": 0
    }
}]

Find an image with the “year_captured” property equal to 2007, verify that only one image satisfy the constraint, update the “focal_length_mm” property:

[{
    "UpdateImage": {
        "constraints": ["$year_captured", "==", 1992],
        "properties": {
            "focal_length_mm": 55
        }
    }
}]

Successful response:

[{
    "UpdateImage": {
        "count": 1,
        "status": 0
    }
}]

Remove “focal_lenght” property from all the images that are connected to an entity of the class “Dataset” and with a property “name” equal to “COCO”:

[{
    "FindEntity": {
        "with_class": "Dataset",
        "_ref": 1,
        "constraints": ["$name", "==", "COCO"]
    }
}, {
    "FindImage": {
        "_ref": 2,
        "is_connected_to": {
            "ref": 1,
            "connection_class": "in_dataset"
        },
        "blobs": false
    }
}, {
    "UpdateImage": {
        "ref": 2,
        "remove_props": ["focal_length"]
    }
}]

Successful response:

[{
    "FindEntity": {
        "status": 0,
        "returned": 0
    }
}, {
    "FindImage": {
        "status": 0,
        "returned": 0
    }
}, {
    "UpdateImage": {
        "count": 1,
        "status": 0
    }
}]