Method: Mongoid::Contextual::Mongo#length

Defined in:
lib/mongoid/contextual/mongo.rb

#lengthInteger Also known as: size

Get’s the number of documents matching the query selector.

Examples:

Get the length.

context.length

Returns:

  • (Integer)

    The number of documents.

Since:

  • 3.0.0



351
352
353
# File 'lib/mongoid/contextual/mongo.rb', line 351

def length
  @length ||= self.count
end