lib/mongoid/contextual/mongo.rb in mongoid-4.0.0 vs lib/mongoid/contextual/mongo.rb in mongoid-4.0.1
- old
+ new
@@ -52,11 +52,11 @@
#
# @since 3.0.0
def count(document = false, &block)
return super(&block) if block_given?
if document.is_a?(Document)
- return collection.find(criteria.and(_id: document.id).selector).count
+ return collection.find(criteria.and(_id: document._id).selector).count
end
return query.count(document) if document
try_cache(:count) { query.count }
end
@@ -348,12 +348,12 @@
query.dup.select(normalized_select).map do |doc|
if normalized_select.size == 1
doc[normalized_select.keys.first]
else
- normalized_select.keys.map { |n| doc[n] }.compact
+ normalized_select.keys.map { |n| doc[n] }
end
- end.compact
+ end
end
# Skips the provided number of documents.
#
# @example Skip the documents.