Postgresql Loop Through Array Of Objects