# File lib/aws/simple_db/item_collection.rb, line 240
      def count options = {}, &block
        return if handle_query_options(:count, options, &block)

        options = options.merge(:output_list => "count(*)")

        count = 0
        next_token = nil

        while limit.nil? || count < limit and
            response = select_request(options, next_token)

          if domain_item = response.items.first and
              count_attribute = domain_item.attributes.first
            count += count_attribute.value.to_i
          end

          next_token = response.next_token
          break unless next_token

        end

        count
      end