Service: CouchDB - EyevinnOSC/community GitHub Wiki
Getting Started
The open source project Apache CouchDB available as a service in Eyevinn Open Source Cloud provides a serverless NoSQL document database. This tutorial walks you through how you quickly can get started using NoSQL document database in Eyevinn Open Source Cloud.
Prerequisites
- If you have not already done so, sign up for an Eyevinn OSC account.
Step 1: Setup secrets
Create a service secret for the database admin password.
adminpassword=secret
The admin password to just serve as an example.
Step 2: Create a database server
Click on the button "Create couchdb" in the web user interface. Then, enter your desired instance name and an admin password in the Create CouchDB dialog.
Press the button Create and wait for the instance to be in status Running.
Step 3: Access the database
When the database instance is running you can click on the instance card.
Login as admin
and with the password you set in the secret in step 1.
Now you can create a database guide
and create a document.
The connection URL to this database instance in this example is https://admin:[email protected]
, and you can use any of the CouchDB clients available to access the documents from your application. The following example is using the JavaScript library nano
.
const url = new URL('https://eyevinnlab-guide.apache-couchdb.auto.prod.osaas.io');
url.password = 'secret';
url.username = 'admin';
const client = nano(url.toString());
const db = client.db.use('guide');
await db.insert({
title: 'Getting started with NoSQL in Eyevinn OSC',
content: 'Learn the basics of NoSQL in Eyevinn OSC',
author: 'Jonas Birmé',
createdAt: new Date()
});
Adding CORS to your CouchDB
In the CouchDB interface, you can add Cross-Origin Resource Sharing (CORS). To do so, press the gear icon in the navigation bar and select "CORS" in the Configuration menu.
Then, press "Enable CORS" if it has not already been enabled. You will then be able to enter domains that your database will accept requests from.