CouchDB
Apache CouchDB is an open source document-oriented NoSQL database.
Official Websitehttps://couchdb.apache.org/
TagsNoSQLDatabase
- JavaScript
- Python
Documentationhttps://github.com/apache/couchdb-nano
NodeJS packagehttps://www.npmjs.com/package/nano
Version10.1.2
Source Codehttps://github.com/apache/couchdb-nano
Comming soon
We are releasing new Python features every week
Network Connection needs
This integration needs network access to the server where the service is running.
See the Network access page for details about how to achieve that.
Credential configuration
Fill in the appropiate values for your CouchDB connection. Specify the required fields: url
, username
and password
.
In the extra options field, you can provide any of the parameters found here.
Here is an example of a filled credential configuration form in YepCode:
CouchDB Snippets available in editor
note
The title is the triggering text for YepCode to autocomplete the script.
- JavaScript
- Python
Integration
New integration from credential
const couchdb = await yepcode.integration.couchdb('credential-slug')
New integration from plain authentication data
const couchdb = require("nano")({
url: "url"
});
await couchdb.auth("username", "password");
// You should use a yepcode env variable to don't store plain password
// See: https://docs.yepcode.io/docs/processes/team-variables
Create a Database
Create a database
await couchdb.db.create("database-name")
.then(() => console.log(`Database created!`))
.catch(console.error);
Insert a Document
Insert a document
const sampleDocument = { foo: 'bar' };
await couchdb.use("database-name").insert(sampleDocument)
.then((result) => console.log(`Document inserted! ID: ${result.id}`))
.catch(console.error);
Get a Document
Get a document
await couchdb.use("database-name").get("document-id")
.then((result) => console.log(result))
.catch(console.error);
Find Documents
Find documents
// See available options at: https://docs.couchdb.org/en/latest/api/database/find.html#db-find
const query = {
selector: {
name: "John Doe",
age: { $gte: 18 },
},
};
await couchdb.use("database-name").find(query);
.then((result) => {
result.docs.forEach((doc) => {
console.log(doc);
});
})
.catch(console.error);
List all Documents
List all documents
await couchdb.use("database-name").list()
.then((result) => {
console.log(`Showing ${result.total_rows} documents`)
result.rows.forEach((row) => {
console.log(row);
});
})
.catch(console.error);
Delete a Document
Delete a document
await couchdb.use("database-name").destroy("document-id", "document-rev")
.then(() => console.log(`Document deleted!`))
.catch(console.error);
Delete a Database
Delete a database
await couchdb.db.destroy("database-name")
.then(() => console.log(`Database deleted!`))
.catch(console.error);
Comming soon
We are releasing new Python features every week