Class: Faststep::Collection
- Inherits:
-
Object
- Object
- Faststep::Collection
- Defined in:
- ext/faststep/collection.c,
lib/faststep/collection.rb
Instance Attribute Summary (collapse)
-
- (Object) db
readonly
Returns the value of attribute db.
-
- (Object) name
readonly
Returns the value of attribute name.
Instance Method Summary (collapse)
- - (Object) connection
- - (Object) count
- - (Object) create_index
- - (Object) drop
- - (Object) drop_index(index_name)
- - (Object) find
- - (Object) find_one
- - (Object) index_information
-
- (Collection) initialize(name, db)
constructor
A new instance of Collection.
- - (Object) insert
- - (Object) ns
- - (Object) remove
- - (Object) rename(new_name)
- - (Object) update
Constructor Details
- (Collection) initialize(name, db)
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
- (Object) db (readonly)
Returns the value of attribute db
3 4 5 |
# File 'lib/faststep/collection.rb', line 3 def db @db end |
- (Object) name (readonly)
Returns the value of attribute name
3 4 5 |
# File 'lib/faststep/collection.rb', line 3 def name @name end |
Instance Method Details
- (Object) connection
10 11 12 |
# File 'lib/faststep/collection.rb', line 10 def connection db.connection end |
- (Object) count
- (Object) create_index
- (Object) drop
- (Object) drop_index(index_name)
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 |
- (Object) find
- (Object) find_one
- (Object) index_information
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 |
- (Object) insert
- (Object) ns
- (Object) remove
- (Object) rename(new_name)
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 |