Liking cljdoc? Tell your friends :D

monger.collection

Provides key functionality for interaction with MongoDB: inserting, querying, updating and deleting documents, performing Aggregation Framework queries, creating and dropping indexes, creating collections and more.

For more advanced read queries, see monger.query.

Related documentation guides:

Provides key functionality for interaction with MongoDB: inserting, querying, updating and deleting documents, performing Aggregation Framework
queries, creating and dropping indexes, creating collections and more.

For more advanced read queries, see monger.query.

Related documentation guides:

* http://clojuremongodb.info/articles/getting_started.html
* http://clojuremongodb.info/articles/inserting.html
* http://clojuremongodb.info/articles/querying.html
* http://clojuremongodb.info/articles/updating.html
* http://clojuremongodb.info/articles/deleting.html
* http://clojuremongodb.info/articles/aggregation.html
raw docstring

aggregateclj

(aggregate db coll stages & opts)

Executes an aggregation query. MongoDB 2.2+ only. Accepts the options :allow-disk-use and :cursor (a map with the :batch-size key), as described in the MongoDB manual. Additionally, the :max-time option is supported, for specifying a limit on the execution time of the query in milliseconds.

:keywordize option that control if resulting map keys will be turned into keywords, default is true.

See http://docs.mongodb.org/manual/applications/aggregation/ to learn more.

Executes an aggregation query. MongoDB 2.2+ only.
 Accepts the options :allow-disk-use and :cursor (a map with the :batch-size
 key), as described in the MongoDB manual. Additionally, the :max-time option
is supported, for specifying a limit on the execution time of the query in
milliseconds.

:keywordize option that control if resulting map keys will be turned into keywords, default is true.

See http://docs.mongodb.org/manual/applications/aggregation/ to learn more.
sourceraw docstring

any?clj

(any? db coll)
(any? db coll conditions)

Whether the collection has any items at all, or items matching query.

Whether the collection has any items at all, or items matching query.
sourceraw docstring

countclj

(count db coll)
(count db coll conditions)

Returns the number of documents in this collection.

Takes optional conditions as an argument.

Returns the number of documents in this collection.

Takes optional conditions as an argument.
sourceraw docstring

createclj

(create db coll options)

Creates a collection with a given name and options.

Options are:

:capped (pass true to create a capped collection) :max (number of documents) :size (max allowed size of the collection, in bytes)

Creates a collection with a given name and options.

Options are:

:capped (pass true to create a capped collection)
:max (number of documents)
:size (max allowed size of the collection, in bytes)
sourceraw docstring

create-indexclj

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

Forces creation of index on a set of fields, if one does not already exists.

Forces creation of index on a set of fields, if one does not already exists.
sourceraw docstring

distinctclj

(distinct db coll key)
(distinct db coll key query)

Finds distinct values for a key

Finds distinct values for a key
sourceraw docstring

dropclj

(drop db coll)

Deletes collection from database.

Deletes collection from database.
sourceraw docstring

drop-indexclj

(drop-index db coll idx)

Drops an index from this collection.

Drops an index from this collection.
sourceraw docstring

drop-indexesclj

(drop-indexes db coll)

Drops all indixes from this collection.

Drops all indixes from this collection.
sourceraw docstring

empty?clj

(empty? db coll)

Whether the collection is empty.

Whether the collection is empty.
sourceraw docstring

ensure-indexclj

(ensure-index db coll keys)
(ensure-index db coll keys options)
(ensure-index db coll keys index-name unique?)

Creates an index on a set of fields, if one does not already exist. This operation is inexpensive in the case when an index already exists.

Options are:

:unique (boolean) to create a unique index :name (string) to specify a custom index name and not rely on the generated one

Creates an index on a set of fields, if one does not already exist.
This operation is inexpensive in the case when an index already exists.

Options are:

:unique (boolean) to create a unique index
:name (string) to specify a custom index name and not rely on the generated one
sourceraw docstring

exists?clj

(exists? db coll)

Checks weather collection with certain name exists.

Checks weather collection with certain name exists.
sourceraw docstring

explain-aggregateclj

(explain-aggregate db coll stages & opts)

Returns the explain plan for an aggregation query. MongoDB 2.2+ only.

See http://docs.mongodb.org/manual/applications/aggregation/ to learn more.

Returns the explain plan for an aggregation query. MongoDB 2.2+ only.

See http://docs.mongodb.org/manual/applications/aggregation/ to learn more.
sourceraw docstring

findclj

(find db coll)
(find db coll ref)
(find db coll ref fields)

Queries for objects in this collection. This function returns DBCursor, which allows you to iterate over DBObjects. If you want to manipulate clojure sequences maps, use find-maps.

Queries for objects in this collection.
This function returns DBCursor, which allows you to iterate over DBObjects.
If you want to manipulate clojure sequences maps, use find-maps.
sourceraw docstring

find-and-modifyclj

(find-and-modify db
                 coll
                 conditions
                 document
                 {:keys [fields sort remove return-new upsert keywordize]
                  :or {fields nil
                       sort nil
                       remove false
                       return-new false
                       upsert false
                       keywordize true}})

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

Atomically modify a document (at most one) and return it.
sourceraw docstring

find-by-idclj

(find-by-id db coll id)
(find-by-id db coll id fields)

Returns a single object with matching _id field.

Returns a single object with matching _id field.
sourceraw docstring

find-map-by-idclj

(find-map-by-id db coll id)
(find-map-by-id db coll id fields)
(find-map-by-id db coll id fields keywordize)

Returns a single object, converted to map with matching _id field.

Returns a single object, converted to map with matching _id field.
sourceraw docstring

find-mapsclj

(find-maps db coll)
(find-maps db coll ref)
(find-maps db coll ref fields)
(find-maps db coll ref fields keywordize)

Queries for objects in this collection. This function returns clojure Seq of Maps. If you want to work directly with DBObject, use find.

Queries for objects in this collection.
This function returns clojure Seq of Maps.
If you want to work directly with DBObject, use find.
sourceraw docstring

find-oneclj

(find-one db coll ref)
(find-one db coll ref fields)

Returns a single DBObject from this collection matching the query.

Returns a single DBObject from this collection matching the query.
sourceraw docstring

find-one-as-mapclj

(find-one-as-map db coll ref)
(find-one-as-map db coll ref fields)
(find-one-as-map db coll ref fields keywordize)

Returns a single object converted to Map from this collection matching the query.

Returns a single object converted to Map from this collection matching the query.
sourceraw docstring

find-seqclj

(find-seq db coll)
(find-seq db coll ref)
(find-seq db coll ref fields)

Queries for objects in this collection, returns ISeq of DBObjects.

Queries for objects in this collection, returns ISeq of DBObjects.
sourceraw docstring

indexes-onclj

(indexes-on db coll)

Return a list of the indexes for this collection.

Return a list of the indexes for this collection.
sourceraw docstring

insertclj

(insert db coll document)
(insert db coll document concern)

Saves document to collection and returns a write result monger.result/acknowledged? and related functions operate on. You can optionally specify a WriteConcern.

In case you need the exact inserted document returned, with the :_id key generated, use monger.collection/insert-and-return instead.

Saves document to collection and returns a write result monger.result/acknowledged?
and related functions operate on. You can optionally specify a WriteConcern.

In case you need the exact inserted document returned, with the :_id key generated,
use monger.collection/insert-and-return instead.
sourceraw docstring

insert-and-returnclj

(insert-and-return db coll document)
(insert-and-return db coll document concern)

Like monger.collection/insert but returns the inserted document as a persistent Clojure map.

If the :_id key wasn't set on the document, it will be generated and merged into the returned map.

Like monger.collection/insert but returns the inserted document as a persistent Clojure map.

If the :_id key wasn't set on the document, it will be generated and merged into the returned
map.
sourceraw docstring

insert-batchclj

(insert-batch db coll documents)
(insert-batch db coll documents concern)

Saves documents do collection. You can optionally specify WriteConcern as a third argument.

Saves documents do collection. You can optionally specify WriteConcern as a third argument.
sourceraw docstring

map-reduceclj

(map-reduce db coll js-mapper js-reducer output query)
(map-reduce db coll js-mapper js-reducer output output-type query)

Performs a map reduce operation

Performs a map reduce operation
sourceraw docstring

purge-manyclj

(purge-many db xs)

Purges (removes all documents from) multiple collections. Intended to be used in test environments.

Purges (removes all documents from) multiple collections. Intended
to be used in test environments.
sourceraw docstring

removeclj

(remove db coll)
(remove db coll conditions)

Removes objects from the database.

Removes objects from the database.
sourceraw docstring

remove-by-idclj

(remove-by-id db coll id)

Removes a single document with given id

Removes a single document with given id
sourceraw docstring

renameclj

(rename db from to)
(rename db from to drop-target?)

Renames collection.

Renames collection.
sourceraw docstring

saveclj

(save db coll document)
(save db coll document write-concern)

Saves an object to the given collection (does insert or update based on the object _id).

If the object is not present in the database, insert operation will be performed. If the object is already in the database, it will be updated.

This function returns write result. If you want to get the exact persisted document back, use save-and-return.

Saves an object to the given collection (does insert or update based on the object _id).

If the object is not present in the database, insert operation will be performed.
If the object is already in the database, it will be updated.

This function returns write result. If you want to get the exact persisted document back,
use `save-and-return`.
sourceraw docstring

save-and-returnclj

(save-and-return db coll document)
(save-and-return db coll document write-concern)

Saves an object to the given collection (does insert or update based on the object _id).

If the object is not present in the database, insert operation will be performed. If the object is already in the database, it will be updated.

This function returns the exact persisted document back, including the :_id key in case of an insert.

If you want to get write result back, use save.

Saves an object to the given collection (does insert or update based on the object _id).

If the object is not present in the database, insert operation will be performed.
If the object is already in the database, it will be updated.

This function returns the exact persisted document back, including the `:_id` key in
case of an insert.

If you want to get write result back, use `save`.
sourceraw docstring

system-collection-patternclj

source

system-collection?clj

(system-collection? coll)

Evaluates to true if the given collection name refers to a system collection. System collections are prefixed with system. or fs. (default GridFS collection prefix)

Evaluates to true if the given collection name refers to a system collection. System collections
are prefixed with system. or fs. (default GridFS collection prefix)
sourceraw docstring

updateclj

(update db coll conditions document)
(update db
        coll
        conditions
        document
        {:keys [upsert multi write-concern]
         :or
           {upsert false multi false write-concern mc/*mongodb-write-concern*}})

Performs an update operation.

Please note that update is potentially destructive operation. It updates document with the given set emptying the fields not mentioned in the new document. In order to only change certain fields, use "$set".

You can use all the MongoDB modifier operations ($inc, $set, $unset, $push, $pushAll, $addToSet, $pop, $pull $pullAll, $rename, $bit) here as well.

It also takes options, such as :upsert and :multi. By default :upsert and :multi are false.

Performs an update operation.

Please note that update is potentially destructive operation. It updates document with the given set
emptying the fields not mentioned in the new document. In order to only change certain fields, use
"$set".

You can use all the MongoDB modifier operations ($inc, $set, $unset, $push, $pushAll, $addToSet, $pop, $pull
$pullAll, $rename, $bit) here as well.

It also takes options, such as :upsert and :multi.
By default :upsert and :multi are false.
sourceraw docstring

update-by-idclj

(update-by-id db coll id document)
(update-by-id db
              coll
              id
              document
              {:keys [upsert write-concern]
               :or {upsert false write-concern mc/*mongodb-write-concern*}})

Update a document with given id

Update a document with given id
sourceraw docstring

update-by-idsclj

(update-by-ids db coll ids document)
(update-by-ids db
               coll
               ids
               document
               {:keys [upsert write-concern]
                :or {upsert false write-concern mc/*mongodb-write-concern*}})

Update documents by given ids

Update documents by given ids
sourceraw docstring

upsertclj

(upsert db coll conditions document)
(upsert db
        coll
        conditions
        document
        {:keys [multi write-concern]
         :or {multi false write-concern mc/*mongodb-write-concern*}})

Performs an upsert.

This is a convenience function that delegates to monger.collection/update and sets :upsert to true.

See monger.collection/update documentation

Performs an upsert.

This is a convenience function that delegates to monger.collection/update and
sets :upsert to true.

See monger.collection/update documentation
sourceraw docstring

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

× close