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.12 to 1.0.13

119

agoge-pouchdb-plugins.js
var CryptoJS = require('crypto-js');
exports.identity = async function(type) {
await db.upsert({
_id: "_design/identity",
views: {
identity: {
map: function (doc) {
var p = doc._id.indexOf('-');
if ( p < 0 ) return;
var type = doc._id.slice(0, p);
var id = Number(doc._id.slice(p+1, doc._id.length));
var identityMapReduce = {
_id: "_design/identity",
views: {
identity: {
map: function (doc) {
var p = doc._id.indexOf('-');
if ( p < 0 ) return;
var type = doc._id.slice(0, p);
var id = Number(doc._id.slice(p+1, doc._id.length));
emit(type, id);
}.toString(),
reduce: function (keys, values, rereduce) {
return values.sort(function(a,b) {return a-b}).reverse()[0];
}.toString()
}
emit(type, id);
}.toString(),
reduce: function (keys, values, rereduce) {
return values.sort(function(a,b) {return a-b}).reverse()[0];
}.toString()
}
});
}
}
var whereMapReduce = {
_id: "_design/where" ,
views: {
where: {
map: function(doc) {
var p = doc._id.indexOf('-');
if ( p < 0 ) return;
var type = doc._id.slice(0, p);
var id = doc._id.slice(p+1, doc._id.length);
emit([type]);
if ( isNaN(id) ) {
emit([type, id]);
} else {
emit([type, Number(id)]);
}
for (key in doc) {
emit([type, key, doc[key]]);
}
}.toString()
}
}
};
exports.identity = async function(type) {
await db.upsert(identityMapReduce);

@@ -74,11 +102,23 @@ var ret = await this.query('identity/identity', {key: type, group: true});

exports.find = async function(type, key, value, all, include_docs) {
var all = all || false;
exports.find = async function(type, key, value, include_docs) {
var options = {
key: [],
include_docs: include_docs || true
};
if (type) options.key.push(type);
if (key) options.key.push(key);
if (value) options.key.push(value);
await this.upsert(whereMapReduce);
return await this.scalar('where', 'where', options);
}
exports.filter = async function(type, key, value, include_docs) {
var options = {
key: []
key: [],
include_docs: include_docs || true
};
options.include_docs = include_docs;
if (type) options.key.push(type);

@@ -88,35 +128,5 @@ if (key) options.key.push(key);

await this.upsert({
_id: "_design/find" ,
views: {
find: {
map: function(doc) {
var p = doc._id.indexOf('-');
if ( p < 0 ) return;
var type = doc._id.slice(0, p);
var id = doc._id.slice(p+1, doc._id.length);
emit([type]);
if ( isNaN(id) ) {
emit([type, id]);
} else {
emit([type, Number(id)]);
}
var key;
for (key in doc) {
emit([type, key, doc[key]]);
}
}.toString()
}
}
});
if (all)
return await this.tolist('find', 'find', options);
else
return await this.scalar('find', 'find', options);
await this.upsert(whereMapReduce);
return await this.tolist('where', 'where', options);
}

@@ -225,2 +235,1 @@

};
{
"name": "agoge-pouchdb-plugins",
"version": "1.0.12",
"version": "1.0.13",
"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