
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
couchdb-tools
Advanced tools
A library of handy functions for use when working with CouchDB documents.
npm install coucbdb-tools --save
A library of handy functions for use when working with CouchDB documents. All functions are database adapter agnostic.
Some functions are unique to this library, others are just wrappers around some of the best packages for the job from the Node.JS community - and in which case thanks for your hard work :)
ddoc(obj[,name])
Build a JSON/CouchDB compatible design document from a native JavaScript object. The main utility of this function is to translate any map/reduce functions encountered in the design document into tidy JSON-safe strings.
The name
parameter is optional, and only required if you wish to create the design document's id too.
var tools = require('couchdb-tools');
var projects = {
views: {
projectsById: {
map: function (doc) {
if ( doc.type == "project") {
emit(doc._id,doc);
}
}
}
}
}
var projectsDesignDoc = tools.ddoc(projects,'projects');
console.log(projectsDesignDoc);
The following will be output to the console:
{
_id: '_design/projects',
views: {
projectsById: {
map: 'function(doc){if(doc.type=="project"){emit(doc._id,doc)}}'
}
}
}
normalise(collection)
Documentation to do.
sync(current,old)
Documentation to do.
clone(obj,obj[,obj...])
Documentation to do.
find(collection,id)
Documentation to do.
equal(a,b)
Documentation to do.
combine(a,b)
Create a new object that is the result of copying the properties of the second parameter into the first.
var tools = require('couchdb-tools');
var a = {foo:'bar',baz:'qux'};
var b = {foo:'quux',qux:'quuux'};
var combination = tools.combine(a,b);
console.log(combination);
The following will be output to the console:
{
foo: 'quux',
baz: 'qux',
qux: 'quuux'
}
shortid([seed])
Generate URI-safe, short, non-sequential unique ids. Optionally pass in a unique-for-your-app random number seed which will make your ids more secure. Passing the seed only needs to be done once at the start.
var tools = require('couchdb-tools');
tools.shortid(343983);
console.log(tools.shortid());
console.log(tools.shortid());
console.log(tools.shortid());
Similar contents to the following will be output to the console:
FG2Ws27qck
dGEEs27X15
oHeEydIXck
slug(text)
Converts a string into a URI-safe slug. Symbols are removed and foreign characters are coerced into their English equivalent.
var tools = require('couchdb-tools');
console.log(tools.slug('Hello $$$ world'));
The following will be output to the console:
hello-world
FAQs
A library of handy functions for use when working with CouchDB documents.
The npm package couchdb-tools receives a total of 3 weekly downloads. As such, couchdb-tools popularity was classified as not popular.
We found that couchdb-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.