Liking cljdoc? Tell your friends :D

mongrove.core

A clojure wrapper over the official MongoDB java driver

A clojure wrapper over the official MongoDB java driver
raw docstring

client-session-optionsclj

(client-session-options {:keys [causally-consistent transaction-opts] :as opts})

Default MongoDB client session options.

Default MongoDB client session options.
sourceraw docstring

client-settingsclj

(client-settings {:keys [read-preference read-concern write-concern retry-reads
                         retry-writes]
                  :as opts})

Initialize a ConnectionPoolSettings object from given options map. Available options : :read-preference :read-concern :write-concern :retry-reads :retry-writes

Initialize a ConnectionPoolSettings object from given options map.
Available options : :read-preference :read-concern :write-concern
:retry-reads :retry-writes
sourceraw docstring

cluster-settingsclj

(cluster-settings builder {:keys [hosts] :as opts})

Initialize a ClusterSettings object from given options map. Available options : :hosts

Initialize a ClusterSettings object from given options map.
Available options : :hosts
sourceraw docstring

connectcljmultimethod

(connect :direct {:host host :port port :opts opts})
(connect :replica-set [{:host host :port port :opts opts} & more])

Initialize the MongoDB Connection. Mongo Client Opts, if any, are taken from the first server-spec. Ref. `client-settings' fn for a list of default opts that are applied to the Mongo Client.

Initialize the MongoDB Connection. Mongo Client Opts, if any, are taken from
the first server-spec. Ref. `client-settings' fn for a list of default opts
that are applied to the Mongo Client.
sourceraw docstring

connection-pool-settingsclj

(connection-pool-settings builder
                          {:keys [connections-per-host max-connection-wait-time]
                           :as opts})

Initialize a ConnectionPoolSettings object from given options map. Available options : :connections-per-host :max-connection-wait-time

Initialize a ConnectionPoolSettings object from given options map.
Available options : :connections-per-host :max-connection-wait-time
sourceraw docstring

count-docsclj

(count-docs db coll query)
(count-docs db session coll query)

Count documents in a collection. Optionally take a query.

Count documents in a collection.
Optionally take a query.
sourceraw docstring

create-indexclj

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

Ensure that the given index on the collection exists. Inexpensive if the index already exists. index-spec is map like : {:field 1 :another-field -1} 1 indicates ascending index, -1 indicated descending index To ensure order of the fields in a compound index, always use an array map like : (array-map :field 1 :another-field -1) Supports option :unique (boolean) => creates a unique index

Ensure that the given index on the collection exists.
Inexpensive if the index already exists.
index-spec is map like : {:field 1 :another-field -1}
1 indicates ascending index, -1 indicated descending index
To ensure order of the fields in a compound index,
always use an array map like : (array-map :field 1 :another-field -1)
Supports option :unique (boolean) => creates a unique index
sourceraw docstring

deleteclj

(delete
  db
  coll
  query
  &
  {write-concern :write-concern session :session :or {write-concern :majority}})

Delete a document from the collection that matches query. wc is the write-concern which should be a key from write-concern-map and is optional. Else the default write-concern is used.

Delete a document from the collection that matches `query`.
wc is the write-concern which should be a key from write-concern-map and is optional.
Else the default write-concern is used.
sourceraw docstring

drop-collectionclj

(drop-collection db coll)
(drop-collection db session coll)

Drop the given collection.

Drop the given collection.
sourceraw docstring

drop-databaseclj

(drop-database db)
(drop-database db session)

Drop the given database.

Drop the given database.
sourceraw docstring

fetch-oneclj

(fetch-one db
           coll
           query
           &
           {:keys [only exclude session] :or {only [] exclude []}})

Fetch a single document depending on query. Optionally return (or exclude) only a subset of the fields.

Fetch a single document depending on query.
Optionally return (or exclude) only a subset of the fields.
sourceraw docstring

get-collectionclj

(get-collection db coll)
(get-collection db coll write-concern)

Get the collection object from given db

Get the collection object from given db
sourceraw docstring

get-collection-namesclj

(get-collection-names db)
(get-collection-names db session)

Returns names of all the collections for the given db

Returns names of all the collections for the given db
sourceraw docstring

get-database-namesclj

(get-database-names client)
(get-database-names client session)

Get all database names available in the given mongo server.

Get all database names available in the given mongo server.
sourceraw docstring

get-databasesclj

(get-databases client)
(get-databases client session)

Get all databases available in the given mongo server.

Get all databases available in the given mongo server.
sourceraw docstring

get-dbclj

(get-db client db-name)

Get the database object given a name.

Get the database object given a name.
sourceraw docstring

get-indexesclj

(get-indexes db coll)
(get-indexes db session coll)

Get indexes for a given collection

Get indexes for a given collection
sourceraw docstring

insertclj

(insert db
        coll
        docs
        &
        {multi? :multi?
         write-concern :write-concern
         session :session
         :or {multi? false write-concern :majority}})

Insert a document into the database. If inserting in bulk, provide a vector of maps and set multi? as true.

Insert a document into the database. If inserting in bulk, provide a vector of
maps and set multi? as true.
sourceraw docstring

queryclj

(query db
       coll
       query
       &
       {:keys [sort-by limit only exclude skip one? batch-size session]
        :or {skip 0 limit 10 one? false only [] exclude [] batch-size 10000}})

Perform an arbitrary query on a collection. Optionally sort, limit, paginate, fetch a subset of fields. Note: Beware of the queries where limit > batch-size which can lead to a situation where 1 batch is received and processed and if for another batch if mongod server goes down at the same time, then cursor is lost and query will fail with the Cursor exception

Perform an arbitrary query on a collection.
 Optionally sort, limit, paginate, fetch a subset of fields.
Note: Beware of the queries where limit > batch-size which can lead to a
situation where 1 batch is received and processed and if for another batch
if mongod server goes down at the same time, then cursor is lost and query
will fail with the Cursor exception
sourceraw docstring

run-in-transactionclj

(run-in-transaction client body-fn {:keys [transaction-opts] :as options})

Execute the given code in a MongoDB transaction. client : The MongoClient connection object body-fn : The body-fn should be a function which takes 1 argument, a ClientSession object. This session object needs to be passed in to all the mongrove APIs which take a session arg. options: Currently supported keys are : transaction-opts {:read-preference :read-concern :write-concern :retry-on-errors} If the transaction fails with a retryable error label, and retry-on-errors is true, mongrove will keep retrying the transaction. For other options, refer to the MongoDB documentation. For default values chosen, refer to Jepsen's recommendations here : http://jepsen.io/analyses/mongodb-4.2.6

Execute the given code in a MongoDB transaction.
`client` : The MongoClient connection object
`body-fn` : The body-fn should be a function which takes 1 argument,
 a ClientSession object. This session object needs to be
 passed in to all the mongrove APIs which take a session arg.
`options`: Currently supported keys are :
  `transaction-opts` {:read-preference :read-concern :write-concern :retry-on-errors}
   If the transaction fails with a retryable error label, and retry-on-errors is true,
   mongrove will keep retrying the transaction.
   For other options, refer to the MongoDB documentation.
   For default values chosen, refer to Jepsen's recommendations
   here : http://jepsen.io/analyses/mongodb-4.2.6
sourceraw docstring

socket-settingsclj

(socket-settings builder {:keys [connect-timeout socket-timeout] :as opts})

Initialize a SocketSettings object from given options map. Available options : :connect-timeout :socket-timeout

Initialize a SocketSettings object from given options map.
Available options : :connect-timeout :socket-timeout
sourceraw docstring

transaction-optionsclj

(transaction-options {:keys [read-preference read-concern write-concern]
                      :as opts})

Default Transaction options.

Default Transaction options.
sourceraw docstring

updateclj

(update db
        coll
        query
        doc
        &
        {upsert? :upsert?
         multi? :multi?
         write-concern :write-concern
         session :session
         :or {upsert? false multi? false write-concern :majority}})

Update one or more documents with given document depending on query. Optionally upsert.

Update one or more documents with given document depending on query.
Optionally upsert.
sourceraw docstring

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

× close