agoge-pouchdb-plugins
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -33,3 +33,3 @@ var CryptoJS = require('crypto-js'); | ||
emit([type]); | ||
if ( isNaN(id) ) { | ||
@@ -40,3 +40,3 @@ emit([type, id]); | ||
} | ||
for (key in doc) { | ||
@@ -50,5 +50,5 @@ emit([type, key, doc[key]]); | ||
exports.identity = async function(type) { | ||
exports.identity = async function(type) { | ||
await db.upsert(identityMapReduce); | ||
var ret = await this.query('identity/identity', {key: type, group: true}); | ||
@@ -89,3 +89,3 @@ | ||
options["include_docs"] = true; | ||
options["limit"] = 1; | ||
@@ -110,3 +110,3 @@ | ||
include_docs: include_docs || true | ||
}; | ||
}; | ||
@@ -116,23 +116,40 @@ if (type) options.key.push(type); | ||
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) { | ||
exports.filter = 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.tolist('where', 'where', options); | ||
var plugin = this; | ||
return new function() { | ||
this.take = async function(n, m) { | ||
await plugin.upsert(whereMapReduce); | ||
if ( n ) { | ||
options.limit = n; | ||
} | ||
if ( m ) { | ||
options.start_key = m; | ||
} | ||
return await plugin.tolist('where', 'where', options); | ||
} | ||
this.all = this.take; | ||
} | ||
} | ||
exports.upsert = async function(doc) { | ||
@@ -180,7 +197,7 @@ module.upserted = module.upserted || []; | ||
exports.save = async function(doc) { | ||
var parts = doc._id.split('-'); | ||
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); | ||
@@ -197,11 +214,11 @@ | ||
try { | ||
var old = await db.get(doc._id); | ||
} catch (err) { | ||
var old = { _attachments: {} }; | ||
var old = { _attachments: {} }; | ||
} | ||
doc._attachments = old._attachments || {}; | ||
doc._attachments = old._attachments || {}; | ||
var an = 'revisions/' + docRevNo + '.json'; | ||
@@ -208,0 +225,0 @@ |
{ | ||
"name": "agoge-pouchdb-plugins", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "My personal plugin functions to pouchdb-couchdb", | ||
@@ -5,0 +5,0 @@ "main": "agoge-pouchdb-plugins.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5664
185