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

agoge-pouchdb-plugins

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agoge-pouchdb-plugins - npm Package Compare versions

Comparing version 1.0.18 to 1.0.19

95

agoge-pouchdb-plugins.js

@@ -164,11 +164,13 @@ var CryptoJS = require('crypto-js');

exports.upsert = async function(doc) {
module.upserted = module.upserted || [];
exports.upsert = async function(doc, byPassSingleton = false) {
module.upserted = module.upserte || [];
var docHash = CryptoJS.MD5(JSON.stringify(doc)).toString();
if ( ! byPassSingleton ) {
var docHash = CryptoJS.MD5(JSON.stringify(doc)).toString();
if (module.upserted.includes(docHash))
return doc;
if (module.upserted.includes(docHash))
return doc;
module.upserted.push(docHash);
module.upserted.push(docHash);
}

@@ -207,23 +209,4 @@ try {

exports.save = async function(doc) {
var parts = doc._id.split('-');
doc.type = parts[0];
doc.id = Number(parts[1]) || parts[1];
doc.modified = new Date();
var currentVersionJson = JSON.stringify(doc, null, 4);
if ( ! doc._rev ) {
var docRevNo = 0;
var docRevGuid = 0;
} else {
var docRevisionParts = doc._rev.split('-');
var docRevNo = docRevisionParts[0];
var docRevGuid = docRevisionParts[1];
}
var o = JSON.parse(JSON.stringify(doc));
o._id = o._id.replace('-', '@') + '.' + (Number(docRevNo)+1);
delete o._rev;
await db.put(o);
var doc = await this.standardizeDoc(doc);
var rev = await this.storeRevision(doc);
var ret = await this.put(doc);

@@ -240,3 +223,3 @@ return ret;

result.rows.forEach(function(row) {
for ( row of result.rows ) {
var x = row.doc;

@@ -250,5 +233,8 @@

if (before != after)
if (before != after) {
await this.standardizeDoc(x);
await this.storeRevision(x);
mods.push(x);
});
}
}

@@ -259,1 +245,50 @@ //console.log('Atualizando ' + mods.length + ' documentos');

exports.standardizeDoc = async function(doc) {
var parts = doc._id.split('-');
doc.type = parts[0];
doc.id = Number(parts[1]) || parts[1];
doc.modified = new Date();
try {
var meta = await this.get('meta-' + doc.type);
var descKey;
for (key in meta) {
if ( meta[key].type == "description" ) {
var descKey = key;
break;
}
}
if ( descKey )
doc.desc = doc[descKey];
else
doc.desc = doc.type.toUpperCase() + ': ' + doc.id;
} catch(err) {
doc.desc = doc.type.toLowerCase() + ': ' + doc.id;
}
return doc;
}
exports.storeRevision = async function(doc) {
var currentVersionJson = JSON.stringify(doc, null, 4);
if ( ! doc._rev ) {
var docRevNo = 0;
var docRevGuid = 0;
} else {
var docRevisionParts = doc._rev.split('-');
var docRevNo = docRevisionParts[0];
var docRevGuid = docRevisionParts[1];
}
var o = JSON.parse(JSON.stringify(doc));
o._id = o._id.replace('-', '@') + '.' + (Number(docRevNo)+1);
delete o._rev;
var ret = await db.upsert(o);
return ret;
}
{
"name": "agoge-pouchdb-plugins",
"version": "1.0.18",
"version": "1.0.19",
"description": "My personal plugin functions to pouchdb-couchdb",

@@ -5,0 +5,0 @@ "main": "agoge-pouchdb-plugins.js",

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