New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sol-x/couchdb-migration-store

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sol-x/couchdb-migration-store - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

README.md

58

dist/index.js

@@ -15,3 +15,4 @@ "use strict";

}
this.couchDbWaitTime = parseInt(process.env.COUCHDB_WAIT_TIME || "0") || 10 * 1000;
this.couchDbWaitTime =
parseInt(process.env.COUCHDB_WAIT_TIME || "0") || 10 * 1000;
this.couchDbUrl = couchDbUrl;

@@ -24,6 +25,20 @@ }

});
const nano = nano_1.default(this.couchDbUrl);
const allDbs = await nano.db.list();
if (!allDbs.includes(MIGRATION_DB_NAME)) {
await nano.db.create(MIGRATION_DB_NAME);
}
return nano.use(MIGRATION_DB_NAME);
}
async getMigrationDocument(db, docId) {
try {
return await db.get(docId, { revs_info: true });
}
catch (e) {
return;
}
}
async save(migrationData, callback) {
const { lastRun } = migrationData;
const migrations = migrationData.migrations.map(migration => ({
const migrations = migrationData.migrations.map((migration) => ({
title: migration.title,

@@ -34,23 +49,14 @@ timestamp: migration.timestamp,

try {
await this.waitForCouchdb();
}
catch (err) {
callback(err);
return;
}
const nano = nano_1.default(this.couchDbUrl);
try {
await nano.db.destroy(MIGRATION_DB_NAME);
}
catch (_a) {
}
finally {
await nano.db.create(MIGRATION_DB_NAME);
}
try {
const db = nano.use(MIGRATION_DB_NAME);
await db.insert(dataToStore);
const db = await this.waitForCouchdb();
const dataInStore = await this.getMigrationDocument(db, "1");
if (dataInStore && dataInStore._rev) {
await db.insert({ ...dataToStore, _rev: dataInStore._rev });
}
else {
await db.insert(dataToStore);
}
callback(undefined);
}
catch (e) {
console.error(`Encounter error when running migration ${lastRun}`);
callback(e);

@@ -61,11 +67,3 @@ }

try {
await this.waitForCouchdb();
}
catch (err) {
callback(err);
return;
}
const nano = nano_1.default(this.couchDbUrl);
try {
const db = nano.use(MIGRATION_DB_NAME);
const db = await this.waitForCouchdb();
const data = await db.find({ limit: 1, selector: {} });

@@ -81,3 +79,3 @@ const { docs } = data;

catch (e) {
callback(undefined, {});
callback(e, {});
}

@@ -84,0 +82,0 @@ }

{
"name": "@sol-x/couchdb-migration-store",
"version": "1.0.2",
"version": "1.1.0",
"description": "couchdb migration store for node-migrate",
"main": "dist/index.js",
"files": [
"dist/**/*"
],
"scripts": {

@@ -27,3 +30,3 @@ "build": "tsc",

"dependencies": {
"nano": "git://github.com/sol-x/couchdb-nano.git#8.1.3",
"nano": "^8.2.3",
"wait-on": "^3.3.0"

@@ -30,0 +33,0 @@ },

Sorry, the diff of this file is not supported yet

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