clarango.document
create
(create document & args)
Creates a document.
First argument: A map that represents the document.
If you want to specify a key by yourself, add it as the :_key parameter to the document map or use method create-with-key.
If you would like the key to be created automatically, just leave this parameter out.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'createCollection' true/false, 'waitForSync' true/false} (replace the single quotes with double quotes)
- createCollection meaning if the collection should be created if it does not exist yet;
- waitForSync meaning if the server response should wait until the document is saved to disk;
The option map might be passed in an arbitrary position after the first argument.
create-with-key
(create-with-key document key & args)
Creates a document with a given key.
First argument: A map that represents the document.
Second argument: The key for the new document (string or clojure keyword).
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'createCollection' true/false, 'waitForSync' true/false} (replace the single quotes with double quotes)
- createCollection meaning if the collection should be created if it does not exist yet;
- waitForSync meaning if the server response should wait until the document is saved to disk;
The option map might be passed in an arbitrary position after the first argument.
delete-by-example
(delete-by-example example & args)
Deletes a document or a number of documents out of a collection by giving an example to match.
Takes the example as a map as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'limit' limit} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk
- limit meaning the maximum amount of documents that will be deleted
The option map might be passed in an arbitrary position after the first two arguments.
delete-by-key
(delete-by-key & args)
Deletes a document by its id.
Takes the document key as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'rev' revision_id, 'policy' 'error/last'} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk;
- rev is the document revision
- policy meanins the desired behaviour in case the given revision number does not match the latest document revision
-> 'error' meaning that an error is thrown if the given revision_id does not match the revision_id in the document
-> 'last' meaning the document is still deleted even if the given revision_id does not match the revision_id in the document
The option map might be passed in an arbitrary position after the first argument.
delete-by-keys
(delete-by-keys keys & args)
Deletes a number of documents in a single request.
Takes a vector of keys to delete as first argument.
Optionally takes a collection name and a db as further arguments.
If omitted the default db and collection will be used.
get-by-example
(get-by-example example & args)
Gets a document or a number of documents out of a collection by giving an example to match.
Takes the example as a map as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'skip' skip, 'limit' limit} (replace the single quotes with double quotes)
- skip meaning the (number of?) documents to skip in the result
- limit meaning the maximum amount of documents to return
The option map might be passed in an arbitrary position after the first two arguments.
get-by-key
(get-by-key & args)
Gets a document by its key.
Takes the document key as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'rev' revision_id} (replace the single quotes with double quotes)
- rev is the document revision; if the current document revision_id does not match the given one, an error is thrown
The option map might be passed in an arbitrary position after the first two arguments.
get-by-keys
(get-by-keys keys & args)
Gets a number of documents in a single request.
Takes a vector of keys as first argument.
Optionally takes a collection name and a db as further arguments.
If omitted the default db and collection will be used.
get-first-by-example
(get-first-by-example example & args)
Gets the first document out of a collection that matches an example.
Takes the example as a map as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
get-info
(get-info & args)
Gets information about a document by its key.
Takes the document key as first argument.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'rev' revision_id, 'policy' 'error/last'} (replace the single quotes with double quotes)
- rev is the document revision
- policy meaning the desired behaviour in case the given revision number does not match the latest document revision
-> 'error' meaning that an error is thrown if the given revision_id does not match the revision_id in the document
-> 'last' meaning the document is still returned even if the given revision_id does not match the revision_id in the document
The option map might be passed in an arbitrary position after the first two arguments.
replace-by-example
(replace-by-example new-document example & args)
Replaces a document or a number of documents out of a collection by giving an example to match.
First argument: A map representing the new document.
Second argument: The example map.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'limit' limit} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk
- limit meaning the maximum amount of documents that will be replaced
The option map might be passed in an arbitrary position after the first two arguments.
replace-by-key
(replace-by-key new-document & args)
Replaces a document with a map representing the new document.
First argument: A map representing the new document.
Second argument: The document key.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'rev' revision_id, 'policy' 'error/last'} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk
- rev is the document revision
- policy meanins the desired behaviour in case the given revision number does not match the latest document revision
-> 'error' meaning that an error is thrown if the given revision_id does not match the revision_id in the document
-> 'last' meaning the document is still replaced even if the given revision_id does not match the revision_id in the document
The option map might be passed in an arbitrary position after the first two arguments.
update-by-example
(update-by-example document-properties example & args)
Updates a document or a number of documents out of a collection by giving an example to match.
First argument: A map containing the new key/value pairs.
Second argument: The example map.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'limit' limit, 'keepNull' true/false} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk
- limit meaning the maximum amount of documents that will be updated
- keepNull meaning if the key/value pair should be deleted in the document
The option map might be passed in an arbitrary position after the first two arguments.
update-by-key
(update-by-key document-properties & args)
Updates a document with a number of key value pairs. Inserts them into the existing document.
First argument: A map containing the new key/value pairs.
Second argument: The document key.
Takes optional a collection name and a db name as further arguments.
If omitted by user, the default db and collection will be used.
Also optional as argument is another map containing further options:
{'waitForSync' true/false, 'keepNull' true/false, 'rev' revision_id, 'policy' 'error/last'} (replace the single quotes with double quotes)
- waitForSync meaning if the server response should wait until the document is saved to disk;
- keepNull meaning if the key/value pair should be deleted in the document
if the argument map contains it with a null as value;
- rev is the document revision
- policy meanins the desired behaviour in case the given revision number does not match the latest document revision
-> 'error' meaning that an error is thrown if the given revision_id does not match the revision_id in the document
-> 'last' meaning the document is still updated even if the given revision_id does not match the revision_id in the document
The option map might be passed in an arbitrary position after the first two arguments.