The nro (no-read-only) action temporarily lifts the read-only (ro) restriction on a specific property while a callback closure executes.
This is useful when you need to update a read-only property (for example, incrementing a schema_version during a migration) without temporarily removing and re-applying (ro) via mod_type(..., 'mod', ...). If an error occurs inside the callback, the property remains safely read-only.
mod_type(type, 'nro', property, callback)
| Argument | Type | Description |
|---|---|---|
| type | str | Name of the Type to modify. |
'nro' |
str | Passing this argument will result in a no-read-only action. |
| property | str | Name of the read-only (ro) property to temporarily allow writing to. Cannot be an ID (#) definition or a method. |
| callback | closure | Closure executed once while the read-only restriction on property is lifted. |
The value nil.
This code shows how to update a read-only property using the action nro:
// Create type `Schema` with a read-only version property
set_type('Schema', {
version: 'pint(ro)',
});
.schema = Schema{version: 1};
// Temporarily allow modifying `version`
mod_type('Schema', 'nro', 'version', || {
.schema.version = 2;
});
.schema.version;
Return value in JSON format
2