minor: cleanup

This commit is contained in:
Kyle Banker 2010-11-24 14:01:26 -05:00
parent df80704f77
commit e621db732e
1 changed files with 7 additions and 8 deletions

View File

@ -112,19 +112,18 @@ module Mongo
#
# @param [Boolean] whether of not to take notice of skip and limit
#
# @return [Integer] the number of objects in the result set for this query. Does
# not take limit and skip into account.
# @return [Integer] the number of objects in the result set for this query.
#
# @raise [OperationFailure] on a database error.
def count skip_and_limit = false
command = BSON::OrderedHash["count", @collection.name,
"query", @selector]
def count(skip_and_limit = false)
command = BSON::OrderedHash["count", @collection.name, "query", @selector]
if skip_and_limit
command.merge! BSON::OrderedHash["limit", @limit] if @limit != 0
command.merge! BSON::OrderedHash["skip", @skip] if @skip != 0
command.merge!(BSON::OrderedHash["limit", @limit]) if @limit != 0
command.merge!(BSON::OrderedHash["skip", @skip]) if @skip != 0
end
command.merge! BSON::OrderedHash["fields", @fields]
command.merge!(BSON::OrderedHash["fields", @fields])
response = @db.command(command)
return response['n'].to_i if Mongo::Support.ok?(response)