Sql While Loop Through Array Of Objects Javascript