Module mc_worker_api

Data Types

arg()

arg() = {database, database()} | {login, binary()} | {password, binary()} | {w_mode, write_mode()} | {r_mode, read_mode()} | {host, list()} | {port, integer()} | {ssl, boolean()} | {ssl_opts, proplists:proplist()} | {register, atom() | function()}

args()

args() = [arg()]

colldb()

colldb() = collection() | {database(), collection()}

collection()

collection() = binary() | atom()

cursor()

cursor() = pid()

database()

database() = binary() | atom()

query()

query() = #query{database = database(), collection = colldb(), tailablecursor = boolean(), slaveok = boolean(), sok_overriden = boolean(), nocursortimeout = boolean(), awaitdata = boolean(), skip = mc_worker_api:skip(), batchsize = mc_worker_api:batchsize(), selector = mc_worker_api:selector(), projector = mc_worker_api:projector()}

read_mode()

read_mode() = master | slave_ok

selector()

selector() = map() | bson:document()

write_mode()

write_mode() = unsafe | safe | {safe, bson:document()}

Function Index

connect/0shortcut for connect/1 with default params.
connect/1Make one connection to server, return its pid.
disconnect/1
database/2Switch database.
get_version/1
insert/3Insert a document or multiple documents into a collection.
insert/4
insert/5
insert/1Insert one document or multiple documents into a colleciton.
update/4Replace the document matching criteria entirely with the new Document.
update/6Replace the document matching criteria entirely with the new Document.
update/7Replace the document matching criteria entirely with the new Document.
update/8Replace the document matching criteria entirely with the new Document.
update/1Replace the document matching criteria entirely with the new Document.
delete/3Delete selected documents.
delete_one/3Delete first selected document.
delete_limit/4Delete selected documents.
delete_limit/5Delete selected documents.
delete_limit/6Delete selected documents.
delete/1Delete selected documents params: connection - mc_worker pid collection - collection() selector - selector() database - insert in this database (optional) num - int() number of documents (optional).
find_one/3Return first selected document, if any.
find_one/4Return first selected document, if any.
find_one/5Return first selected document, if any.
find_one/1Return projection of selected documents.
find_one/2
find/3Return selected documents.
find/4
find/5Return projection of selected documents.
find/1Return projection of selected documents.
find/2
count/3Count selected documents.
count/4Count selected documents up to given max number; 0 means no max.
count/2
count/1Return projection of selected documents.
ensure_index/3Create index on collection according to given spec.
ensure_index/4
command/2Execute given MongoDB command and return its result.
command/3Execute given MongoDB command on specific database and return its result.
command/4

Function Details

connect/0

connect() -> any()

shortcut for connect/1 with default params.

connect/1

connect(Args::args()) -> {ok, pid()}

Make one connection to server, return its pid

disconnect/1

disconnect(Connection::pid()) -> ok

database/2

database(Connection::pid(), Database::database()) -> ok

Switch database

get_version/1

get_version(Connection::pid()) -> float()

insert/3

insert(Connection::pid(), Coll::collection(), Docs::bson:document()) -> {{boolean(), map()}, bson:document()}

insert(Connection::pid(), Coll::collection(), Docs::map()) -> {{boolean(), map()}, map()}

insert(Connection::pid(), Coll::collection(), Docs::list()) -> {{boolean(), map()}, list()}

Insert a document or multiple documents into a collection. Returns the document or documents with an auto-generated _id if missing.

insert/4

insert(Connection, Coll, Doc, WC) -> any()

insert/5

insert(Connection::pid(), Coll::collection(), Doc::bson:document(), WC::bson:document(), DB::database() | undefined) -> {{boolean(), map()}, bson:document()}

insert(Connection::pid(), Coll::collection(), Doc::map(), WC::bson:document(), DB::database() | undefined) -> {{boolean(), map()}, map()}

insert(Connection::pid(), Coll::collection(), Doc::list(), WC::bson:document(), DB::database() | undefined) -> {{boolean(), map()}, list()}

insert/1

insert(Cmd) -> any()

Insert one document or multiple documents into a colleciton. params: connection - mc_worker pid collection - collection() doc - bson:document() or list database - insert in this database (optional) write_concern - bson:document()

update/4

update(Connection::pid(), Coll::collection(), Selector::selector(), Doc::map() | bson:document()) -> {boolean(), map()}

Replace the document matching criteria entirely with the new Document.

update/6

update(Connection::pid(), Coll::collection(), Selector::selector(), Doc::map() | bson:document(), Upsert::boolean(), MultiUpdate::boolean()) -> {boolean(), map()}

Replace the document matching criteria entirely with the new Document.

update/7

update(Connection::pid(), Coll::collection(), Selector::selector(), Doc::map() | bson:document(), Upsert::boolean(), MultiUpdate::boolean(), WC::bson:document()) -> {boolean(), map()}

Replace the document matching criteria entirely with the new Document.

update/8

update(Connection::pid(), Coll::collection(), Selector::selector(), Doc::map() | bson:document(), Upsert::boolean(), MultiUpdate::boolean(), WC::bson:document(), DB::database()) -> {boolean(), map()}

Replace the document matching criteria entirely with the new Document.

update/1

update(Cmd) -> any()

Replace the document matching criteria entirely with the new Document. params: connection - mc_worker pid collection - collection() selector - selector() doc - bson:document() or list database - insert in this database (optional) upsert - boolean() do upsert multi - boolean() multiupdate write_concern - bson:document()

delete/3

delete(Connection::pid(), Coll::collection(), Selector::selector()) -> {boolean(), map()}

Delete selected documents

delete_one/3

delete_one(Connection::pid(), Coll::collection(), Selector::selector()) -> {boolean(), map()}

Delete first selected document.

delete_limit/4

delete_limit(Connection::pid(), Coll::collection(), Selector::selector(), N::integer()) -> {boolean(), map()}

Delete selected documents

delete_limit/5

delete_limit(Connection::pid(), Coll::collection(), Selector::selector(), N::integer(), WC::bson:document()) -> {boolean(), map()}

Delete selected documents

delete_limit/6

delete_limit(Connection::pid(), Coll::collection(), Selector::selector(), N::integer(), WC::bson:document(), DB::database()) -> {boolean(), map()}

Delete selected documents

delete/1

delete(Cmd) -> any()

Delete selected documents params: connection - mc_worker pid collection - collection() selector - selector() database - insert in this database (optional) num - int() number of documents (optional). 0 = all (default) write_concern - bson:document()

find_one/3

find_one(Connection::pid(), Coll::colldb(), Selector::selector()) -> map() | undefined

Return first selected document, if any

find_one/4

find_one(Connection::pid(), Coll::colldb(), Selector::selector(), Args::map()) -> map() | undefined

Return first selected document, if any

find_one/5

find_one(Connection::pid(), Coll::colldb(), Selector::selector(), Args::map(), Db::database()) -> map() | undefined

Return first selected document, if any

find_one/1

find_one(Cmd) -> any()

Return projection of selected documents. params: connection - mc_worker pid collection - collection() selector - selector() database - insert in this database (optional) projector - bson:document() optional skip - int() optional readopts - bson:document() optional

find_one/2

find_one(Connection::pid() | atom(), Query::query()) -> map() | undefined

find/3

find(Connection::pid(), Coll::colldb(), Selector::selector()) -> {ok, cursor()} | []

Return selected documents.

find/4

find(Connection::pid(), Coll::colldb(), Selector::selector(), Args::map()) -> {ok, cursor()} | []

find/5

find(Connection::pid(), Coll::colldb(), Selector::selector(), Args::map(), Db::database()) -> {ok, cursor()} | []

Return projection of selected documents. Empty projection [] means full projection.

find/1

find(Cmd) -> any()

Return projection of selected documents. params: connection - mc_worker pid collection - collection() selector - selector() database - insert in this database (optional) projector - bson:document() optional skip - int() optional batchsize - int() optional readopts - bson:document() optional

find/2

find(Connection::pid() | atom(), Query::query()) -> {ok, cursor()} | []

count/3

count(Connection::pid(), Coll::collection(), Selector::selector()) -> integer()

Count selected documents

count/4

count(Connection::pid(), Coll::collection(), Selector::selector(), Args::map()) -> integer()

Count selected documents up to given max number; 0 means no max. Ie. stops counting when max is reached to save processing time.

count/2

count(Connection::pid() | atom(), Query::bson:document()) -> integer()

count/1

count(Cmd) -> any()

Return projection of selected documents. params: connection - mc_worker pid collection - collection() selector - selector() database - insert in this database (optional) limit - int() optional. 0 - no limit readopts - bson:document() optional

ensure_index/3

ensure_index(Connection::pid(), Coll::colldb(), IndexSpec::bson:document()) -> ok | {error, any()}

Create index on collection according to given spec. The key specification is a bson documents with the following fields: IndexSpec :: bson document, for e.g. {field, 1, other, -1, location, 2d}, required

ensure_index/4

ensure_index(Connection::pid(), Coll::colldb(), IndexSpec::bson:document(), DB::database()) -> ok | {error, any()}

command/2

command(Connection::pid(), Command::selector()) -> {boolean(), map()} | {ok, cursor()}

Execute given MongoDB command and return its result.

command/3

command(Db::database(), Connection::pid(), Command::selector()) -> {boolean(), map()} | {ok, cursor()}

Execute given MongoDB command on specific database and return its result.

command/4

command(Db, Connection, Command, IsSlaveOk) -> any()


Generated by EDoc