API for karras.collection

by Unknown

Usage:
(ns your-namespace
  (:require karras.collection))

Overview



Public Variables and Functions



collection

function
Usage: (collection collection-name)
       (collection db collection-name)
       (collection mongo db-name collection-name)
Returns a DBCollection.
Source


collection-db

function
Usage: (collection-db collection)
Get the DB that this collection is associated with.
Source


collection-db-name

function
Usage: (collection-db-name collection)
Get the name of the DB that this collection is associated with.
Source


collection-name

function
Usage: (collection-name collection)
Get the name of the collection.
Source


count-docs

function
Usage: (count-docs coll)
       (count-docs coll criteria)
Returns the count of documents, optionally, matching a criteria
Source


delete

function
Usage: (delete coll & queries)
Removes documents matching the supplied queries from a collection.
Source


distinct-values

function
Usage: (distinct-values coll kw)
Fetch a seq of the distinct values of a given collection for a key.
Source


drop-collection

function
Usage: (drop-collection coll)

  Source


drop-index

function
Usage: (drop-index coll o)

  Source


drop-index-named

function
Usage: (drop-index-named coll kw)

  Source


ensure-index

function
Usage: (ensure-index coll fields)
Ensure an index exist on a collection.
Source


ensure-named-index

function
Usage: (ensure-named-index coll name fields)
Ensure an index exist on a collection with the given name.
Source


ensure-unique-index

function
Usage: (ensure-unique-index coll name fields)
Ensure a unique index exist on a collection.
Source


fetch

function
Usage: (fetch coll criteria & options__36__auto__)
Fetch a seq of documents that match a given criteria.
Accepts the following keywords:
    :limit, maximum number of documents to return
    :skip, where in the result set the seq will begin, i.e. paging
    :include, which keys to include in the result set, can not be combined with :exclude
    :exclude, which keys to exclude from the result set, can not be combined with :include
    :sort, which keys to order by
    :count, if true return the count of the result set, defaults to false
Source


fetch-all

function
Usage: (fetch-all coll & options)
Fetch all the documents of a collection. Same options as fetch.
Source


fetch-by-id

function
Usage: (fetch-by-id coll id)
Fetch a document by :_id
Source


fetch-map-reduce-values

function
Usage: (fetch-map-reduce-values map-reduce-result & fetch-options)
Takes the result of map-reduce and fetches the values. Takes the same options as fetch.
Source


fetch-one

function
Usage: (fetch-one coll criteria & options)
Fetch one document of a collection. Supports same options as fetch except :limit and :count
Source


find-and-modify

function
Usage: (find-and-modify coll criteria modifier & options__36__auto__)
See http://www.mongodb.org/display/DOCS/findandmodify+Command
Source


find-and-remove

function
Usage: (find-and-remove coll criteria & options__36__auto__)
See http://www.mongodb.org/display/DOCS/findandmodify+Command
Source


group

function
Usage: (group coll keys)
       (group coll keys cond initial reduce)
       (group coll keys cond initial reduce finalize)
Fetch a seq of grouped items.
Example:
  SQL: select a,b,sum(c) csum from coll where active=1 group by a,b
  Karras: (group coll
                 [:a :b] 
                 {:active 1}
                 {:csum 0}
                 "function(obj,prev) { prev.csum += obj.c; }")
Source


insert

function
Usage: (insert coll & objs)
Inserts one or more documents into a collection. 
Returns the inserted object with :_id
Source


list-indexes

function
Usage: (list-indexes coll)

  Source


map-reduce

function
Usage: (map-reduce coll mapfn reducefn & options__36__auto__)
See http://www.mongodb.org/display/DOCS/MapReduce
Source


map-reduce-fetch-all

var

  
Composes map-reduce and fetch-map-reduce-values and returns all the results.
If you need to filter the results use:
  (fetch-map-reduce-values (map-reduce ...) ...your fetch options...
Source


save

function
Usage: (save coll obj)
Saves a document to a colection, does an upsert behind the scenes.
Returns the object with :_id if it was inserted..
Source


update

function
Usage: (update coll criteria obj & options)
Updates one or more documents in a collection that match the criteria with the document 
provided.
  :upsert, performs an insert if the document doesn't have :_id
  :multi, update all documents that match the criteria
Source


update-all

function
Usage: (update-all coll obj)
       (update-all coll criteria obj)
Shortcut for (update collection criteria obj :multi)
Source


upsert

function
Usage: (upsert coll obj)
       (upsert coll criteria obj)
Shortcut for (update collection criteria obj :upsert)
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.