Class: Mongo::Database::View
- Inherits:
-
Object
- Object
- Mongo::Database::View
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/mongo/database/view.rb
Overview
A class representing a view of a database.
Instance Attribute Summary collapse
-
#batch_size ⇒ Integer
readonly
Batch_size The size of the batch of results when sending the listCollections command.
-
#collection ⇒ Collection
readonly
Collection The command collection.
-
#limit ⇒ Integer
readonly
Limit The limit when sending a command.
Instance Method Summary collapse
-
#collection_names(options = {}) ⇒ Array<String>
Get all the names of the non system collections in the database.
-
#initialize(database) ⇒ View
constructor
Create the new database view.
-
#list_collections ⇒ Array<Hash>
Get info on all the collections in the database.
Constructor Details
Instance Attribute Details
#batch_size ⇒ Integer (readonly)
Returns batch_size The size of the batch of results when sending the listCollections command.
30 31 32 |
# File 'lib/mongo/database/view.rb', line 30 def batch_size @batch_size end |
#collection ⇒ Collection (readonly)
Returns collection The command collection.
36 37 38 |
# File 'lib/mongo/database/view.rb', line 36 def collection @collection end |
#limit ⇒ Integer (readonly)
Returns limit The limit when sending a command.
33 34 35 |
# File 'lib/mongo/database/view.rb', line 33 def limit @limit end |
Instance Method Details
#collection_names(options = {}) ⇒ Array<String>
Get all the names of the non system collections in the database.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mongo/database/view.rb', line 51 def collection_names( = {}) @batch_size = [:batch_size] server = next_primary(false) @limit = -1 if server.features.list_collections_enabled? collections_info(server).collect do |info| if server.features.list_collections_enabled? info[Database::NAME] else (info[Database::NAME] && info[Database::NAME].sub("#{@database.name}.", '')) end end end |
#list_collections ⇒ Array<Hash>
Get info on all the collections in the database.
73 74 75 |
# File 'lib/mongo/database/view.rb', line 73 def list_collections collections_info(next_primary(false)) end |