The central database structures in CouchDB is said to be a document and the essence of the database are saved in terms of documents rather then tabular forms and these documents can be created based on Futon and with utility of cURL.
Document creating using Futon
Description
The following steps describes the process of creating a document using futon.
Step - 1
For creating a database document open http://127.0.0.1:5984/_utils/.
Step - 2
Click on splessons1.
Step - 3
Click on New Document.
Step - 4
Enter _id value and click tick button.
Step - 5
Click on Add Field.
Step - 6
Enter the new field values and click tick button.
Step - 7
Entered field names with null values.
Step - 8
Click on source button.
Step - 9
The source code will display the documents with null values.
Document creating using cURL Utility
Description
Database documents can be created in CouchDB by passing a HTTP solicitation to the server utilizing PUT techniques over the utility of cURL.
Syntax
The syntax for creating a document using cURL utility.
$ curl -X PUT http://127.0.0.1:5984/database name/"id" -d ' { document} '
X => HTTP request.
PUT => Operation/methods in the url's.
-d => Sending the documents through HTTP request.
Examples
By viewing the below example, the concept of creating a document can be easily understand.
[c]
$ curl -X PUT http://127.0.0.1:5984/my_database/"001" -d
'{ " Name " : " Mike " , " age " :" 25 " , " Designation " : " Database Administrator" }'
{"ok":true,"id":"001","rev":"1-1c2fae390fa5475d9b809301bbf3f25e"}
$ curl -X GET http://127.0.0.1:5984/my_database/001
{
"_id": "001",
"_rev": "1-3fcc78daac7a90803f0a5e383f4f1e1e",
"Name": "Mike",
"age": 25,
"Designation": "Database Administrator"
}
[/c]
Here in the above example a document as been successfully created and get verified that whether all the value in the document exists are not.
Summary
Key Points
Creating a document - Document created in couchDB database.
Creating document using futon - The process of creating a new database document.
Creating document using cURL utility - Created by passing a HTTP solicitation to the server using PUT techniques.