minor: cleanup
This commit is contained in:
parent
df80704f77
commit
e621db732e
@ -112,19 +112,18 @@ module Mongo
|
|||||||
#
|
#
|
||||||
# @param [Boolean] whether of not to take notice of skip and limit
|
# @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
|
# @return [Integer] the number of objects in the result set for this query.
|
||||||
# not take limit and skip into account.
|
|
||||||
#
|
#
|
||||||
# @raise [OperationFailure] on a database error.
|
# @raise [OperationFailure] on a database error.
|
||||||
def count skip_and_limit = false
|
def count(skip_and_limit = false)
|
||||||
command = BSON::OrderedHash["count", @collection.name,
|
command = BSON::OrderedHash["count", @collection.name, "query", @selector]
|
||||||
"query", @selector]
|
|
||||||
if skip_and_limit
|
if skip_and_limit
|
||||||
command.merge! BSON::OrderedHash["limit", @limit] if @limit != 0
|
command.merge!(BSON::OrderedHash["limit", @limit]) if @limit != 0
|
||||||
command.merge! BSON::OrderedHash["skip", @skip] if @skip != 0
|
command.merge!(BSON::OrderedHash["skip", @skip]) if @skip != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
command.merge! BSON::OrderedHash["fields", @fields]
|
command.merge!(BSON::OrderedHash["fields", @fields])
|
||||||
|
|
||||||
response = @db.command(command)
|
response = @db.command(command)
|
||||||
return response['n'].to_i if Mongo::Support.ok?(response)
|
return response['n'].to_i if Mongo::Support.ok?(response)
|
||||||
|
Loading…
Reference in New Issue
Block a user