
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
couchdb-simple
Advanced tools
I've been using this in my own production-level applications and it's worked quite wonderfully.
This takes care of revisions and annoyances in the background to help speed you up. But it doesn't abstract things too much. You're really just throwing around JS objects. Make sure you standardize your database code and your interfaces to make sure you aren't onion-skinning your data, nor losing records.
This works nicely with local CouchDB instances or a wonderful service called Cloudant that I love very much.
npm install couchdb-simple
For localhostin' your CouchDB server:
var couchdb = require("couchdb-simple");
var database = new couchdb();
For Cloudant, and other hosted solutions:
var couchdb = require("couchdb-simple");
var database = new couchdb(COUCHDB_HOSTNAME, COUCHDB_PORT, COUCHDB_USERNAME, COUCHDB_PASSWORD);
You can read a list of entries:
database.read('/dir/', function( results, error ) {
// Iterate on results.rows
});
or read a single entry:
database.read('/dir/entryid', function( results, error ) {
// Results are accessible in results object
});
Writing is easy, since you don't have to deal with revision information. At the same time, be careful not to wreck your existing data accidentally! Right now, I don't recommend writing without an entry ID, I think it's easier to handle those synchronously by declaring them before you write to the database.
var datastore = {};
database.write('/dir/entryid', datastore, function( results, error ) {
});
Just like writing, revision data is handled behind the scenes so you can delete an entry in a single step. I should have named the method delete
but I pushed this live too late :trollface:
database.remove('/dir/entryid', function( results, error ) {
});
There is an error object returned with every request that you can use to determine the success of the request:
if ( typeof error !== "undefined" && error ) {
// Something's amiss about database request, handle it.
} else {
// All's well!
}
This avoids try
-catch
patterns which really make cringe. I don't like things that supposed to run for a very long time to just break when something happens, so I find this method fairly graceful.
I use Cloudant for my Couchdb work, and it never really breaks so these are all over my code, but don't run that often. If interest is there, I can write in a HEAD method to check database availability.
FAQs
Simple Node.js Wrapper for CouchDB
The npm package couchdb-simple receives a total of 0 weekly downloads. As such, couchdb-simple popularity was classified as not popular.
We found that couchdb-simple 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 pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.