Converts a typed thing into a thing.
This function can only be used if the type of the typed thing is not required by any other type (including a self dependency). If the type is dependent by another type, then ThingsDB has no way to tell if it is allowed to do the conversion.
This function generates a change.
typed-thing.to_thing()
None
Returns nil
when successful.
This code converts a typed thing to a thing:
// Create a new type `Example`
new_type('Example');
// create a instance of Example
sample = Example{};
// this will raise an error as type Example does not allow property `name`
is_err(try(sample.name = 'Test'));
// convert to a thing
sample.to_thing();
// we now can set any property we like
sample.name = 'Test';
sample;
Return value in JSON format
{
"name": "Test"
}