0% found this document useful (0 votes)
81 views8 pages

Couchbase CRUD Guide for Developers

This document discusses creating, reading, updating, and deleting (CRUD) documents in Couchbase. It describes how to create documents by adding attributes like name, department, and salary to a JSON object and saving it. It also covers querying data by directly accessing documents by ID, creating views to search data by department, and appending parameters to URLs to include document contents in query results.

Uploaded by

Sanju Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views8 pages

Couchbase CRUD Guide for Developers

This document discusses creating, reading, updating, and deleting (CRUD) documents in Couchbase. It describes how to create documents by adding attributes like name, department, and salary to a JSON object and saving it. It also covers querying data by directly accessing documents by ID, creating views to search data by department, and appending parameters to URLs to include document contents in query results.

Uploaded by

Sanju Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

CRUD - Couchbase

To create new documents in your database, click on the "Data Buckets" tab.

Hpot-Tech

CRUD - Couchbase

Let's create a new documents in the default bucket:

1.
2.
3.
4.
5.

Click on Documents button


Click on Create Document
Since each document must have an id for example 100.
Couchbase save the document and add some metadata such as _rev, $flags, expiration
Add new attributes to the document that describe an employee : Name, Departement and Salary, then save it. You just need to update the JSON
object with values
{
"name": "henry",
"dept": "Sales",
"salary": 5000
}

Create the following documents as shown below:

Hpot-Tech

CRUD - Couchbase

Click on Documents

Hpot-Tech

CRUD - Couchbase

Query Data
Access document directly from its ID

http://192.168.92.128:8092/default/300

Search your data with queries:


Lets create a new view from the Admin Console:

1.
2.
3.

Click on the Views tab (be sure you are on the default bucket)
Click on the "Create Development View"
Enter the Document and View name:
o Document Name : _design/dev_dept
o View Name : dept
Cick Save
Click on your View to edit it

Hpot-Tech

CRUD - Couchbase

Hpot-Tech

CRUD - Couchbase

Change as follow:

function (doc) {
emit(doc.dept, null);
}
Click on show results

Hpot-Tech

CRUD - Couchbase

Try accessing the following URL:


http://192.168.92.128:8092/default/_design/dev_dept/_view/dept

Try appending key parameter in the URL as follows:

Hpot-Tech

CRUD - Couchbase

Append :- &include_docs=true in the url

Hpot-Tech

You might also like