I have a table in a postgres DB which contains a jsonb column let's call it "data" that contains very large array stored as the following format
[
{
"id" : 1
"title" : "title 1",
"description" : "description 1",
},
{
"id" : 2
"title" : "title 2",
"description" : "description 2",
} // etc... until 1GB of data
]
My eloquent model contains the following declaration.
class Item extends Model
{
protected $casts = [
'data' => 'array'
];
If I use a statement like this
$array = $item->data;
It will cause an out of memory exception so how can I iterate over the array and preferably uses the cast in the model without loading the entire data into memory ?