Liking cljdoc? Tell your friends :D

murmeli.core

Murmeli MongoDB driver

Javadoc

Murmeli MongoDB driver

[Javadoc](https://www.mongodb.com/docs/drivers/java/sync/current/)
raw docstring

aggregate!clj

(aggregate! conn collection pipeline & {:as options})

Like aggregate-reducible!, but eagerly executes the aggregation and returns a vector of documents.

Like [[aggregate-reducible!]], but eagerly executes the aggregation and returns a vector of documents.
sourceraw docstring

aggregate-reducible!clj

(aggregate-reducible! conn collection pipeline & {:as options})

Execute an aggregation pipelien on a collection.

Returns a reducible (IReduceInit), which can be reduced (using reduce, into, transduce, run!,...) to execute the aggregation and produce the resulting documents.

Execute an aggregation pipelien on a collection.

Returns a reducible ([IReduceInit](https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IReduceInit.java)),
which can be reduced (using `reduce`, `into`, `transduce`, `run!`,...)
to execute the aggregation and produce the resulting documents.
sourceraw docstring

connect-client!clj

(connect-client! {:keys [cluster-settings credentials keywords? read-concern
                         read-preference retry-reads? retry-writes? ssl-settings
                         uri write-concern]
                  :as db-spec})

Connects to a Mongo instance as described by the db-spec by constructing a client connection.

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace
  • cluster-settings -- Map of cluster settings, see below
  • credentials -- Credentials to use, map of auth-db, username, and password
  • keywords? -- If true, deserialize map keys as keywords instead of strings
  • read-concern -- Choose level of read isolation, see murmeli.impl.data-interop/get-read-concern
  • read-preference -- Choose preferred replica set members when reading, see murmeli.impl.data-interop/get-read-preference
  • retry-reads? -- Retry reads if they fail due to a network error
  • retry-writes? -- Retry writes if they fail due to a network error
  • ssl-settings -- Map of SSL settings, see below
  • uri -- The connection string to use, eg. "mongodb://[username:password@]host[:port1],..."
  • write-concern -- Acknowledgement of write operations, see murmeli.impl.data-interop/get-write-concern

The cluster-settings map:

  • hosts -- Sequence of maps with host and optionally port

The ssl-settings map:

  • enabled? -- Enable SSL
  • invalid-hostname-allowed? -- Allow invalid hostnames

Returns a connection (map).

Connects to a Mongo instance as described by the `db-spec` by constructing a client connection.

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace
* `cluster-settings` -- Map of cluster settings, see below
* `credentials` -- Credentials to use, map of `auth-db`, `username`, and `password`
* `keywords?` -- If true, deserialize map keys as keywords instead of strings
* `read-concern` -- Choose level of read isolation, see [[murmeli.impl.data-interop/get-read-concern]]
* `read-preference` -- Choose preferred replica set members when reading, see [[murmeli.impl.data-interop/get-read-preference]]
* `retry-reads?` -- Retry reads if they fail due to a network error
* `retry-writes?` -- Retry writes if they fail due to a network error
* `ssl-settings` -- Map of SSL settings, see below
* `uri` -- The connection string to use, eg. "mongodb://[username:password@]host[:port1],..."
* `write-concern` -- Acknowledgement of write operations, see [[murmeli.impl.data-interop/get-write-concern]]

The `cluster-settings` map:
* `hosts` -- Sequence of maps with `host` and optionally `port`

The `ssl-settings` map:
* `enabled?` -- Enable SSL
* `invalid-hostname-allowed?` -- Allow invalid hostnames

Returns a connection (map).
sourceraw docstring

connected?clj

(connected? conn)

Return true if the conn contains a client connection.

Return `true` if the `conn` contains a client connection.
sourceraw docstring

count-collectionclj

(count-collection conn
                  collection
                  &
                  {:keys [allow-qualified? collation-options comment hint
                          keywords? limit max-time-ms query sanitize-strings?
                          skip]})

Count the number of documents in a collection.

Returns the number of documents.

Count the number of documents in a collection.

Returns the number of documents.
sourceraw docstring

create-collection!clj

(create-collection! conn collection)

Creates a collection. Returns nil.

Creates a collection.
Returns `nil`.
sourceraw docstring

create-idclj

(create-id)

Returns a new unique string representation of an object id.

Returns a new unique string representation of an object id.
sourceraw docstring

create-index!clj

(create-index! conn
               collection
               index-keys
               &
               {:keys [allow-qualified? background? bits collation-options
                       default-language expire-after-seconds hidden? index-name
                       language-override max-boundary min-boundary
                       partial-filter-expression sanitize-strings? sparse?
                       sphere-version storage-engine text-version unique?
                       version weights wildcard-projection]})

Create a new index.

Arguments:

  • conn -- The database connection
  • collection -- The collection to operate on
  • index-keys -- Map of index name to index type (1, -1, 2d, 2dsphere, text)

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace
  • background? -- Create index in the background
  • bits -- 2d index location geodata hash precision bits
  • collation-options -- Map of collation options, see murmeli.impl.data-interop/make-collation
  • default-language -- Text index language
  • expire-after-seconds -- TTL for removing indexed documents
  • hidden? -- Hide index from the query planner
  • language-override -- Name of the field that contains the language string
  • max-boundary -- Upper inclusive boundary for the longitude and latitude values for 2d indexes
  • min-boundary -- Lower inclusive boundary for the longitude and latitude values for 2d indexes
  • index-name -- Name of the index
  • partial-filter-expression -- Filter expression (a map) for including documents in the index
  • sparse? -- Create a sparse index
  • sphere-version -- The 2dsphere index version number
  • storage-engine -- Map of storage engine options
  • text-version -- The text index version number
  • unique? -- Create a unique index
  • version -- The index version number
  • weights -- Map of text index field weights
  • wildcard-projection -- Map of fields to include/exclude in a wildcard index

Returns the name of the created index.

Create a new index.

Arguments:
* `conn` -- The database connection
* `collection` -- The collection to operate on
* `index-keys` -- Map of index name to index type (1, -1, 2d, 2dsphere, text)

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace
* `background?` -- Create index in the background
* `bits` -- 2d index location geodata hash precision bits
* `collation-options` -- Map of collation options, see [[murmeli.impl.data-interop/make-collation]]
* `default-language` -- Text index language
* `expire-after-seconds` -- TTL for removing indexed documents
* `hidden?` -- Hide index from the query planner
* `language-override` -- Name of the field that contains the language string
* `max-boundary` -- Upper inclusive boundary for the longitude and latitude values for 2d indexes
* `min-boundary` -- Lower inclusive boundary for the longitude and latitude values for 2d indexes
* `index-name` -- Name of the index
* `partial-filter-expression` -- Filter expression (a map) for including documents in the index
* `sparse?` -- Create a sparse index
* `sphere-version` -- The 2dsphere index version number
* `storage-engine` -- Map of storage engine options
* `text-version` -- The text index version number
* `unique?` -- Create a unique index
* `version` -- The index version number
* `weights` -- Map of text index field weights
* `wildcard-projection` -- Map of fields to include/exclude in a wildcard index

Returns the name of the created index.
sourceraw docstring

create-object-idclj

(create-object-id)

Returns a new unique org.bson.types.ObjectId instance.

Returns a new unique `org.bson.types.ObjectId` instance.
sourceraw docstring

delete-many!clj

(delete-many! conn collection query & {:as options})

Delete document(s) based on the given collection and query.

Returns a map, where

  • :acknowledged? -- True if the deletion was acknowledged.
  • :count -- Number of documents deleted.
Delete document(s) based on the given collection and query.

Returns a map, where
* `:acknowledged?` -- True if the deletion was acknowledged.
* `:count` -- Number of documents deleted.
sourceraw docstring

delete-one!clj

(delete-one! conn collection query & {:as options})

Delete a single document based on the given collection and query.

Returns a map, where

  • :acknowledged? -- True if the deletion was acknowledged.
  • :count -- Number of documents deleted.
Delete a single document based on the given collection and query.

Returns a map, where
* `:acknowledged?` -- True if the deletion was acknowledged.
* `:count` -- Number of documents deleted.
sourceraw docstring

disconnect!clj

(disconnect! conn)

Disconnect the client.

Disconnect the client.
sourceraw docstring

drop-all-indexes!clj

(drop-all-indexes! conn collection)

Drop all indexes (except for _id) in the given collection.

Returns nil.

Drop all indexes (except for `_id`) in the given collection.

Returns `nil`.
sourceraw docstring

drop-collection!clj

(drop-collection! conn collection)

Drop the given collection from the database.

Returns nil.

Drop the given collection from the database.

Returns `nil`.
sourceraw docstring

drop-db!clj

(drop-db! conn database-name)

Drop the given database. Does nothing, if the database does not exist. Returns nil.

Drop the given database.
Does nothing, if the database does not exist.
Returns `nil`.
sourceraw docstring

drop-index!clj

(drop-index! conn collection index-keys)

Drop a specific index (as per the keys) in the given collection. Returns nil.

Drop a specific index (as per the keys) in the given collection.
Returns `nil`.
sourceraw docstring

drop-index-by-name!clj

(drop-index-by-name! conn collection index-name)

Drop a specific index (as per the name) in the given collection. Returns nil.

Drop a specific index (as per the name) in the given collection.
Returns `nil`.
sourceraw docstring

estimated-count-collectionclj

(estimated-count-collection conn collection)

Estimate the number of documents in a collection.

Returns the number of documents.

Estimate the number of documents in a collection.

Returns the number of documents.
sourceraw docstring

find-allclj

(find-all conn
          collection
          &
          {:keys [allow-qualified? batch-size keywords? limit max-time-ms
                  projection query sanitize-strings? skip sort]})

Like find-reducible, but eagerly realizes all matches into a vector.

Like [[find-reducible]], but eagerly realizes all matches into a vector.
sourceraw docstring

find-by-idclj

(find-by-id conn
            collection
            id
            &
            {:keys [allow-qualified? keywords? projection sanitize-strings?]})

Like find-one, but fetches a single document by id.

Like [[find-one]], but fetches a single document by id.
sourceraw docstring

find-distinctclj

(find-distinct conn
               collection
               field
               &
               {:keys [allow-qualified? batch-size keywords? max-time-ms query
                       sanitize-strings?]})

Find all distinct value of a field in a collection.

Returns a set containing the distinct values.

Find all distinct value of a field in a collection.

Returns a set containing the distinct values.
sourceraw docstring

find-distinct-reducibleclj

(find-distinct-reducible conn
                         collection
                         field
                         &
                         {:keys [allow-qualified? batch-size keywords?
                                 max-time-ms query sanitize-strings?]})

Find all distinct value of a field in a collection.

Returns a reducible (IReduceInit), which can be reduced (using reduce, into, transduce, run!..) to execute the query and produce the distinct values.

Find all distinct value of a field in a collection.

Returns a reducible ([IReduceInit](https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IReduceInit.java)),
which can be reduced (using `reduce`, `into`, `transduce`, `run!`..) to execute the query and produce the distinct values.
sourceraw docstring

find-oneclj

(find-one conn
          collection
          &
          {:keys [allow-qualified? keywords? projection query sanitize-strings?
                  throw-on-multiple? warn-on-multiple?]})

Like find-all, but fetches a single document

By default will warn & throw if the query produces more than one document.

Like [[find-all]], but fetches a single document

By default will warn & throw if the query produces more than one document.
sourceraw docstring

find-one-and-delete!clj

(find-one-and-delete! conn
                      collection
                      query
                      &
                      {:keys [allow-qualified? collation-options comment hint
                              keywords? max-time-ms projection sanitize-strings?
                              sort variables]})

Find a document and remove it.

Returns the document, or nil if none found.

Find a document and remove it.

Returns the document, or `nil` if none found.
sourceraw docstring

find-one-and-replace!clj

(find-one-and-replace! conn
                       collection
                       query
                       replacement
                       &
                       {:keys [allow-qualified? bypass-validation?
                               collation-options comment hint keywords?
                               max-time-ms projection return sanitize-strings?
                               sort upsert? variables]})

Find a document and replace it.

Returns the document, or nil if none found. The return argument controls whether we return the document before or after the replacement.

Find a document and replace it.

Returns the document, or `nil` if none found. The `return` argument controls
whether we return the document before or after the replacement.
sourceraw docstring

find-one-and-update!clj

(find-one-and-update! conn
                      collection
                      query
                      updates
                      &
                      {:keys [allow-qualified? array-filters bypass-validation?
                              collation-options comment hint keywords?
                              max-time-ms projection return sanitize-strings?
                              sort upsert? variables]})

Find a document and update it. Returns the document, or ´nil´ if none found. The return argument controls whether we return the document before or after the replacement.

Find a document and update it.
Returns the document, or ´nil´ if none found. The `return` argument controls
whether we return the document before or after the replacement.
sourceraw docstring

find-reducibleclj

(find-reducible conn
                collection
                &
                {:keys [allow-qualified? batch-size keywords? limit max-time-ms
                        projection query sanitize-strings? skip sort]})

Query for documents in the given collection.

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace
  • batch-size -- Fetch documents in N sized batches
  • keywords? -- Decode map keys as keywords instead of strings
  • limit -- Limit number of results to return
  • max-time-ms -- Maximum execution time on server in milliseconds
  • projection -- Either a sequence of field names or a map of field names to projection types
  • query -- Map describing the query to run
  • skip -- Skip first N documents
  • sort -- Map of field name to sort type

Returns a reducible (IReduceInit), which can be reduced (using reduce, into, transduce, run!..). to execute the query and produce the matched documents.

Query for documents in the given collection.

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace
* `batch-size` -- Fetch documents in N sized batches
* `keywords?` -- Decode map keys as keywords instead of strings
* `limit` -- Limit number of results to return
* `max-time-ms` -- Maximum execution time on server in milliseconds
* `projection` -- Either a sequence of field names or a map of field names to projection types
* `query` -- Map describing the query to run
* `skip` -- Skip first N documents
* `sort` -- Map of field name to sort type

Returns a reducible ([IReduceInit](https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IReduceInit.java)),
which can be reduced (using `reduce`, `into`, `transduce`, `run!`..). to execute the query and produce the matched documents.
sourceraw docstring

id?clj

(id? id)

Returns true if given string represents an object id.

Returns true if given string represents an object id.
sourceraw docstring

insert-many!clj

(insert-many! conn
              collection
              docs
              &
              {:keys [allow-qualified? sanitize-strings?]})

Insert multiple documents into a collection. If the documents do not contain _id fields, one will be generated (by default an ObjectId).

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace

Returns a vector containing the _ids of the inserted documents (String or ObjectId) in the corresponding order.

Insert multiple documents into a collection.
If the documents do not contain `_id` fields, one will be generated (by default an `ObjectId`).

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace

Returns a vector containing the `_id`s of the inserted documents (`String` or `ObjectId`) in the corresponding order.
sourceraw docstring

insert-one!clj

(insert-one! conn collection doc & {:keys [allow-qualified? sanitize-strings?]})

Insert a single document into a collection If the document does not contain an _id field, one will be generated (by default an ObjectId).

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace

Returns the _id of the inserted document (String or ObjectId).

Insert a single document into a collection
If the document does not contain an `_id` field, one will be generated (by default an `ObjectId`).

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace

Returns the `_id` of the inserted document (`String` or `ObjectId`).
sourceraw docstring

list-collection-namesclj

(list-collection-names conn & {:keys [batch-size max-time-ms keywords?]})

Query the collections names in the database.

Options:

  • batch-size -- Number of documents per batch
  • max-time-ms -- Maximum execution time on server in milliseconds
  • keywords? -- If true, return collection names as keywords

Returns a set of collection names.

Query the collections names in the database.

Options:
* `batch-size` -- Number of documents per batch
* `max-time-ms` -- Maximum execution time on server in milliseconds
* `keywords?` -- If true, return collection names as keywords

Returns a set of collection names.
sourceraw docstring

list-dbsclj

(list-dbs conn)

Query all the databases as documents. Returns a vector of maps, where each map contains keys like :name, :sizeOnDisk, :empty.

Query all the databases as documents.
Returns a vector of maps, where each map contains keys like `:name`, `:sizeOnDisk`, `:empty`.
sourceraw docstring

list-indexesclj

(list-indexes conn collection & {:keys [batch-size max-time-ms keywords?]})

Query all indexes in the given collection.

Returns a vector of maps, where each map contains keys like :name, :key,...

Query all indexes in the given collection.

Returns a vector of maps, where each map contains keys like `:name`, `:key`,...
sourceraw docstring

object-id?clj

(object-id? id)

Returns true if given object is an org.bson.types.ObjectId.

Returns true if given object is an `org.bson.types.ObjectId`.
sourceraw docstring

replace-one!clj

(replace-one! conn
              collection
              query
              changes
              &
              {:keys [allow-qualified? bypass-validation? collation-options
                      comment hint keywords? sanitize-strings? upsert?
                      variables]})

Find document(s) matching query and replace the first one.

Returns a map, where

  • :matched -- Number of documents matched.
  • :modified -- Number of documents modified.
Find document(s) matching `query` and replace the first one.

Returns a map, where
* `:matched` -- Number of documents matched.
* `:modified` -- Number of documents modified.
sourceraw docstring

update-many!clj

(update-many! conn
              collection
              query
              changes
              &
              {:keys [allow-qualified? array-filters bypass-validation?
                      collation-options comment hint sanitize-strings? upsert?
                      variables]})

Find document(s) matching query and apply changes to them.

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace
  • array-filters -- List of array filter documents
  • bypass-validation? -- If true, bypass document validation
  • collation-options -- Map of collation options, see murmeli.impl.data-interop/make-collation
  • comment -- Operation comment string
  • hint -- Indexing hint document
  • upsert? -- If true, insert changes document if no existing document matches query
  • variables -- Top-level variable documents

Returns a map, where

  • :matched -- Number of documents matched.
  • :modified -- Number of documents modified.
Find document(s) matching `query` and apply `changes` to them.

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace
* `array-filters` -- List of array filter documents
* `bypass-validation?` -- If true, bypass document validation
* `collation-options` -- Map of collation options, see [[murmeli.impl.data-interop/make-collation]]
* `comment` -- Operation comment string
* `hint` -- Indexing hint document
* `upsert?` -- If true, insert `changes` document if no existing document matches `query`
* `variables` -- Top-level variable documents

Returns a map, where
* `:matched` -- Number of documents matched.
* `:modified` -- Number of documents modified.
sourceraw docstring

update-one!clj

(update-one! conn
             collection
             query
             changes
             &
             {:keys [allow-qualified? array-filters bypass-validation?
                     collation-options comment hint upsert? variables]})

Find document matching query and apply changes to it.

Options:

  • allow-qualified? -- Accept qualified idents (keywords or symbols), even though we discard the namespace
  • array-filters -- List of array filter documents
  • bypass-validation? -- If true, bypass document validation
  • collation-options -- Map of collation options, see murmeli.impl.data-interop/make-collation
  • comment -- Operation comment string
  • hint -- Indexing hint document
  • upsert? -- If true, insert changes document if no existing document matches query
  • variables -- Top-level variable documents

Returns a map, where

  • :matched -- Number of documents matched.
  • :modified -- Number of documents modified.
Find document matching `query` and apply `changes` to it.

Options:
* `allow-qualified?` -- Accept qualified idents (keywords or symbols), even though we discard the namespace
* `array-filters` -- List of array filter documents
* `bypass-validation?` -- If true, bypass document validation
* `collation-options` -- Map of collation options, see [[murmeli.impl.data-interop/make-collation]]
* `comment` -- Operation comment string
* `hint` -- Indexing hint document
* `upsert?` -- If true, insert `changes` document if no existing document matches `query`
* `variables` -- Top-level variable documents

Returns a map, where
* `:matched` -- Number of documents matched.
* `:modified` -- Number of documents modified.
sourceraw docstring

with-client-session-optionsclj

(with-client-session-options conn
                             &
                             {:keys [causally-consistent? default-timeout-ms
                                     read-concern read-preference snapshot?
                                     write-concern]})

Store session options into conn, read by with-session

Store session options into `conn`, read by `with-session`
sourceraw docstring

with-dbclj

(with-db conn database-name)

Retrieve a database using the client and store it in the connection.

Retrieve a database using the client and store it in the connection.
sourceraw docstring

with-default-registryclj

(with-default-registry conn)
source

with-registryclj

(with-registry conn registry)
source

with-sessioncljmacro

(with-session [sym conn :as bindings] & body)

Run body in a session/transaction.

Gets the session options (as set by with-client-session-options), starts a session and stores it in conn and binds the result to sym. The session/transaction is either committed or aborted depending on whether body throws or not.

Run `body` in a session/transaction.

Gets the session options (as set by `with-client-session-options`), starts a session and stores it
in `conn` and binds the result to `sym`. The session/transaction is either committed or aborted
depending on whether `body` throws or not.
sourceraw docstring

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

× close