bedquilt.core

add-constraints

(add-constraints spec collection-name constraints)
Add a set of constraints to the collection.
Returns true if any constraints were added by this command

collection-exists?

(collection-exists? spec collection-name)
Check if a collection exists currently.
Returns boolean.

count

(count spec collection-name)(count spec collection-name query-doc)
Get a count of documents in the collection.

create-collection

(create-collection spec collection-name)
Create a collection if it does not already exist.
Returns boolean indicating whether the collection was created by this command.

delete-collection

(delete-collection spec collection-name)
Delete a collection if it exists.
Returns boolean indicating whether the collection was deleted by this command.

distinct

(distinct spec collection-name dotted-path)
Get a sequence of unique values at the given dotted-path.
Example: (bq/distinct db "people" "address.city")

find

(find spec collection-name)(find spec collection-name query-doc)(find spec collection-name query-doc {:keys [skip limit sort], :as options})
Find documents from the collection matching a given query.

find-many-by-ids

(find-many-by-ids spec collection-name doc-ids)
Find documents which have _id in the supplied sequence of doc-ids.
Returns a potentially empty sequence of docs.

find-one

(find-one spec collection-name)(find-one spec collection-name query-doc)(find-one spec collection-name query-doc {:keys [skip sort], :as options})
Find a single document from the collection matching a given query.
Returns a map, or nil if not found.

find-one-by-id

(find-one-by-id spec collection-name doc-id)
Find a single document which has a _id equal to the supplied doc-id.
Returns a map, or nil if not found.

insert

(insert spec collection-name doc)
Insert a document (map) into the collection

list-collections

(list-collections spec)
Get a list of collections on the server.
Returns a sequence of strings

list-constraints

(list-constraints spec collection-name)
Get a list of constraints on this collection.

make-db-spec

(make-db-spec spec)
Build a connection spec, same as a clojure.java.jdbc spec.
This function will add the appropriate PostgreSQL bits to the supplied
spec map.
See http://clojure.github.io/java.jdbc/#clojure.java.jdbc/get-connection.
Example:
  (def spec (bq/make-db-spec {:subname "//localhost/some_db"
                              :user "a_username"
                              :password "a_bad_password"}))

remove

(remove spec collection-name query-doc)
Remove documunts matching the supplied query-doc.

remove-constraints

(remove-constraints spec collection-name constraints)
Remove a set of constraints from the collection.
Returns true if any constraints were removed by this command

remove-many-by-ids

(remove-many-by-ids spec collection-name doc-ids)
Remove many documents, by their _id fields

remove-one

(remove-one spec collection-name query-doc)
Remove a single document matching the supplied query-doc.

remove-one-by-id

(remove-one-by-id spec collection-name doc-id)
Remove a single document which has a _id value matching the supplied doc-id.

save

(save spec collection-name doc)
Save a document (map) to the collection, overwriting any existing
doc with the same _id value.

with-connection

macro

(with-connection binding & body)
Evaluates body expressions in the context of a single db connection.
Example:
  (bq/with-connection [conn spec]
    (bq/insert conn "things" {:a 1})
    (bq/insert conn "things" {:a 2}))