mongo v0.5.4 Mongo.Db

Module holding operations that can be performed on MongoDB databases

Summary

Functions

Authenticates a user to a database

Check authentication

Executes a db command

See cmd/2

Executes a db command requesting imediate response

Gets collection default options

Returns a collection struct

Returns the error status of the preceding operation

See getLastError/1

Returns the previous error status of the preceding operation(s)

See getPrevError/1

Kill a cursor of the db

Creates %Mongo.Db{} with default options

Adds options to the database overwriting mongo server connection options

Resets error

See resetError/1

Functions

auth(db, username, password)

Authenticates a user to a database

Expects a DB struct, a user and a password returns {:ok, db} or %Mongo.Error{}

auth!(username, password, db)

See auth/3

auth?(db)

Check authentication

returns true if authentication was performed and succesful

cmd(db, cmd, cmd_args \\ %{})

Executes a db command

Before using this check Mongo.Collection, Mongo.Db or Mongo.Server for commands already implemented by these modules

cmd!(db, command)

See cmd/2

cmd_sync(db, command, cmd_args \\ %{})

Executes a db command requesting imediate response

coll_opts(db)

Gets collection default options

collection(db, name)

Returns a collection struct

getLastError(db)

Returns the error status of the preceding operation.

getLastError!(db)

See getLastError/1

getPrevError(db)

Returns the previous error status of the preceding operation(s).

getPrevError!(db)

See getPrevError/1

kill_cursor(db, cursorID)

Kill a cursor of the db

new(mongo, name)

Creates %Mongo.Db{} with default options

opts(db, new_opts)

Adds options to the database overwriting mongo server connection options

new_opts must be a map with zero or more of the following keys:

  • read: :awaitdata, :nocursortimeout, :slaveok, :tailablecursor
  • write concern: :wc
  • socket: :mode, :timeout
resetError(db)

Resets error

resetError!(db)

See resetError/1