Liking cljdoc? Tell your friends :D

mongo-driver-3.collection


aggregateclj

(aggregate db coll pipeline)
(aggregate db coll pipeline opts)

Aggregates documents according to the specified aggregation pipeline and return a seq of maps, unless configured otherwise..

Arguments:

  • db is a MongoDatabase
  • coll is a collection namee
  • q is a map representing a query.
  • opts (optional), a map of:
    • :allow-disk-use? whether to allow writing temporary files
    • :batch-size Documents to return per batch, e.g. 1
    • :bypass-document-validation? Boolean
    • :keywordize? keywordize the keys of return results, default: true
    • :realise-fn how to realise the MongoIterable, default: clojure.core/sequence (i.e. lazily)
    • :raw? return the mongo AggregateIterable directly instead of processing into a seq, default: false
    • :session a ClientSession
Aggregates documents according to the specified aggregation pipeline and return a seq of maps,
unless configured otherwise..

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection namee
- `q` is a map representing a query.
- `opts` (optional), a map of:
  - `:allow-disk-use?` whether to allow writing temporary files
  - `:batch-size` Documents to return per batch, e.g. 1
  - `:bypass-document-validation?` Boolean
  - `:keywordize?` keywordize the keys of return results, default: true
  - `:realise-fn` how to realise the MongoIterable, default: `clojure.core/sequence` (i.e. lazily)
  - `:raw?` return the mongo AggregateIterable directly instead of processing into a seq, default: false
  - `:session` a ClientSession
sourceraw docstring

bulk-writeclj

(bulk-write db coll operations)
(bulk-write db coll operations opts)

Executes a mix of inserts, updates, replaces, and deletes.

  • db is a MongoDatabase
  • coll is a collection name
  • operations a list of 2-tuples in the form [op config],
    • op is one of :insert-one :update-one :update-many :delete-one :delete-many :replace-one
    • config the configuration map for the operation
      • insert takes :document
      • update takes :filter, :update, and any options in the corresponding update function
      • delete takes :filter, and any options in the corresponding delete function
      • replace takes :filter, :replacement, and any options in the corresponding replace function
  • opts (optional), a map of:
    • :bypass-document-validation? Boolean
    • :ordered? Boolean whether serve should insert documents in order provided (default true)
    • :bulk-write-options A BulkWriteOptions for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :session A ClientSession

Additionally takes options specified in collection

Executes a mix of inserts, updates, replaces, and deletes.

- `db` is a MongoDatabase
- `coll` is a collection name
- `operations` a list of 2-tuples in the form `[op config]`,
  - `op` is one of :insert-one :update-one :update-many :delete-one :delete-many :replace-one
  - `config` the configuration map for the operation
    - `insert` takes `:document`
    - `update` takes `:filter`, `:update`, and any options in the corresponding update function
    - `delete` takes `:filter`, and any options in the corresponding delete function
    - `replace` takes `:filter`, `:replacement`, and any options in the corresponding replace function
- `opts` (optional), a map of:
  - `:bypass-document-validation?` Boolean
  - `:ordered?` Boolean whether serve should insert documents in order provided (default true)
  - `:bulk-write-options` A BulkWriteOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it.
  - `:session` A ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

collectionclj

(collection db coll)
(collection db coll opts)

Coerces coll to a MongoCollection with some options.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name or a MongoCollection. This is to provide flexibility, either in reuse of instances or in some more complex configuration we do not directly support.
  • opts (optional), a map of:
    • :read-preference Accepts a ReadPreference or a kw corresponding to one: [:primary, :primaryPreferred, :secondary, :secondaryPreferred, :nearest] Invalid values will throw an exception.
    • :read-concern Accepts a ReadConcern or kw corresponding to one: [:available, :default, :linearizable, :local, :majority, :snapshot] Invalid values will throw an exception.
    • :write-concern A WriteConcern or kw corresponding to one: [:acknowledged, :journaled, :majority, :unacknowledged, :w1, :w2, :w3], defaulting to :acknowledged, if some invalid option is provided.
    • :write-concern/w an int >= 0, controlling the number of replicas to acknowledge
    • :write-concern/w-timeout-ms How long to wait for secondaries to acknowledge before failing, in milliseconds (0 means indefinite).
    • :write-concern/journal? If true, block until write operations have been committed to the journal.
Coerces `coll` to a MongoCollection with some options.

Arguments:

- `db`   is a MongoDatabase
- `coll` is a collection name or a MongoCollection. This is to provide flexibility, either in reuse of
  instances or in some more complex configuration we do not directly support.
- `opts` (optional), a map of:
  - `:read-preference` Accepts a ReadPreference or a kw corresponding to one:
    [:primary, :primaryPreferred, :secondary, :secondaryPreferred, :nearest]
    Invalid values will throw an exception.
  - `:read-concern` Accepts a ReadConcern or kw corresponding to one:
    [:available, :default, :linearizable, :local, :majority, :snapshot]
    Invalid values will throw an exception.
  - `:write-concern` A WriteConcern or kw corresponding to one:
    [:acknowledged, :journaled, :majority, :unacknowledged, :w1, :w2, :w3],
    defaulting to :acknowledged, if some invalid option is provided.
  - `:write-concern/w` an int >= 0, controlling the number of replicas to acknowledge
  - `:write-concern/w-timeout-ms` How long to wait for secondaries to acknowledge before failing,
     in milliseconds (0 means indefinite).
  - `:write-concern/journal?` If true, block until write operations have been committed to the journal.
sourceraw docstring

count-documentsclj

(count-documents db coll)
(count-documents db coll q)
(count-documents db coll q opts)

Count documents in a collection, optionally matching a filter query q.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • opts (optional), a map of:
    • :hint an index name (string) hint or specification (map)
    • :max-time-ms max amount of time to allow the query to run, in milliseconds
    • :skip number of documents to skip before counting
    • :limit max number of documents to count
    • :count-options a CountOptions, for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :session a ClientSession

Additionally takes options specified in collection.

Count documents in a collection, optionally matching a filter query `q`.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `opts` (optional), a map of:
  - `:hint` an index name (string) hint or specification (map)
  - `:max-time-ms` max amount of time to allow the query to run, in milliseconds
  - `:skip` number of documents to skip before counting
  - `:limit` max number of documents to count
  - `:count-options` a CountOptions, for configuring directly. If specified, any
     other [preceding] query options will be applied to it.
  - `:session` a ClientSession

Additionally takes options specified in `collection`.
sourceraw docstring

createclj

(create db coll)
(create db coll opts)

Creates a collection

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • opts (optional), a map of:
    • :capped? Boolean whether to create a capped collection
    • :max-documents max documents for a capped collection
    • :max-size-bytes max collection size in bytes for a capped collection
    • :create-collection-options A CreateCollectionOptions for configuring directly. If specified, any other [preceding] query options will be applied to it
Creates a collection

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `opts` (optional), a map of:
  - `:capped?` Boolean whether to create a capped collection
  - `:max-documents` max documents for a capped collection
  - `:max-size-bytes` max collection size in bytes for a capped collection
  - `:create-collection-options` A CreateCollectionOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it
sourceraw docstring

create-indexclj

(create-index db coll keys)
(create-index db coll keys opts)

Creates an index

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • keys is a document representing index keys, e.g. {:a 1}
  • opts (optional), a map of:
    • :name
    • :sparse?
    • :unique?
    • :index-options An IndexOptions for configuring directly. If specified, any other [preceding] query options will be applied to it
Creates an index

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `keys` is a document representing index keys, e.g. {:a 1}
- `opts` (optional), a map of:
  - `:name`
  - `:sparse?`
  - `:unique?`
  - `:index-options` An IndexOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it
sourceraw docstring

create-indexesclj

(create-indexes db coll indexes)
(create-indexes db coll indexes opts)

Creates many indexes.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • indexes is a collection of maps with the following keys:
    • :keys (mandatory) a document representing index keys, e.g. {:a 1}
    • :name
    • :sparse?
    • :unique?
Creates many indexes.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `indexes` is a collection of maps with the following keys:
  - `:keys` (mandatory) a document representing index keys, e.g. {:a 1}
  - `:name`
  - `:sparse?`
  - `:unique?`
sourceraw docstring

delete-manyclj

(delete-many db coll q)
(delete-many db coll q opts)

Deletes multiple documents from a collection and returns a DeleteResult.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • opts (optional), a map of:
    • :delete-options A DeleteOptions for configuring directly.
    • :session A ClientSession

Additionally takes options specified in collection

Deletes multiple documents from a collection and returns a DeleteResult.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `opts` (optional), a map of:
  - `:delete-options` A DeleteOptions for configuring directly.
  - `:session` A ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

delete-oneclj

(delete-one db coll q)
(delete-one db coll q opts)

Deletes a single document from a collection and returns a DeleteResult.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • opts (optional), a map of:
    • :delete-options A DeleteOptions for configuring directly.
    • :session A ClientSession

Additionally takes options specified in collection

Deletes a single document from a collection and returns a DeleteResult.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `opts` (optional), a map of:
  - `:delete-options` A DeleteOptions for configuring directly.
  - `:session` A ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

dropclj

(drop db coll)

Drops a collection from a database.

Drops a collection from a database.
sourceraw docstring

findclj

(find db coll q)
(find db
      coll
      q
      {:keys [limit skip sort projection session keywordize? raw? realise-fn]
       :or {keywordize? true realise-fn sequence}
       :as opts})

Finds documents and returns a seq of maps, unless configured otherwise.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • opts (optional), a map of:
    • :limit Max number of documents to return, e.g. 1
    • :skip Number of documents to skip, e.g. 1
    • :sort document representing sort order, e.g. {:timestamp -1}
    • :projection document representing fields to return, e.g. {:_id 0}
    • :keywordize? keywordize the keys of return results, default: true
    • :realise-fn how to realise the MongoIterable, default: clojure.core/sequence (i.e. lazily)
    • :raw? return the mongo FindIterable directly instead of processing into a seq, default: false
    • :session a ClientSession

Additionally takes options specified in collection.

Finds documents and returns a seq of maps, unless configured otherwise.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `opts` (optional), a map of:
  - `:limit` Max number of documents to return, e.g. 1
  - `:skip` Number of documents to skip, e.g. 1
  - `:sort` document representing sort order, e.g. {:timestamp -1}
  - `:projection` document representing fields to return, e.g. {:_id 0}
  - `:keywordize?` keywordize the keys of return results, default: true
  - `:realise-fn` how to realise the MongoIterable, default: `clojure.core/sequence` (i.e. lazily)
  - `:raw?` return the mongo FindIterable directly instead of processing into a seq, default: false
  - `:session` a ClientSession

Additionally takes options specified in `collection`.
sourceraw docstring

find-oneclj

(find-one db coll q)
(find-one db coll q opts)

Finds a single document and returns it as a clojure map, or nil if not found.

Takes the same options as find.

Finds a single document and returns it as a clojure map, or nil if not found.

Takes the same options as `find`.
sourceraw docstring

find-one-and-replaceclj

(find-one-and-replace db coll q doc)
(find-one-and-replace db coll q doc opts)

Atomically find a document (at most one) and replace it.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • doc is a new document to add.
  • opts (optional), a map of:
    • :upsert? whether to insert a new document if nothing is found, default: false
    • :return-new? whether to return the document after update (insead of its state before the update), default: false
    • :sort map representing sort order, e.g. {:timestamp -1}
    • :projection map representing fields to return, e.g. {:_id 0}
    • :find-one-and-replace-options A FindOneAndReplaceOptions for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :keywordize? keywordize the keys of return results, default: true
    • :session a ClientSession

Additionally takes options specified in collection.

Atomically find a document (at most one) and replace it.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `doc` is a new document to add.
- `opts` (optional), a map of:
  - `:upsert?` whether to insert a new document if nothing is found, default: false
  - `:return-new?` whether to return the document after update (insead of its state before the update), default: false
  - `:sort` map representing sort order, e.g. {:timestamp -1}
  - `:projection` map representing fields to return, e.g. {:_id 0}
  - `:find-one-and-replace-options` A FindOneAndReplaceOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it.
  - `:keywordize?` keywordize the keys of return results, default: true
  - `:session` a ClientSession

Additionally takes options specified in `collection`.
sourceraw docstring

find-one-and-updateclj

(find-one-and-update db coll q update)
(find-one-and-update db coll q update opts)

Atomically find a document (at most one) and modify it.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • update is either a map representing a document update or a vector representing an 'aggregation pipeline'. A document update must include only update operators, while an 'aggregation pipeline' can contain multiple stages of $set, $unset and $replaceWith.
  • opts (optional), a map of:
    • :upsert? whether to insert a new document if nothing is found, default: false
    • :return-new? whether to return the document after update (insead of its state before the update), default: false
    • :sort map representing sort order, e.g. {:timestamp -1}
    • :projection map representing fields to return, e.g. {:_id 0}
    • :find-one-and-update-options A FindOneAndUpdateOptions for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :keywordize? keywordize the keys of return results, default: true
    • :session a ClientSession

Additionally takes options specified in collection.

Atomically find a document (at most one) and modify it.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `update` is either a map representing a document update or a vector
  representing an 'aggregation pipeline'. A document update must include only
  update operators, while an 'aggregation pipeline' can contain multiple
  stages of `$set`, `$unset` and `$replaceWith`.
- `opts` (optional), a map of:
  - `:upsert?` whether to insert a new document if nothing is found, default: false
  - `:return-new?` whether to return the document after update (insead of its state before the update), default: false
  - `:sort` map representing sort order, e.g. {:timestamp -1}
  - `:projection` map representing fields to return, e.g. {:_id 0}
  - `:find-one-and-update-options` A FindOneAndUpdateOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it.
  - `:keywordize?` keywordize the keys of return results, default: true
  - `:session` a ClientSession

Additionally takes options specified in `collection`.
sourceraw docstring

insert-manyclj

(insert-many db coll docs)
(insert-many db coll docs opts)

Inserts multiple documents into a collection. If a document does not have an _id field, it will be auto-generated by the underlying driver.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • docs is a collection of maps to insert
  • opts (optional), a map of:
    • :bypass-document-validation? Boolean
    • :ordered? Boolean whether serve should insert documents in order provided (default true)
    • :insert-many-options An InsertManyOptions for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :session A ClientSession

Additionally takes options specified in collection

Inserts multiple documents into a collection.
If a document does not have an _id field, it will be auto-generated by the underlying driver.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `docs` is a collection of maps to insert
- `opts` (optional), a map of:
  - `:bypass-document-validation?` Boolean
  - `:ordered?` Boolean whether serve should insert documents in order provided (default true)
  - `:insert-many-options` An InsertManyOptions for configuring directly. If specified,
    any other [preceding] query options will be applied to it.
  - `:session` A ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

insert-oneclj

(insert-one db coll doc)
(insert-one db coll doc opts)

Inserts a single document into a collection, and returns nil. If the document does not have an _id field, it will be auto-generated by the underlying driver.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • doc is a map to insert.
  • opts (optional), a map of:
    • :bypass-document-validation? Boolean
    • :insert-one-options An InsertOneOptions for configuring directly. If specified, any other [preceding] query options will be applied to it.
    • :session A ClientSession

Additionally takes options specified in collection.

Inserts a single document into a collection, and returns nil.
If the document does not have an _id field, it will be auto-generated by the underlying driver.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `doc` is a map to insert.
- `opts` (optional), a map of:
  - `:bypass-document-validation?` Boolean
  - `:insert-one-options` An InsertOneOptions for configuring directly. If specified,
     any other [preceding] query options will be applied to it.
  - `:session` A ClientSession

Additionally takes options specified in `collection`.
sourceraw docstring

list-indexesclj

(list-indexes db coll)
(list-indexes db coll opts)

Lists indexes.

Lists indexes.
sourceraw docstring

renameclj

(rename db coll new-coll)
(rename db coll new-coll opts)

Renames coll to new-coll in the same DB.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • new-coll is the target collection name
  • opts (optional), a map of:
    • :drop-target? Boolean drop tne target collection if it exists. Default: false
    • :rename-collection-options A RenameCollectionOptions for configuring directly. If specified, any other [preceding] query options will be applied to it
Renames `coll` to `new-coll` in the same DB.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `new-coll` is the target collection name
- `opts` (optional), a map of:
  - `:drop-target?` Boolean drop tne target collection if it exists. Default: false
  - `:rename-collection-options` A RenameCollectionOptions for configuring directly. If specified,
  any other [preceding] query options will be applied to it
sourceraw docstring

replace-oneclj

(replace-one db coll q doc)
(replace-one db coll q doc opts)

Replace a single document in a collection and returns an UpdateResult.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • doc is a new document to add.
  • opts (optional), a map of:
    • :upsert? whether to insert a new document if nothing is found, default: false
    • :bypass-document-validation? Boolean
    • :replace-options A ReplaceOptions for configuring directly. If specified, any other [preceding[ query options will be applied to it.
    • :session a ClientSession

Additionally takes options specified in collection

Replace a single document in a collection and returns an UpdateResult.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `doc` is a new document to add.
- `opts` (optional), a map of:
  - `:upsert?` whether to insert a new document if nothing is found, default: false
  - `:bypass-document-validation?` Boolean
  - `:replace-options` A ReplaceOptions for configuring directly. If specified,
  any other [preceding[ query options will be applied to it.
  - `:session` a ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

update-manyclj

(update-many db coll q update)
(update-many db coll q update opts)

Updates many documents in a collection and returns an UpdateResult.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • update is a map representing an update. The update to apply must include only update operators.
  • opts (optional), a map of:
    • :upsert? whether to insert a new document if nothing is found, default: false
    • :bypass-document-validation? Boolean
    • :update-options An UpdateOptions for configuring directly. If specified, any other [preceding[ query options will be applied to it.
    • :session a ClientSession

Additionally takes options specified in collection

Updates many documents in a collection and returns an UpdateResult.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `update` is a map representing an update. The update to apply must include only update operators.
- `opts` (optional), a map of:
  - `:upsert?` whether to insert a new document if nothing is found, default: false
  - `:bypass-document-validation?` Boolean
  - `:update-options` An UpdateOptions for configuring directly. If specified,
  any other [preceding[ query options will be applied to it.
  - `:session` a ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

update-oneclj

(update-one db coll q update)
(update-one db coll q update opts)

Updates a single document in a collection and returns an UpdateResult.

Arguments:

  • db is a MongoDatabase
  • coll is a collection name
  • q is a map representing a query.
  • update is a map representing an update. The update to apply must include only update operators.
  • opts (optional), a map of:
    • :upsert? whether to insert a new document if nothing is found, default: false
    • :bypass-document-validation? Boolean
    • :update-options An UpdateOptions for configuring directly. If specified, any other [preceding[ query options will be applied to it.
    • :session a ClientSession

Additionally takes options specified in collection

Updates a single document in a collection and returns an UpdateResult.

Arguments:

- `db` is a MongoDatabase
- `coll` is a collection name
- `q` is a map representing a query.
- `update` is a map representing an update. The update to apply must include only update operators.
- `opts` (optional), a map of:
  - `:upsert?` whether to insert a new document if nothing is found, default: false
  - `:bypass-document-validation?` Boolean
  - `:update-options` An UpdateOptions for configuring directly. If specified,
  any other [preceding[ query options will be applied to it.
  - `:session` a ClientSession

Additionally takes options specified in `collection`
sourceraw docstring

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

× close