New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.22 to 1.0.23

91

agoge-pouchdb-plugins.js

@@ -64,2 +64,80 @@ var CryptoJS = require('crypto-js');

var listGlobalTypes = {
_id: "_design/gtypes" ,
views: {
gtypes: {
map: function(doc) {
if (doc.type) emit(doc.type);
}.toString()
, reduce: "_count"
}
}
};
exports.cleanDeletedTypes = async function() {
console.log('cleanDeletedTypes started');
await this.upsert(listGlobalTypes);
var gtypes = await this.query('gtypes', {
reduce: true
, group: true
});
var globalTypes = gtypes.rows.map(x=>x.key);
console.log('global-types: ' + JSON.stringify(globalTypes) + '\n');
var metas = await db.filter('meta').all();
var metaTypes = metas.map(x=>x.id);
console.log('meta-types: ' + JSON.stringify(metaTypes) + '\n');
for ( globalType of globalTypes ) {
if ( ! metaTypes.includes(globalType) && globalType != 'meta' ) {
var lista = await this.filter(globalType).all();
for ( item of lista ) {
item._deleted = true;
}
console.log('deleting ' + globalType + ' with ' + lista.length + ' docs');
while ( lista.length > 0 ) {
let agora = [];
for ( let i = 0; i < (lista.length > 1000 ? 1000 : lista.length); i++) {
agora.push(lista.shift());
}
await this.bulkDocs(agora);
}
console.log(globalType + ' done' + '\n');
}
}
console.log('cleanDeletedTypes done' + '\n');
}
exports.buildMangoIndex = async function(name) {
var o = {type: 'meta' };
if ( name ) o[name] = 0;
while (true) {
try {
await this.find({selector: o});
console.log(name + ' index build successfully');
break;
} catch(err) {
console.log('couchdb is busy right now, delaying index building of: ' + name);
await new Promise((resolve, reject)=>{setTimeout(resolve, 1000*60*10*Math.random())});
}
}
}
exports.createMangoTypeIndex = async function() {

@@ -74,5 +152,4 @@ var data = await db.createIndex({

});
this.find({selector: {type: 'meta'}});
this.buildMangoIndex();
console.log("MANGO 'type' INDEX: " + JSON.stringify(data.result));

@@ -90,7 +167,5 @@ }

});
var o = {type: 'meta' };
o[name] = 0;
this.find({selector: o});
this.buildMangoIndex(name);
console.log("MANGO '" + name + "' INDEX: " + JSON.stringify(data.result));

@@ -113,3 +188,3 @@ }

}
console.log('db.init done');

@@ -116,0 +191,0 @@ }

2

package.json
{
"name": "agoge-pouchdb-plugins",
"version": "1.0.22",
"version": "1.0.23",
"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