Liking cljdoc? Tell your friends :D

mingler.core

Clojure API for MongoDB

Clojure API for MongoDB
raw docstring

abort-transactionclj

(abort-transaction session)

Abort a transaction in the context of this session. A transaction can only be aborted if one has first been started. Returns the session.

Abort a transaction in the context of this session. A transaction can only be aborted if
one has first been started. Returns the session.
sourceraw docstring

active-transaction?clj

(active-transaction? session)

Returns true if there is an active transaction on this session, and false otherwise.

Returns `true` if there is an active transaction on this session, and `false` otherwise.
sourceraw docstring

close-clientclj

(close-client client)
source

close-cursorclj

(close-cursor cursor)

Close the cursor. Cursor implements java.util.Closeable, so you can close cursor with with-open too.

Close the cursor. Cursor implements java.util.Closeable, so you can close
cursor with `with-open` too.
sourceraw docstring

close-sessionclj

(close-session session)

Close client session. Returns the closed session.

Close client session. Returns the closed session.
sourceraw docstring

collectionclj

(collection db coll)

Given a collection name returns a MongoDB collection instance. Collection instances can be shared between threads.

Given a collection name returns a MongoDB collection instance.
Collection instances can be shared between threads.
sourceraw docstring

collectionsclj

(collections db)

Returns description of all collections.

Returns description of all collections.
sourceraw docstring

commit-transactionclj

(commit-transaction session)

Commit a transaction in the context of this session. A transaction can only be commmited if one has first been started. Returns the session.

Commit a transaction in the context of this session. A transaction can only be commmited
if one has first been started. Returns the session.
sourceraw docstring

countclj

(count db coll)
(count db coll filter-document)
(count db coll filter-document count-options)

Counts the number of documents in the collection according to the given options.

Counts the number of documents in the collection according to the given options.
sourceraw docstring

count-txclj

(count-tx session db coll)
(count-tx session db coll filter-document)
(count-tx session db coll filter-document count-options)
source

create-collectionclj

(create-collection db collection-name)
(create-collection db collection-name create-collection-options)

Create a new collection with the given name. Returns the collection.

Create a new collection with the given name. Returns the collection.
sourceraw docstring

create-collection-txclj

(create-collection-tx session db collection-name)
(create-collection-tx session db collection-name create-collection-options)

Create a new collection with the given name. Returns the collection.

Create a new collection with the given name. Returns the collection.
sourceraw docstring

create-indexclj

(create-index db coll index)
(create-index db coll index options)

Create an index for given fields. The index must be a vector where the first element is the index type, and the rest are options for index. Supported index types are:

:ascending - index for an ascending index on the given fields :descending - index for an descending index on the given fields :geo2dsphere - index for an 2dsphere index on the given fields :geo-haystack - index for a geohaystack index on the given field :text - index for a text index on the given field :hashed - index for a hashed index on the given field :compound - compound index specifications

For example,

(create-index db coll [:ascending :first-name :last-name])

creates an ascending index for fields :first-name and :last-name. Compound index example:

(create-index db coll [:compound [:ascending :first-name :last-name] [:descending :email]])

The fourth, optional argument, is the index options. Possible values are documented at http://mongodb.github.io/mongo-java-driver/3.8/javadoc/?com/mongodb/client/model/IndexOptions.html

For example, to create an unique index on :email:

(create-index db coll [:ascending :email] {:unique true})

Create an index for given fields. The `index` must be a vector where the first
element is the index type, and the rest are options for index. Supported index
types are:

:ascending     - index for an ascending index on the given fields
:descending    - index for an descending index on the given fields
:geo2dsphere   - index for an 2dsphere index on the given fields
:geo-haystack  - index for a geohaystack index on the given field
:text          - index for a text index on the given field
:hashed        - index for a hashed index on the given field
:compound      - compound index specifications

For example,

  `(create-index db coll [:ascending :first-name :last-name])`

creates an ascending index for fields `:first-name` and `:last-name`. Compound
index example:

  `(create-index db coll [:compound
                          [:ascending :first-name :last-name]
                          [:descending :email]])`

The fourth, optional argument, is the index options. Possible values are documented
at http://mongodb.github.io/mongo-java-driver/3.8/javadoc/?com/mongodb/client/model/IndexOptions.html

For example, to create an unique index on `:email`:

  `(create-index db coll [:ascending :email] {:unique true})`
sourceraw docstring

databaseclj

(database client database-name)

Given a database name returns a MongoDB database instance. Database instances can be shared between threads.

Given a database name returns a MongoDB database instance.
Database instances can be shared between threads.
sourceraw docstring

databasesclj

(databases client)

Returns description of all databases.

Returns description of all databases.
sourceraw docstring

deleteclj

(delete db coll filter-document)

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified. Returns delete result as a map.

Removes at most one document from the collection that matches the given filter.
If no documents match, the collection is not modified. Returns delete result as a map.
sourceraw docstring

delete-manyclj

(delete-many db coll filter-document)

Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified. Returns delete result as a map.

Removes all documents from the collection that match the given query filter.
If no documents match, the collection is not modified. Returns delete result as a map.
sourceraw docstring

delete-many-txclj

(delete-many-tx session db coll filter-document)

Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified. Returns delete result as a map.

Removes all documents from the collection that match the given query filter.
If no documents match, the collection is not modified. Returns delete result as a map.
sourceraw docstring

delete-txclj

(delete-tx session db coll filter-document)

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified. Returns delete result as a map.

Removes at most one document from the collection that matches the given filter.
If no documents match, the collection is not modified. Returns delete result as a map.
sourceraw docstring

drop-collectionclj

(drop-collection db coll)

Drops this collection from the Database.

Drops this collection from the Database.
sourceraw docstring

drop-collection-txclj

(drop-collection-tx db coll session)

Drops this collection from the Database.

Drops this collection from the Database.
sourceraw docstring

drop-indexclj

(drop-index db coll index-name)

Drops the index given its name.

Drops the index given its name.
sourceraw docstring

drop-indexesclj

(drop-indexes db coll)

Drop all the indexes on this collection, except for the default on _id.

Drop all the indexes on this collection, except for the default on _id.
sourceraw docstring

expected-matches!clj

(expected-matches! result)
(expected-matches! {:as result :keys [matched-count]} expected-count)

Accepts update result like returned by update and delete functions and an expected match count (defaults to 1). If the match count on the result is not equal to expected, throws an exception. Otherwise returns the result.

Accepts update result like returned by `update` and `delete` functions and
an expected match count (defaults to 1). If the match count on the result
is not equal to expected, throws an exception. Otherwise returns the
result.
sourceraw docstring

filterclj

(filter query filter-document)

Apply a filter document to query context. Returns the query context.

Apply a filter document to query context. Returns the query context.
sourceraw docstring

find-allclj

(find-all db coll filter-document)

Helper to return all documents that match the filter document. Not lazy.

Helper to return all documents that match the filter document. Not lazy.
sourceraw docstring

find-all-txclj

(find-all-tx session db coll filter-document)

Helper to return all documents that match the filter document. Not lazy.

Helper to return all documents that match the filter document. Not lazy.
sourceraw docstring

find-oneclj

(find-one db coll filter-document)

Helper to return a first document that matches the filter document.

Helper to return a first document that matches the filter document.
sourceraw docstring

find-one-txclj

(find-one-tx session db coll filter)

Helper to return a first document that matches the filter document.

Helper to return a first document that matches the filter document.
sourceraw docstring

for-eachclj

(for-each query callback)
(for-each query callback keyfn)

Iterates over all documents in the view, applying the given callback to each.

Iterates over all documents in the view, applying the given callback to each.
sourceraw docstring

get-firstclj

(get-first query)
(get-first query keyfn)

Helper to return the first document from query context. Handy helper when only one document is expected. Avoids opening and closing a cursor.

Helper to return the first document from query context. Handy helper when
only one document is expected. Avoids opening and closing a cursor.
sourceraw docstring

get-indexesclj

(get-indexes db coll)
source

insertclj

(insert db coll document)
(insert db coll document insert-options)

Insert document to the collection. If the document is missing an identifier, the driver should generate one. Returns the db.

Insert document to the collection. If the document is missing an identifier, the driver should
generate one. Returns the db.
sourceraw docstring

insert-manyclj

(insert-many db coll documents)
(insert-many db coll documents insert-options)

Insert one or more documents. Returns the db.

Insert one or more documents. Returns the db.
sourceraw docstring

insert-many-txclj

(insert-many-tx session db coll documents)
(insert-many-tx session db coll documents insert-options)

Insert one or more document with a session, probably with an active transaction. Returns the session.

Insert one or more document with a session, probably with an active transaction.
Returns the session.
sourceraw docstring

insert-txclj

(insert-tx session db coll document)
(insert-tx session db coll document insert-options)

Insert document to the collection with a session, probably with an active transaction. If the document is missing an identifier, the driver should generate one. Returns the session.

Insert document to the collection with a session, probably with an active transaction.
If the document is missing an identifier, the driver should generate one. Returns the session.
sourceraw docstring

intoclj

(into query to)
(into query to keyfn)

Like clojure.core/into.

Like `clojure.core/into`.
sourceraw docstring

limitclj

(limit query value)

Sets the limit to apply to query context. Returns the query context.

Sets the limit to apply to query context. Returns the query context.
sourceraw docstring

modifiersclj

(modifiers query modifiers-document)

Sets the query modifiers to apply to this operation.

Sets the query modifiers to apply to this operation.
sourceraw docstring

open-clientclj

(open-client)
(open-client config)

Creates a new MongoDB client. Client instances can be shared between threads.

Typical applications create one client instance at the start of the application and close it at application shutdown.

Client must be closed when it is no longer used. Closing client closes all resources, including sockets and background monitoring threads.

Zero arity version connects to MongoDB server at localhost:27017.

Arity one accepts either connection string (see http://mongodb.github.io/mongo-java-driver/3.8/javadoc/com/mongodb/ConnectionString.html) or a map with following shape:

{:ssl? false :compression? true :servers [{:host "db-1"} {:host "db-2", :port 27018}] :credentials {:username "user" :password "pass" :database "dbname"}}

If :ssl? is true, all connections to server use SSL. Default is false.

If :compression? is true, data transmissions with servers are compressed. Default is false.

:servers is a vector of server addresses with :host and optional ':port. The default port is 27017. The default for:serversis[{:host "localhost"}]`.

The :credentials, if provided, are used to authenticate the client to server. The :database is the name of the MongoDB database where user is defined.

Creates a new MongoDB client. Client instances can be shared between threads.

Typical applications create one client instance at the start of the application and
close it at application shutdown.

Client must be closed when it is no longer used. Closing client closes all resources, including
sockets and background monitoring threads.

Zero arity version connects to MongoDB server at localhost:27017.

Arity one accepts either connection string
(see http://mongodb.github.io/mongo-java-driver/3.8/javadoc/com/mongodb/ConnectionString.html)
or a map with following shape:

  {:ssl? false
   :compression? true
   :servers [{:host "db-1"}
             {:host "db-2", :port 27018}]
   :credentials {:username "user"
                 :password "pass"
                 :database "dbname"}}

If `:ssl?` is `true`, all connections to server use SSL. Default is `false`.

If `:compression?` is `true`, data transmissions with servers are compressed. Default is `false`.

`:servers` is a vector of server addresses with `:host` and optional ':port`. The default port
is 27017. The default for `:servers` is `[{:host "localhost"}]`.

The `:credentials`, if provided, are used to authenticate the client to server. The `:database`
is the name of the MongoDB database where user is defined.
sourceraw docstring

open-cursorclj

(open-cursor query)
(open-cursor query keyfn)

Opens query cursor. The cursor implements java.util.Iterator so you can use clojure.core/iterator-seq to wrap cursor into a seq. Note how ever, that the opened cursor must be closed. The returned cursor is closeable, so you can use with-open with the returned cursor.

Opens query cursor. The cursor implements java.util.Iterator so you can use
`clojure.core/iterator-seq` to wrap cursor into a seq. Note how ever, that the
opened cursor must be closed. The returned cursor is closeable, so you can use
`with-open` with the returned cursor.
sourceraw docstring

open-sessionclj

(open-session client)
(open-session client session-options)

Creates a client session. Client sessions must be closed. Client session instances implement java.io.Closable, so the recommended practice is to use with-open. A session instance can not be used concurrently in multiple operations.

Creates a client session. Client sessions must be closed. Client session instances
implement `java.io.Closable`, so the recommended practice is to use `with-open`.
A session instance can not be used concurrently in multiple operations.
sourceraw docstring

projectionclj

(projection query projection-document)

Sets a document describing the fields to return for all matching documents.

Sets a document describing the fields to return for all matching documents.
sourceraw docstring

queryclj

(query db coll)

Returns a query context (an instance of com.mongodb.client.FindIterable). This context can be refined with various with-* functions below. Query is executed by the open-cursor function.

Returns a query context (an instance of com.mongodb.client.FindIterable). This
context can be refined with various `with-*` functions below. Query is executed by
the `open-cursor` function.
sourceraw docstring

query-txclj

(query-tx session db coll)

Returns a query context (an instance of com.mongodb.client.FindIterable) with a session, probably with an active transaction.

Returns a query context (an instance of com.mongodb.client.FindIterable) with
a session, probably with an active transaction.
sourceraw docstring

skipclj

(skip query value)

Sets the number of documents to skip. Returns the query context.

Sets the number of documents to skip. Returns the query context.
sourceraw docstring

sortclj

(sort query sort-document)

Sets the sort criteria to apply to the query.

Sets the sort criteria to apply to the query.
sourceraw docstring

start-transactionclj

(start-transaction session)
(start-transaction session transaction-options)

Start a transaction in the context of this session. A transaction can not be started if there is already an active transaction on this session. Returns the session.

Start a transaction in the context of this session. A transaction can not be started
if there is already an active transaction on this session. Returns the session.
sourceraw docstring

transaction-optionsclj

(transaction-options session)

Gets the transaction options. If transaction is not active, returns nil. Otherwise returns a map with at least :read-concern and :write-concern.

Gets the transaction options. If transaction is not active, returns `nil`. Otherwise returns
a map with at least `:read-concern` and `:write-concern`.
sourceraw docstring

updateclj

(update db coll filter-document update-document)
(update db coll filter-document update-document update-options)

Update a single document in the collection according to the specified arguments. Returns a map of update results.

Update a single document in the collection according to the specified arguments.
Returns a map of update results.
sourceraw docstring

update-manyclj

(update-many db coll filter-document update-document)
(update-many db coll filter-document update-document update-options)

Update all documents in the collection according to the specified arguments. Returns a map of update results.

Update all documents in the collection according to the specified arguments.
Returns a map of update results.
sourceraw docstring

update-many-txclj

(update-many-tx session db coll filter-document update-document update-options)

Update all documents in the collection according to the specified arguments. Returns a map of update results.

Update all documents in the collection according to the specified arguments.
Returns a map of update results.
sourceraw docstring

update-txclj

(update-tx session db coll filter-document update-document)
(update-tx session db coll filter-document update-document update-options)

Update a single document in the collection according to the specified arguments. Returns a map of update results.

Update a single document in the collection according to the specified arguments.
Returns a map of update results.
sourceraw docstring

with-txcljmacro

(with-tx session & body)

Takes a session, optional transaction-options map, and a body of statements. Executes statements with an transaction. After the statements are executed, commits the transaction if it's still open. If statements execution causes an exception, aborts the transaction, if it's still open.

Takes a session, optional transaction-options map, and a body of statements.
Executes statements with an transaction. After the statements are executed,
commits the transaction if it's still open. If statements execution causes
an exception, aborts the transaction, if it's still open.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close