
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
integreat-adapter-couchdb
Advanced tools
Adapter and authentication strategies to let Integreat use CouchDb and Cloudant as sources.
Requires node v8.6 and Integreat v0.6.
Install from npm:
npm install integreat-adapter-couchdb
Example of use:
const integreat = require('integreat')
const couchdb = require('integreat-adapter-couchdb')
const defs = require('./config')
const resources = couchdb(integreat.resources())
const great = integreat(defs, resources)
// ... and then dispatch actions as usual
The couchdb()
function adds the adapter couchdb
and the authentication
strategy couchdb
to the resources object, but you still need to configure your
source to use these.
Example source configuration:
{
id: 'store',
adapter: 'couchdb',
auth: 'couchdb',
baseUri: 'http://mycouchdb.com/database',
endpoints: {
get: {uri: '/_design/store/_view/by_type_updatedAt?include_docs=true&startkey=["{type}"{updatedAfter|wrap(\\,",")?}]&endkey=["{type}",\\{\\}]', path: 'rows[].doc'},
getOne: '/{id}',
set: {uri: '/_bulk_docs', path: 'docs[]', method: 'POST'},
setOne: '/{id}'
},
mappings: {
'*': {}
}
}
The baseUri
is required with the couchdb
adapter, as it is used to generate
an endpoint for getting _rev
for existing documents. The baseUri
should
include the host and the database name, so that it can append _all_docs
directly after. Ending /
is optional.
It's also important that the path on each endpoint points to items, as the
couchdb
adapter will override normalize
and serialize
methods to alter
the items. These overrides is based on the path pointing to the actual items.
Other than that, these endpoints are examples of a typical way to configure a CouchDb database as a store for Integreat.
Note that the get
endpoint uses a view returning all documents with an array
of type
and updatedAt
as key. This is a better way of returning all
documents of a type than filtering the results from /_all_docs
. Here's an
example of such a view:
{
"views": {
"by_type_updatedAt": {
"map": "function (doc) { emit([doc.type, doc.updatedAt], null); }"
}
}
}
Finally, authorization might be configured like this:
{
id: 'couchdb',
strategy: 'couchdb',
options: {
uri: process.env.COUCHDB_URL,
key: process.env.COUCHDB_KEY,
secret: process.env.COUCHDB_PASSWORD
}
}
The tests can be run with npm test
.
Please read CONTRIBUTING for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the ISC License - see the LICENSE file for details.
FAQs
CouchDB/Cloudant support for Integreat
The npm package integreat-adapter-couchdb receives a total of 6 weekly downloads. As such, integreat-adapter-couchdb popularity was classified as not popular.
We found that integreat-adapter-couchdb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.