Learn R Programming

rmongodb (version 1.8.0)

mongo.destroy: Destroy a MongoDB connection

Description

Destroy a mongo connection. The connection is disconnected first if it is still connected. No further communication is possible on the connection. Releases resources attached to the connection on both client and server.

Usage

mongo.destroy(mongo)

Arguments

mongo
(mongo) a mongo connection object.

Details

Although the 'destroy' functions in this package are called automatically by garbage collection, this one in particular should be called as soon as feasible when finished with the connection so that server resources are freed.

See Also

mongo, mongo.disconnect, mongo.is.connected mongo.reconnect.

Examples

Run this code
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    n_people <- mongo.count(mongo, "test.people")
    mongo.destroy(mongo)
    print(n_people)
}

Run the code above in your browser using DataLab