Mongo.Db

Module holding operations that can be performed on MongoDB databases

Source

Summary

auth!(username, password, db)

See auth/3

auth(db, username, password)

Authenticates a user to a database

auth?(db)

Check authentication

cmd!(db, command)

See cmd/2

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

Executes a db command

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)

See getLastError/1

getLastError(db)

Returns the error status of the preceding operation

getPrevError!(db)

See getPrevError/1

getPrevError(db)

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

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

resetError!(db)

See resetError/1

resetError(db)

Resets error

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{}

Source
auth!(username, password, db)

See auth/3

Source
auth?(db)

Check authentication

returns true if authentication was performed and succesful

Source
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

Source
cmd!(db, command)

See cmd/2

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

Executes a db command requesting imediate response

Source
coll_opts(db)

Gets collection default options

Source
collection(db, name)

Returns a collection struct

Source
getLastError(db)

Returns the error status of the preceding operation.

Source
getLastError!(db)

See getLastError/1

Source
getPrevError(db)

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

Source
getPrevError!(db)

See getPrevError/1

Source
kill_cursor(db, cursorID)

Kill a cursor of the db

Source
new(mongo, name)

Creates %Mongo.Db{} with default options

Source
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
Source
resetError(db)

Resets error

Source
resetError!(db)

See resetError/1

Source