Class: Tina4::DocStore::MongoCollection

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/tina4/docstore.rb

Overview

A Mongo::Collection that also answers find_one, and whose find returns a cursor answering to_list.

Instance Method Summary collapse

Instance Method Details

#find(*args, &block) ⇒ Object

Pure pass-through plus wrapping. The argument list is NOT re-declared, so the driver keeps deciding what find accepts.



794
795
796
# File 'lib/tina4/docstore.rb', line 794

def find(*args, &block)
  MongoView.new(__getobj__.find(*args, &block))
end

#find_one(filter = nil, projection = nil) ⇒ Object

pymongo's signature, which the Python master already ships. On the driver a projection is an OPTION rather than a positional, so it is spelled the driver's way here; the meaning is identical.



802
803
804
805
# File 'lib/tina4/docstore.rb', line 802

def find_one(filter = nil, projection = nil)
  view = projection ? __getobj__.find(filter || {}, projection: projection) : __getobj__.find(filter || {})
  view.first
end