-
Notifications
You must be signed in to change notification settings - Fork 1
Reference
Client accepts MongoDB connection string as a parameter. If no string provided - mongodb://localhost:27017
will be used.
This method returns array with databases stored on provided to client server(s).
This method creates Mongo::Database
instance connected with this client.
This method provides reader for client's address.
This method returns true
if database exists on server
Database can be initialized via Mongo::Client#[]
method or direct by Mongo::Database.new(client, name)
. It awaits Mongo::Client
instance as argument.
This method provides reader for database's client.
This method returns array with collections stored within this database.
This method creates Mongo::Collection
instance connected with this database.
Collection can be initialized via Mongo::Database#[]
method or direct by Mongo::Collection.new(db, name)
. It awaits Mongo::Database
instance as argument.
This method provides reader for collection's database.
This methods returns number of documents in collection.
This method awaits Hash
instance as argument and returns inserted document with fulfilled _id
field.
This method awaits optional Hash
instance. This hash will be used as query for documents removing. Example:
collection.drop(status: 'ok') # it should drop all documents with {status: 'ok'}
collection.drop # it should drop all documents in collection
This methods awaits two required Hash
arguments and one optional boolean.
# format is corresponding to: http://docs.mongodb.org/v2.4/reference/method/db.collection.update
collection.update(query, update) # this should be executed as db.collection.update(query, update, false, true)
collection.update(query, update, true) # this should be executed as db.collection.update(query, update, true, true)
So, for #update
method multiple
flag is always set to true.
This method instantiates Mongo::Query
and awaits optional hash argument which should be used as query. If no argument passed - blank query should be used.
Query can be initialized via Mongo::Collection#where
or with Mongo::Query.new(collection, query)
, where first argument is Mongo::Collection
object and second argument is query hash.
Instantiates new Mongo::Query
instance from existing but adding sort hash to it. Uses default MongoDB sorting rules.
Instantiates new Mongo::Query
instance from existing but adding limit of documents to return to it.
Instantiates new Mongo::Query
instance from existing but adding amount of documents to skip to it.
Instantiates new Mongo::Query
instance from existing but adding "fields to return" hash to it.
Returns number of documents which are satisfying query.
Returns documents of query as array of hashes.
BSON is data-type provided for testing hash-to-BSON conversions. You can take a closer look in include/conversions.h
.