const classafMongo::MongoClient
sys::Obj afMongo::MongoClient
A MongoDB client.
This class is the main starting point for connecting to a MongoDB instance.
Retrieving data from a MongoDB can be as easy as:
mongo := MongoClient(ActorPool(), `mongodb://localhost:27017`)
data := mongo.db("db").collection("col").findAll
Or using defaults and shorthand notation:
mongo := MongoClient(ActorPool()) data := mongo["db"]["col"].findAll
- buildInfo
Returns a build summary
@see http://docs.mongodb.org/manual/reference/command/buildInfo/
- databaseNames
Str[] databaseNames()Returns all the database names on the MongoDB instance.
- db
Database db(Str dbName)Returns a
Databasewith the given name.Note this just instantiates the Fantom object, it does not create anything in the database.
- get
@Operator
Database get(Str dbName)Convenience / shorthand notation for
db(name)- hostInfo
Returns info about the underlying MongoDB system.
@see http://docs.mongodb.org/manual/reference/command/hostInfo/
- listCommands
Returns a list of database commands.
@see http://docs.mongodb.org/manual/reference/command/listCommands/
- listDatabases
Returns a list of existing databases with some basic statistics.
@see http://docs.mongodb.org/manual/reference/command/listDatabases/
- make
new make(ConnectionManager connectionManager, |This? f := null)Creates a
MongoClientwith the givenConnectionManager. This is the preferred ctor.- makeFromUri
new makeFromUri(ActorPool actorPool, Uri mongoUri := `mongodb://localhost:27017`, |This? f := null)A convenience ctor - just to get you started!
- runAdminCmd
Str:Obj? runAdminCmd(Str:Obj? cmd)Runs a command against the admin database. Convenience for:
db("admin").runCmd(cmd)- serverStatus
Returns an overview of the database process’s state.
@see http://docs.mongodb.org/manual/reference/command/serverStatus/
- shutdown
Void shutdown()Convenience for
connectionManager.shutdown.