Module: Minimongo::Query

Defined in:
lib/minimongo/query.rb

Instance Method Summary collapse

Instance Method Details

#all(*g) ⇒ Object



28
# File 'lib/minimongo/query.rb', line 28

def all(*g); find(*g).to_a; end

#count(*g) ⇒ Object



27
# File 'lib/minimongo/query.rb', line 27

def count(*g); find(*g).count; end

#first(*g) ⇒ Object

First, last, count, all



25
# File 'lib/minimongo/query.rb', line 25

def first(*g); find(*g).limit(-1).first; end

#last(*g) ⇒ Object



26
# File 'lib/minimongo/query.rb', line 26

def last(*g); find(*g).limit(-1).sort(:$natural => -1).first; end

#oid(v = nil) ⇒ Object

Creates a BSON::ObjectId from a string, or a new one Use with: oid(string), or oid, oid(:new), oid(nil) to create a new BSON::ObjectId



19
# File 'lib/minimongo/query.rb', line 19

def oid(v = nil); BSON::ObjectId.from_string(v) rescue BSON::ObjectId.new; end