Twist Utility
Twist utility is an approach to speak with CouchDB.
It is an apparatus to move information from or to a worker, utilizing one of the upheld conventions (HTTP, HTTPS, FTP, FTPS, TFTP, DICT, TELNET, LDAP or FILE). The order is intended to work without client communication. Twist offers a busload of helpful stunts like intermediary uphold, client verification, ftp transfer, HTTP post, SSL (https:) associations, treats, document move resume and that's just the beginning.
The cURL utility is accessible in working frameworks, for example, UNIX, Linux, Mac OS X and Windows. It is an order line utility utilizing which client can get to HTTP convention straight away from the order line. This section shows you how to utilize cURL utility.
Utilizing cURL Utility
You can get to any site utilizing cURL utility by just composing cURL followed by the site address as demonstrated beneath −
curl www.tutorialspoint.com/
Of course, the cURL utility returns the source code of the mentioned page. It shows this code on the terminal window.
Twist Utility Options
Twist utility furnishes different choices to work with, and you can see them in cURL utility assistance.
The accompanying code shows some bit of cURL help.
$ curl --help
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
--anyauth Pick "any" authentication method (H)
-a/--append Append to target file when uploading (F/SFTP)
--basic Use HTTP Basic Authentication (H)
--cacert <file> CA certificate to verify peer against (SSL)
-d/--data <data> HTTP POST data (H)
--data-ascii <data> HTTP POST ASCII data (H)
--data-binary <data> HTTP POST binary data (H)
--data-urlencode <name=data/name@filename> HTTP POST data
urlencoded (H)
--delegation STRING GSS-API delegation permission
--digest Use HTTP Digest Authentication (H)
--disable-eprt Inhibit using EPRT or LPRT (F)
--disable-epsv Inhibit using EPSV (F)
-F/--form <name=content> Specify HTTP multipart POST data (H)
--form-string <name=string> Specify HTTP multipart POST data (H)
--ftp-account <data> Account data to send when requested by server
(F)
--ftp-alternative-to-user <cmd> String to replace "USER [name]" (F)
--ftp-create-dirs Create the remote dirs if not present (F)
--ftp-method [multi cwd/no cwd/single cwd] Control CWD usage (F)
--ftp-pasv Use PASV/EPSV instead of PORT (F)
-G/--get Send the -d data with a HTTP GET (H)
-H/--header <line> Custom header to pass to server (H)
-I/--head Show document info only
-h/--help This help text
--hostpubmd5 <md5> Hex encoded MD5 string of the host public key.
(SSH)
-0/--http1.0 Use HTTP 1.0 (H)
--ignore-content-length Ignore the HTTP Content-Length header
-i/--include Include protocol headers in the output (H/F)
-M/--manual Display the full manual
-o/--output <file> Write output to <file> instead of stdout
--pass <pass> Pass phrase for the private key (SSL/SSH)
--post301 Do not switch to GET after following a 301
redirect (H)
--post302 Do not switch to GET after following a 302
redirect (H)
-O/--remote-name Write output to a file named as the remote file
--remote-name-all Use the remote file name for all URLs
-R/--remote-time Set the remote file's time on the local output
-X/--request <command> Specify request command to use
--retry <num> Retry request <num> times if transient problems
occur
--retry-delay <seconds> When retrying, wait this many seconds
between each
--retry-max-time <seconds> Retry only within this period
-T/--upload-file <file> Transfer <file> to remote site
--url <URL> Set URL to work with
-B/--use-ascii Use ASCII/text transfer
While speaking with CouchDB, certain alternatives of cURL utility were broadly utilized. Following are the concise portrayals of some significant alternatives of cURL utility including those utilized by CouchDB.
- X banner
(HTTP) Specifies a custom solicitation strategy utilized when speaking with the HTTP worker. The predetermined solicitation is utilized rather than the technique in any case utilized (which defaults to GET). Peruse the HTTP 1.1 determination for subtleties and clarifications.
(FTP) Specifies a custom FTP order to use rather than LIST when doing document records with ftp.
- H
(HTTP) Extra header is utilized while getting a site page. Note that on the off chance that you add a custom header that has similar name as one of the inside ones cURL would utilize, your remotely set header will be utilized rather than the inner one. This permits you to make much trickier work than cURL would ordinarily do. You ought not supplant inside set headers without totally understanding what you're doing. Supplanting an inner header with the one without content on the correct side of the colon, will keep that header from showing up.
Twist guarantees that every header you add/supplant get sent with the appropriate finish of line marker. Neither one of the you should add that as a piece of the header content nor add newlines or carriage re-visitations of turmoil things.
See likewise the - A/ - client specialist and - e/ - referer alternatives.
This alternative can be utilized on different occasions to add/supplant/eliminate various headers.
- d banner
Utilizing this banner of cURL, you can send information alongside the HTTP POST solicitation to the worker, as though it was filled by the client in the structure and submitted.
Model
Assume there is a site and you need to login into it or send some information to the site utilizing – d banner of cURL utility as demonstrated underneath.
curl -X PUT http://mywebsite.com/login.html -d userid=001 -d password=tutorialspoint
It sends a post piece that resembles "userid=001&password=tutorialspoint". In like manner you can likewise send records (JSON ) utilizing - d banner.
- o banner
Utilizing this banner, cURL composes the yield of the solicitation to a document.
Model
The accompanying model shows the utilization of - o banner of cURL utility.
$ curl -o example.html www.tutorialspoint.com/index.htm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 81193 0 81193 0 0 48168 0 --:--:-- 0:00:01 --:--:--
58077
This gets the source code of the landing page of tutorialspoint.com, makes a document named example.com and saves the yield in the record named example.html.
Following is the preview of the example.html.
- O
This banner is like – o, the solitary distinction is with this banner, another document with a similar name as the mentioned url was made, and the source code of the mentioned url will be duplicated to it.
Model
The accompanying model shows the utilization of - O banner of cURL utility.
$ curl -O www.tutorialspoint.com/index.htm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left
Speed
100 81285 0 81285 0 0 49794 0 --:--:-- 0:00:01 --:--:--
60077
It makes another document with the name index.htm and saves the source code of the file page of tutorialspoint.com in it.
Hi CouchDB
You can get to the landing page of the CouchDB by sending a GET solicitation to the CouchDB occasion introduced. Most importantly ensure you have introduced CouchDB in your Linux climate and it is running effectively, and afterward utilize the accompanying punctuation to send a get solicitation to the CouchDB occurrence.
curl http://127.0.0.1:5984/
This gives you a JSON report as demonstrated beneath where CouchDB indicates the subtleties, for example, variant number, name of the merchant, and adaptation of the product.
$ curl http://127.0.0.1:5984/
{
"couchdb" : "Welcome",
"uuid" : "8f0d59acd0e179f5e9f0075fa1f5e804",
"version" : "1.6.1",
"vendor" : {
"name":"The Apache Software Foundation",
"version":"1.6.1"
}
}
Rundown, all things considered,
You can get the rundown of the multitude of information bases made, by sending a get demand alongside the string "_all_dbs string ". Following is the punctuation to get the rundown of all information bases in CouchDB.
curl -X GET http://127.0.0.1:5984/_all_dbs
It gives you the rundown of all information bases in CouchDB as demonstrated beneath.
$ curl -X GET http://127.0.0.1:5984/_all_dbs
[ "_replicator" , "_users" ]
Making a Database
You can make a data set in CouchDB utilizing cURL with PUT header utilizing the accompanying grammar −
$ curl -X PUT http://127.0.0.1:5984/database_name
Model
For instance, utilizing the above given linguistic structure make an information base with name my_database as demonstrated underneath.
$ curl -X PUT http://127.0.0.1:5984/my_database
{"ok":true}
Confirmation
Confirm whether the information base is made, by drilling down all the data sets as demonstrated underneath. Here you can notice the name of recently made data set, "my_database" in the rundown
$ curl -X GET http://127.0.0.1:5984/_all_dbs
[ "_replicator " , "_users" , "my_database" ]
Getting Database Info
You can get the data about data set utilizing the get demand alongside the data set name. Following is the language structure to get the data set data.
Model
As an illustration let us get the data of the data set named my_database as demonstrated underneath. Here you can get the data about your information base as a reaction.
$ curl -X GET http://127.0.0.1:5984/my_database
{
"db_name" : "my_database",
"doc_count" : 0,
"doc_del_count" : 0,
"update_seq" : 0,
"purge_seq" : 0,
"compact_running" : false,
"disk_size" : 79,
"data_size" : 0,
"instance_start_time" : "1423628520835029",
"disk_format_version" : 6,
"committed_update_seq" : 0
}
Futon
Futon is the implicit, online, organization interface of CouchDB. It gives a basic graphical interface utilizing which you can connect with CouchDB. It is an innocent interface and it gives full admittance to all CouchDB highlights. Following is the rundown of those highlights −
Information bases −
- Makes information bases.
- Devastates data sets.
Reports −
- Makes reports.
- Updates reports.
- Alters reports.
- Erases reports.
Beginning Futon
Ensure CouchDB is running and afterward open the accompanying url in program −
http://127.0.0.1:5984/_utils/
In the event that you open this url, it shows the Futon landing page as demonstrated beneath −
On the left hand side of this page you can notice the rundown of the relative multitude of current data sets of CouchDB. In this delineation, we have an information base named my_database, alongside framework characterized data sets _replicator and _user.
On the correct hand side you can see the accompanying −
- Apparatuses − In this segment you can discover Configuration to design CouchDB, Replicator to perform replications, and Status to confirm status of CouchDB and ongoing changes done on CouchDB.
- Documentation − This part contains the total documentation for the new form of CouchDB.
- Diagnostics − Under this you can check the establishment of CouchDB.
- Ongoing Databases − Under this you can discover the names of as of late added information bases.
