' declaration
Public cdb2 As couchdb2
' initialization
cdb2.Initialize("127.0.0.1",5984,"admin","admin")
' get all databases
Wait For (cdb2.send_request("GET",cdb2.urlhead2 & "_all_dbs","","")) Complete (Result_alldbs As String)
Dim strres As String = Result_alldbs
'create new database
Wait For (cdb2.send_request("PUT",cdb2.urlhead2 & tfnewdb.text,"","")) Complete (Result_create As String)
' delete database
Wait For (cdb2.send_request("DELETE",cdb2.urlhead2 & dbname, "","")) Complete (Result_delete As String)
' get all documents
Wait For (cdb2.send_request("GET",cdb2.urlhead2 & dbname & "/_all_docs?include_docs=true","","")) Complete (Result_all_docs As String)
Dim strres As String = Result_all_docs
' get document
Wait For (cdb2.send_request("GET",cdb2.urlhead2 & dbname & "/" & id,"","")) Complete (Result_get_document As String)
Dim strres As String = Result_get_document
' add new document
Wait For (cdb2.send_request("PUT",cdb2.urlhead2 & dbname & "/" & id & "/","",strdata)) Complete (Result_add_document As String)
' update an existing document
Wait For (cdb2.send_request("PUT",cdb2.urlhead2 & dbname & "/" & id & "/?rev=" & lblrev.text,"",strdata)) Complete (Result_update_document As String)
' delete a document
Wait For (cdb2.send_request("DELETE",cdb2.urlhead2 & lbldb.text & "/" & lbldoc.text & "/?rev=" & lblrev.text, "","")) Complete (Result_delete_document As String)
'add an image attachment
Wait For (cdb2.send_request("PUT",cdb2.urlhead2 & lbldb.text & "/" & lbldoc.text & _
"/" & filename & "?rev=" & lblrev.text,"image/jpg","")) Complete (Result_add_image_attachment As String)