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 MongoDB can be as easy as:

mongo := MongoClient(ActorPool(), "127.0.0.1", 27017)
data  := mongo.db("db").collection("col").findAll

Or using defaults and shorthand notation:

mongo := MongoClient(ActorPool())
data  := mongo["db"]["col"].findAll
buildInfo

Source

Str:Obj? buildInfo()

databaseNames

Source

Str[] databaseNames()

Returns all the database names on the MongoDB instance.

db

Source

Database db(Str dbName)

Returns a Database with the given name.

Note this just instantiates the Fantom object, it does not create anything in the database.

get

Source

@Operator
Database get(Str dbName)

Convenience / shorthand notation for db(name)

hostInfo

Source

Str:Obj? hostInfo()

Returns info about the underlying MongoDB system.

@see http://docs.mongodb.org/manual/reference/command/hostInfo/

listCommands

Source

Str:Obj? listCommands()

listDatabases

Source

Str:Obj?[] listDatabases()

Returns a list of existing databases with some basic statistics.

@see http://docs.mongodb.org/manual/reference/command/listDatabases/

make

Source

new make(ConnectionManager connectionManager, |This? f := null)

Creates a MongoClient with the given ConnectionManager. This is the preferred ctor.

makeFromIpAddr

Source

new makeFromIpAddr(ActorPool actorPool, Str address := "127.0.0.1", Int port := 27017, |This? f := null)

A convenience ctor - just to get you started!

runAdminCmd

Source

Str:Obj? runAdminCmd(Str:Obj? cmd)

Runs a command against the admin database.

serverStatus

Source

Str:Obj? serverStatus()

Returns an overview of the database process’s state.

@see http://docs.mongodb.org/manual/reference/command/serverStatus/

shutdown

Source

Void shutdown()

Convenience for connectionManager.shutdown.

writeConcern

Source

const Str:Obj? writeConcern := MongoConstants.defaultWriteConcern

This write concern is passed down to all Database instances created from this client.