Investigate json field storage
Closed this issue · 2 comments
The spatie medialibrary has a custom_properties json field on the media model.
Data within it gets stored as a json string instead of a proper json object:
"custom_properties" => "{"directory":"species/damer-damer"}"
This is probably caused by json-array casting in the Eloquent builder. We can replace it by a regular json object which allows for indexing etc.
The MediaModel has the following casts:
protected $casts = [
'manipulations' => 'array',
'custom_properties' => 'array',
'generated_conversions' => 'array',
'responsive_images' => 'array',
];
The HasAttributes casts the values to a json string. See the castAttribute function.
The array, json, collection and object casts are all converted to and from json strings.
As the driver already takes care of this later on in the process and we don't want that here.
Storing the data as json instead of a json string allows us to make full use of ArangoDB's features such as indexing embedded properties
Fixed in v1.0.0-beta3