mongodb.async

Thin wrapper for MongoDB's java async driver that enables idiomatic
asynchronous operation over MongoDB via callbacks or `core.async channels`

close!

(close! conn)
Closes the connection

collection

(collection conn dbcol)
Gets a collection

connect

(connect database)(connect database {:keys [host port], :or {host "127.0.0.1", port 27017}})
Connects to a database.

This function receives the database name to connect to and optionaly a map
with connection properties. A connection to the database will be returned.

Examples:

(connect :local-database)
(connect "some-database" {:host '192.168.10.10' :port 27017})

drop-collection!

(drop-collection! conn coll)(drop-collection! conn coll cb)
Drops a collection

fetch

(fetch conn coll {:keys [where only sort skip limit count? one? explain?], :or {sort {}, skip 0, where {}, only [], limit 0, count? false, one? false, explain? false}})(fetch conn coll {:keys [where only sort skip limit count? one? explain?], :or {sort {}, skip 0, where {}, only [], limit 0, count? false, one? false, explain? false}} cb)
Fetches data from collection `coll`
Optional arguments:

:where - a query map
:only - a vector of keys to project
:sort - a map with sorting specs
:skip - number of records to skip
:limit - number of records to return
:count? - performs a document count, defaults to `false`
:one? - retreive only the first document, defaults to `false`
:explain? - returns the query explain data, defaults to `false`

fetch-count

(fetch-count conn coll {:keys [where], :or {where {}}})(fetch-count conn coll {:keys [where], :or {where {}}} cb)
Counts the number of documents in the collection.
Optionaly a query map can be provided.

fetch-one

(fetch-one conn coll {:keys [where only explain?], :or {where {}, only [], explain? false}})(fetch-one conn coll {:keys [where only explain?], :or {where {}, only [], explain? false}} cb)
Fetches the first document that complies to the query criteria
or `nil` of no document is found if using a callback or `:nil`
will be placed in the channel when using this particular interface.

insert!

(insert! conn coll data {:keys [many], :or {many false}})(insert! conn coll data {:keys [many], :or {many false}} cb)
Inserts `data` into collection `coll`.
If the options :many is true, and a vector is provided as data,
a mass insert will be performed

insert-many!

(insert-many! conn coll data {:keys [], :or {}})(insert-many! conn coll data {:keys [], :or {}} tail-pos12499)
Mass insert

remove!

(remove! conn coll {:keys [where one?], :or {where {}, one? false}})(remove! conn coll {:keys [where one?], :or {where {}, one? false}} cb)
Removes documents from a collection
Optional arguments:

:where - a query map
:one? - delete only the first document the complies to the query, defaults to `false`

remove-one!

(remove-one! conn coll {:keys [where explain?], :or {where {}, explain? false}})(remove-one! conn coll {:keys [where explain?], :or {where {}, explain? false}} cb)
Remove the first document that complies to the query

replace-one!

(replace-one! conn coll replacement {:keys [where upsert?], :or {where {}, upsert? false}})(replace-one! conn coll replacement {:keys [where upsert?], :or {where {}, upsert? false}} cb)
Replaces a single document within the collection based on the filter.
Will perform an upsert if `:upsert?` equals true. Defaults to false.

Returns a map with the following data:

:acknowledged - true if the update was acknowledged by the server
:matched-count - number of documents that matched the critera
:upserted-id - the id of the upserted document if an upsert was performed