reject the request promise when reading a response body fails. Fixes issue #375 (#376)
When the connection breaks off after the response headers, reading the body fails. For JSON responses that error was swallowed and the request resolved with
''; for text and binary responses it escaped the un-awaited responseHandler, leaving the request promise unsettled and causing an unhandled rejection. Read JSON bodies as text before parsing them, so that only parse errors are ignored, and chain responseHandler in relax() so that any failure rejects the request.Co-authored-by: Claude Opus 5.5 noreply@anthropic.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
Nano
Offical Apache CouchDB library for Node.js.
Features:
...AsStreamfunctions only)nano.Installation
npm install nanoor save
nanoas a dependency of your project withNote the minimum required version of Node.js is 10.
Table of contents
Getting started
Tutorials & screencasts
Configuration
Database functions
Document functions
Partitioned database functions
Multipart functions
Attachments functions
Views and design functions
Using cookie authentication
Advanced features
Tests
Release
Getting started
To use
nanoyou need to connect it to your CouchDB install, to do that:To create a new database:
and to use an existing database:
Under-the-hood, calls like
nano.db.createare making HTTP API calls to the CouchDB service. Such operations are asynchronous. There are two ways to receive the asynchronous data back from the libraryThe documentation will follow the async/await style.
A simple but complete example in the async/await style:
Running this example will produce:
You can also see your document in futon (http://127.0.0.1:5984/_utils).
Configuration
Configuring nano to use your database server is as simple as:
If you don’t need to instrument database objects you can simply:
You can tell nano to not parse the URL (maybe the server is behind a proxy, is accessed through a rewrite rule or other):
Pool size and open sockets
To specify the number of connections, timeouts and pool size, supply an
agentOptionsobject when starting up Nano.The meanings of the agentOptions attributes is described here, here and here
You may also supply a pre-existing
undici.Agente.g.Custom headers
To supply customer headers with each request, supply a headers object when starting up Nano:
TypeScript
There is a full TypeScript definition included in the the nano package. Your TypeScript editor will show you hints as you write your code with the nano library with your own custom classes:
Database functions
nano.db.create(name, [opts])
Creates a CouchDB database with the given
name, with optionsopts.nano.db.get(name)
Get information about the database
name:nano.db.destroy(name)
Destroys the database
name:nano.db.list()
Lists all the CouchDB databases:
nano.db.listAsStream()
Lists all the CouchDB databases as a stream:
nano.db.compact(name, [designname])
Compacts
name, ifdesignnameis specified also compacts its views.nano.db.replicate(source, target, [opts])
Replicates
sourcetotargetwith optionsopts. Thetargetdatabase has to exist, addcreate_target:truetooptsto create it prior to replication:nano.db.replication.enable(source, target, [opts])
Enables replication using the new CouchDB api from
sourcetotargetwith optionsopts.targethas to exist, addcreate_target:truetooptsto create it prior to replication. Replication will survive server restarts.nano.db.replication.query(id, [opts])
Queries the state of replication using the new CouchDB API. The
idcomes from the response given by the call toreplication.enable:nano.db.replication.disable(id, [opts])
Disables replication using the new CouchDB API. The
idcomes from the response given by the call toreplication.enable:nano.db.changes(name, [params])
Asks for the changes feed of
name,paramscontains additions to the query string.nano.db.changesAsStream(name, [params])
Same as
nano.db.changesbut returns a stream.nano.db.info()
Gets database information:
nano.use(name)
Returns a database object that allows you to perform operations against that database:
The database object can be used to access the Document Functions.
nano.db.use(name)
Alias for
nano.usenano.db.scope(name)
Alias for
nano.usenano.scope(name)
Alias for
nano.usenano.request(opts)
Makes a custom request to CouchDB. This can be used to create your own HTTP request to the CouchDB server, to perform operations where there is no
nanofunction that encapsulates it. The availableoptsare:opts.db– the database nameopts.method– the http method, defaults togetopts.path– the full path of the request, overridesopts.docandopts.attopts.doc– the document nameopts.att– the attachment nameopts.qs– query string parameters, appended after any existingopts.path,opts.doc, oropts.attopts.content_type– the content type of the request, default tojsonopts.headers– additional http headers, overrides existing onesopts.body– the document or attachment bodyopts.encoding– the encoding for attachmentsopts.multipart– array of objects for multipart requestopts.stream- iftrue, arequestobject is returned. Defaultfalseand a Promise is returned.nano.relax(opts)
Alias for
nano.requestnano.config
An object containing the
nanoconfigurations, possible keys are:url- the CouchDB URLdb- the database namenano.updates([params])
Listen to db updates, the available
paramsare:params.feed– Type of feed. Can be one oflongpoll: Closes the connection after the first event.continuous: Send a line of JSON per event. Keeps the socket open until timeout.eventsource: Like, continuous, but sends the events in EventSource format.params.timeout– Number of seconds until CouchDB closes the connection. Default is 60.params.heartbeat– Whether CouchDB will send a newline character (\n) on timeout. Default is true.nano.info()
Fetch information about the CouchDB cluster:
The response is an object with CouchDB cluster information.
Document functions
db.insert(doc, [params])
Inserts
docin the database with optionalparams. If params is a string, it’s assumed it is the intended document_id. If params is an object, it’s passed as query string parameters anddocNameis checked for defining the document_id:The
insertfunction can also be used with the method signaturedb.insert(doc,), where thedoccontains the_idfield e.g.and also used to update an existing document, by including the
_revtoken in the document being saved:db.destroy(docname, rev)
Removes a document from CouchDB whose
_idisdocnameand whose revision (_rev) isrev:db.get(docname, [params])
Gets a document from CouchDB whose
_idisdocname:or with optional query string
params:If you pass
attachments=true, thedoc._attachments.attachmentNameN.datafields will contain the base-64 encoded attachments. Or, you can usedb.multipart.getand parse the returned buffer to get the document and attachments.See the attachments methods to retrieve just an attachment.
db.head(docname)
Same as
getbut lightweight version that returns headers only:db.bulk(docs, [params])
Bulk operations(update/delete/insert) on the database, refer to the CouchDB doc e.g:
db.list([params])
List all the docs in the database .
or with optional query string additions
params:db.listAsStream([params])
List all the docs in the database as a stream.
db.fetch(docnames, [params])
Bulk fetch of the database documents,
docnamesare specified as per CouchDB doc. additional query stringparamscan be specified,include_docsis always set totrue.db.fetchRevs(docnames, [params])
** changed in version 6 **
Bulk fetch of the revisions of the database documents,
docnamesare specified as per CouchDB doc. additional query stringparamscan be specified, this is the same method as fetch butinclude_docsis not automatically set totrue.db.createIndex(indexDef)
Create index on database fields, as specified in CouchDB doc.
Reading Changes Feed
Nano provides a low-level API for making calls to CouchDB’s changes feed, or if you want a reliable, resumable changes feed follower, then you need the
changesReader.There are three ways to start listening to the changes feed:
changesReader.start()- to listen to changes indefinitely by repeated “long poll” requests. This mode continues to poll for changes untilchangesReader.stop()is called, at which point any active long poll will be canceled.changesReader.get()- to listen to changes until the end of the changes feed is reached, by repeated “long poll” requests. Once a response with zero changes is received, the ‘end’ event will indicate the end of the changes and polling will stop.changesReader.spool()- listen to changes in one long HTTP request. (as opposed to repeated round trips) - spool is faster but less reliable.Set up your database connection and then choose
changesReader.start()to listen to that database’s changes:If you want
changesReaderto hold off making the next_changesAPI call until you are ready, then supplywait:truein the options toget/start. The next request will only fire when you callchangesReader.resume():You may supply a number of options when you start to listen to the changes feed:
batchevent.0means the beginning of time,nowmeans the current position or a string token indicates a fixed position in the changes feedget/startmode, automatically pause the changes reader after each request. When the the user callsresume(), the changes reader will resume.The events it emits are as follows:s
get/startmodes.batchSize.ChangesReaderas thesinceparameter to resume changes feed consumption from a known point. Only available inget/startmodes.ChangesReader.get()mode only,The ChangesReader library will handle many temporal errors such as network connectivity, service capacity limits and malformed data but it will emit an
errorevent and exit when fed incorrect authentication credentials or an invalidsincetoken.The
changeevent delivers a change object that looks like this:N.B
docis only present ifincludeDocs:trueis suppliedseqis not present for every changeThe
idis the unique identifier of the document that changed and thechangesarray contains the document revision tokens that were written to the database.The
batchevent delivers an array of change objects.Partition Functions
Functions related to partitioned databases.
Create a partitioned database by passing
{ partitioned: true }todb.create:The database can be used as normal:
but documents must have a two-part
_idmade up of<partition key>:<document id>. They are insert withdb.insertas normal:Documents can be retrieved by their
_idusingdb.get:Mango indexes can be created to operate on a per-partition index by supplying
partitioned: trueon creation:Search indexes can be created by writing a design document with
opts.partitioned = true:MapReduce views can be created by writing a design document with
opts.partitioned = true:db.partitionInfo(partitionKey)
Fetch the stats of a single partition:
db.partitionedList(partitionKey, [params])
Fetch documents from a database partition:
db.partitionedListAsStream(partitionKey, [params])
Fetch documents from a partition as a stream:
db.partitionedFind(partitionKey, query, [params])
Query documents from a partition by supplying a Mango selector:
db.partitionedFindAsStream(partitionKey, query)
Query documents from a partition by supplying a Mango selector as a stream:
db.partitionedSearch(partitionKey, designName, searchName, params)
Search documents from a partition by supplying a Lucene query:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedSearchAsStream(partitionKey, designName, searchName, params)
Search documents from a partition by supplying a Lucene query as a stream:
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } await db.partitionedSearch(‘canidae’, ‘search-ddoc’, ‘search-index’, params) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedSearchAsStream(partitionKey, designName, searchName, params)
Search documents from a partition by supplying a Lucene query as a stream:
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } await db.partitionedSearch(‘canidae’, ‘search-ddoc’, ‘search-index’, params) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } db.partitionedSearchAsStream(‘canidae’, ‘search-ddoc’, ‘search-index’, params) .on(‘error’, (e) => console.error(‘error’, e)) .pipe(process.stdout) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedSearchAsStream(partitionKey, designName, searchName, params)
Search documents from a partition by supplying a Lucene query as a stream:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } await db.partitionedSearch(‘canidae’, ‘search-ddoc’, ‘search-index’, params) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } await db.partitionedSearch(‘canidae’, ‘search-ddoc’, ‘search-index’, params) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } db.partitionedSearchAsStream(‘canidae’, ‘search-ddoc’, ‘search-index’, params) .on(‘error’, (e) => console.error(‘error’, e)) .pipe(process.stdout) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } await db.partitionedSearch(‘canidae’, ‘search-ddoc’, ‘search-index’, params) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
Wolf```
db.partitionedView(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition:
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch
‘ } db.partitionedSearchAsStream(‘canidae’, ‘search-ddoc’, ‘search-index’, params) .on(‘error’, (e) => console.error(‘error’, e)) .pipe(process.stdout) // { total_rows: … , bookmark: …, rows: [ …] }
db.partitionedViewAsStream(partitionKey, designName, viewName, params)
Fetch documents from a MapReduce view from a partition as a stream:
Multipart functions
db.multipart.insert(doc, attachments, params)
Inserts a
doctogether withattachmentsandparams. If params is a string, it’s assumed as the intended document_id. If params is an object, its passed as query string parameters anddocNameis checked for defining the_id. Refer to the doc for more details. Theattachmentsparameter must be an array of objects withname,dataandcontent_typeproperties.db.multipart.get(docname, [params])
Get
docnametogether with its attachments viamultipart/relatedrequest with optional query string additions. The multipart response body is aBuffer.Attachments functions
db.attachment.insert(docname, attname, att, contenttype, [params])
Inserts an attachment
attnametodocname, in most casesparams.revis required. Refer to the CouchDB doc for more details.db.attachment.insertAsStream(docname, attname, att, contenttype, [params])
As of Nano 9.x, the function
db.attachment.insertAsStreamis now deprecated. Now simply pass a readable stream todb.attachment.insertas the third paramseter.db.attachment.get(docname, attname, [params])
Get
docname‘s attachmentattnamewith optional query string additionsparams.db.attachment.getAsStream(docname, attname, [params])
db.attachment.destroy(docname, attname, [params])
changed in version 6
Destroy attachment
attnameofdocname‘s revisionrev.Views and design functions
db.view(designname, viewname, [params])
Calls a view of the specified
designnamewith optional query stringparams. If you’re looking to filter the view results by key(s) pass an array of keys, e.g{ keys: ['key1', 'key2', 'key_n'] }, asparams.or
When
paramsis not supplied, or no keys are specified, it will simply return all documents in the view:db.viewAsStream(designname, viewname, [params])
Same as
db.viewbut returns a stream:db.viewWithList(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document.
db.viewWithListAsStream(designname, viewname, listname, [params])
Calls a list function fed by the given view from the specified design document as a stream.
db.show(designname, showname, doc_id, [params])
Calls a show function from the specified design for the document specified by doc_id with optional query string additions
params.Take a look at the CouchDB wiki for possible query paramaters and more information on show functions.
db.atomic(designname, updatename, docname, [body])
Calls the design’s update function with the specified doc in input.
Note that the data is sent in the body of the request. An example update handler follows:
db.search(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params.or
Check out the tests for a fully functioning example.
db.searchAsStream(designname, searchname, params)
Calls a view of the specified design with optional query string additions
params. Returns stream.db.find(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector:
db.findAsStream(selector)
Perform a “Mango” query by supplying a JavaScript object containing a selector, but return a stream:
using cookie authentication
Nano supports making requests using CouchDB’s cookie authentication functionality. If you initialise Nano so that it is cookie-aware, you may call
nano.authfirst to get a session cookie. Nano will behave like a web browser, remembering your session cookie and refreshing it if a new one is received in a future HTTP response.The second request works because the
nanolibrary has remembered theAuthSessioncookie that was invisibily returned by thenano.authcall.When you have a session, you can see what permissions you have by calling the
nano.sessionfunctionAdvanced features
Getting uuids
If your application needs to generate UUIDs, then CouchDB can provide some for you
The first parameter is the number of uuids to generate. If omitted, it defaults to 1.
Extending nano
nanois minimalistic but you can add your own features withnano.request(opts)For example, to create a function to retrieve a specific revision of the
rabbitdocument:Pipes
You can pipe the return values of certain nano functions like other stream. For example if our
rabbitdocument has an attachment with namepicture.pngyou can pipe it to awritable stream:then open
/tmp/rabbit.pngand you will see the rabbit picture.Functions that return streams instead of a Promise are:
attachment functions:
and document level functions
Logging
When instantiating Nano, you may supply the function that will perform the logging of requests and responses. In its simplest for, simply pass
console.logas your logger:You may supply your own logging function to format the data before output:
Tutorials, examples in the wild & screencasts
Roadmap
Check issues
Tests
To run (and configure) the test suite simply:
Meta
git clone git://github.com/apache/couchdb-nano.githttps://freenode.org/
Release
To create a new release of nano. Run the following commands on the main branch