couchdb_utilities
Advanced tools
Comparing version 1.0.9-prerelease to 1.0.10-prerelease
49
index.js
@@ -69,2 +69,13 @@ exports.printMsg = function() { | ||
exports.deleteDatabase = function ( couchURL, databaseName ) { | ||
var couchDBURL = couchURL + "/" + databaseName; | ||
Obj = this.callURL("DELETE", couchDBURL, null ); | ||
if ( JSON.parse( Obj.responseString).ok == true ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
exports.getDatabaseDetails = function ( couchURL, databaseName ) { | ||
@@ -88,4 +99,38 @@ var couchDBURL = couchURL + "/" + databaseName; | ||
// Design Document Utilities | ||
exports.getDocumentbyID = function ( couchURL, databaseName, docID ) { | ||
var couchDBURL = couchURL + "/" + databaseName + "/" + docID; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
return JSON.parse(Obj.responseString); | ||
}; | ||
exports.createDocument = function ( couchURL, databaseName, document ) { | ||
var couchDBURL = couchURL + "/" + databaseName; | ||
var jsonPayload = { | ||
json: document | ||
}; | ||
Obj = this.callURL("POST", couchDBURL, document ); | ||
if ( JSON.parse( Obj.responseString).ok == true ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
exports.deleteDocument = function ( couchURL, databaseName, docID ) { | ||
var couchDBURL = couchURL + "/" + databaseName; | ||
// var document = this.getDocumentbyID( couchURL, databaseName, docID ); | ||
var rev = this.getDocumentbyID( couchURL, databaseName, docID )._rev; | ||
couchDBURL = couchURL + "/" + databaseName + "/" + docID + "?rev=" + rev; | ||
Obj = this.callURL("DELETE", couchDBURL, null ); | ||
if ( JSON.parse( Obj.responseString).ok == true ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
@@ -118,3 +163,5 @@ // Internal Methods | ||
var syncRequest = require('sync-request'); | ||
var jsonPayload = { json: Payload }; | ||
var jsonPayload = { | ||
json: JSON.parse( Payload ) | ||
}; | ||
@@ -121,0 +168,0 @@ returnObj.startTime = (new Date).getTime(); |
{ | ||
"name": "couchdb_utilities", | ||
"version": "v1.0.9prerelease", | ||
"description": "This package will help you sync the design documents from one couchdb to another", | ||
"version": "v1.0.10prerelease", | ||
"description": "This package contains utilties to use and support couchdb environments.", | ||
"main": "index.js", | ||
@@ -9,3 +9,8 @@ "scripts": { | ||
}, | ||
"author": "", | ||
"author": { | ||
"name": "Hari Vetsa" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hvetsa/couchdb_utilities" | ||
}, | ||
"license": "ISC", | ||
@@ -12,0 +17,0 @@ "dependencies": { |
@@ -13,11 +13,11 @@ # Module under development. | ||
``` | ||
var Boolean = couchUtils.validateConnection ( "http://0.0.0.0:5984" ) ); | ||
var Boolean = couchUtils.validateConnection ( couchURL ) ); | ||
``` | ||
#### Validate the input connection string | ||
``` | ||
var String = couchUtils.getServerVersion ( "http://0.0.0.0:5984" ) ); | ||
var String = couchUtils.getServerVersion ( couchURL ) ); | ||
``` | ||
#### Validate the input connection string | ||
``` | ||
var String = couchUtils.responseDuration ( "http://0.0.0.0:5984" ) ); | ||
var String = couchUtils.responseDuration ( couchURL ) ); | ||
``` | ||
@@ -28,15 +28,19 @@ | ||
``` | ||
var Array = couchUtils.listDatabases( "http://0.0.0.0:5984" ) ); | ||
var Array = couchUtils.listDatabases( couchURL ) ); | ||
``` | ||
#### Check if a database exists in the target | ||
``` | ||
var Boolean = couchUtils.databaseExists( "http://0.0.0.0:5984", "test" ) ); | ||
var Boolean = couchUtils.databaseExists( couchURL, "test" ) ); | ||
``` | ||
#### Create a database in target | ||
``` | ||
var Boolean = couchUtils.createDatabase( "http://0.0.0.0:5984", "test" ) ); | ||
var Boolean = couchUtils.createDatabase( couchURL, "test" ) ); | ||
``` | ||
#### Delete a database in target | ||
``` | ||
var Boolean = couchUtils.deleteDatabase( couchURL, "test" ) ); | ||
``` | ||
#### Obtain details of a database | ||
``` | ||
var Object = couchUtils.getDatabaseDetails( "http://0.0.0.0:5984", "test" ) ); | ||
var Object = couchUtils.getDatabaseDetails( couchURL, "test" ) ); | ||
``` | ||
@@ -46,11 +50,26 @@ | ||
``` | ||
var Array = couchUtils.getDesignDocuments = function ( couchURL, databaseName ) { | ||
var Array = couchUtils.getDesignDocuments ( couchURL, databaseName ) { | ||
``` | ||
### Document Utilities | ||
#### get a document by ID | ||
``` | ||
var Object = couchUtils.getDocumentbyID ( couchURL, databaseName, docID ) { | ||
``` | ||
#### create a Document | ||
``` | ||
var Boolean = couchUtils.createDocument( couchURL, databaseName, jsonString ) { | ||
``` | ||
#### delete a Document | ||
``` | ||
var Boolean = couchUtils.deleteDocument( couchURL, databaseName, docID ) { | ||
``` | ||
#### Check if the view exist | ||
### Design Docs | ||
#### Create view | ||
#### Get design Docs in a db | ||
#### Check Views in target | ||
#### Delete design docs in target db | ||
#### Create Design docs in target |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
7263
140
1
73