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