Class: Marbu::Models::Db::MongoDb::Structure

Inherits:
Object
  • Object
show all
Defined in:
lib/marbu/models/db/mongodb/structure.rb

Class Method Summary collapse

Class Method Details

.get_collection_structure(collection_info) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/marbu/models/db/mongodb/structure.rb', line 6

def self.get_collection_structure( collection_info )
  raise "collection_info needs to be Marbu::Models::Misc, but is: #{collection_info.class}" unless collection_info.is_a?(Marbu::Models::Misc)

  collection  = collection_info.collection
  document    = collection.find().first()

  get_collection_structure_int(document)
end

.get_first_and_last_document(collection_info) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/marbu/models/db/mongodb/structure.rb', line 15

def self.get_first_and_last_document( collection_info )
  raise "collection_info needs to be Marbu::Models::Misc, but is: #{collection_info.class}" unless collection_info.is_a?(Marbu::Models::Misc)

  collection  = collection_info.collection

  [collection.find().sort([['_id', 1]]).first(), collection.find().sort([['_id', -1]]).first()]
end