Class: Faststep::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/faststep/collection.rb,
ext/faststep/collection.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, db) ⇒ Collection

Returns a new instance of Collection.



5
6
7
8
# File 'lib/faststep/collection.rb', line 5

def initialize(name, db)
  @name = name
  @db   = db
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



3
4
5
# File 'lib/faststep/collection.rb', line 3

def db
  @db
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/faststep/collection.rb', line 3

def name
  @name
end

Instance Method Details

#connectionObject



10
11
12
# File 'lib/faststep/collection.rb', line 10

def connection
  db.connection
end

#countObject

#create_indexObject

#dropObject

#drop_index(index_name) ⇒ Object



31
32
33
34
# File 'lib/faststep/collection.rb', line 31

def drop_index(index_name)
  db.command(:deleteIndexes => self.name, :index => index_name)
  true
end

#findObject

#find_oneObject

#index_informationObject



14
15
16
17
18
19
20
# File 'lib/faststep/collection.rb', line 14

def index_information
  info = {}
  db["system.indexes"].find({:ns => ns}).each do |index|
    info[index['name']] = index
  end
  info
end

#insertObject

#nsObject

#removeObject

#rename(new_name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/faststep/collection.rb', line 22

def rename(new_name)
  command = BSON::OrderedHash.new
  command[:renameCollection] = ns
  command[:to] = "#{db.name}.#{new_name}"
  connection["admin"].command(command)
  @name = new_name
  true
end

#updateObject