Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couchdb_utilities

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb_utilities - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7-prerelease

84

index.js

@@ -11,11 +11,67 @@ exports.printMsg = function() {

// server Utilities
exports.validateConnection = function ( couchURL ) {
var couchDBURL = couchURL;
Obj = this.returnObjfromURL(couchDBURL);
if ( Obj.responseCode == 200 ) {
return true;
} else {
return false;
}
};
exports.getServerVersion = function ( couchURL ) {
var couchDBURL = couchURL;
Obj = this.returnObjfromURL(couchDBURL);
if ( Obj.responseCode == 200 ) {
return JSON.parse( Obj.responseString).version;
} else {
return false;
}
};
exports.responseDuration = function ( couchURL ) {
var couchDBURL = couchURL;
Obj = this.returnObjfromURL(couchDBURL);
if ( Obj.responseCode == 200 ) {
return Obj.duration;
} else {
return false;
}
};
// database Utilities
exports.listDatabases = function ( couchURL ) {
var couchDBURL = couchURL + "/" + "_all_dbs";
Obj = this.returnObjfromURL(couchDBURL);
return JSON.parse ( Obj.responseString);
return JSON.parse( Obj.responseString);
};
exports.databaseExists = function ( couchURL, databaseName ) {
var couchDBURL = couchURL + "/" + databaseName;
Obj = this.returnObjfromURL(couchDBURL);
if ( Obj.responseCode == 404 ) {
return false;
} else {
return true;
}
};
exports.createDatabase = function ( couchURL, databaseName ) {
var couchDBURL = couchURL + "/" + databaseName;
Obj = this.callURL("PUT", couchDBURL, null );
if ( Obj.responseCode == 200 || Obj.responseCode == 201 ) {
return true;
} else {
return false;
}
};
// Internal Methods
exports.returnObjfromURL = function ( URL ) {

@@ -33,5 +89,5 @@

var responseString = response.getBody('utf8');
var responseString = response.body.toString('utf8');
returnObj.responseCode = response.getBody('utf8');
returnObj.responseCode = response.statusCode;
returnObj.responseString = responseString;

@@ -42,1 +98,23 @@

};
exports.callURL = function ( Method, URL, Payload ) {
var returnObj = {}
var syncRequest = require('sync-request');
var jsonPayload = { json: Payload };
returnObj.startTime = (new Date).getTime();
var response = syncRequest(Method, URL, jsonPayload );
returnObj.endTime = (new Date).getTime();
returnObj.duration = returnObj.endTime - returnObj.startTime;
returnObj.duration = returnObj.duration + " milliseconds"
var responseString = response.body.toString('utf8');
returnObj.responseCode = response.statusCode;
returnObj.responseString = responseString;
return returnObj;
};

2

package.json
{
"name": "couchdb_utilities",
"version": "v1.0.6",
"version": "v1.0.7prerelease",
"description": "This package will help you sync the design documents from one couchdb to another",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,21 +10,34 @@ # Module under development.

### Core
#### Verify Inputs
#### Validate connection - Source
#### Validate Connection - target
#### Get list of Dbs in the Source
### Server Utilities
#### Validate the input connection string
```
var Boolean = couchUtils.validateConnection ( "http://0.0.0.0:5984" ) );
```
#### Validate the input connection string
```
var String = couchUtils.getServerVersion ( "http://0.0.0.0:5984" ) );
```
#### Validate the input connection string
```
var String = couchUtils.responseDuration ( "http://0.0.0.0:5984" ) );
```
### Database Utilities
#### Get list of databases
```
console.log( couchUtils.listDatabases( "http://0.0.0.0:5984" ) );
[
"_replicator",
"_users",
"test2"
]
var Array = couchUtils.listDatabases( "http://0.0.0.0:5984" ) );
```
#### Check if a database exists in the target
```
var Boolean = couchUtils.databaseExists( "http://0.0.0.0:5984", "test" ) );
```
#### Create a database in target
```
var Boolean = couchUtils.createDatabase( "http://0.0.0.0:5984", "test" ) );
```
#### Check if the view exist
#### Check db in the target
#### Create db in target
### Design Docs

@@ -31,0 +44,0 @@ #### Create view

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc