Postgres Loop Through Array React