npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sphinxkatze/dbutils

v0.0.1

Published

A library for an universal database api

Readme

dbutils

Can databases be used without care of the type?

It certainly is with this library, which combines databases with the own easy to understand api without the database type to matter.

Supported types of databases:

  • dev (temporary development database)
  • mongodb

Do you think, an important type of database is missing, or you want to add your code to support a database type? Make an Issue or Pull Request!

Usage

Pretty simple. First create the database objects; then use the following different operations:

Below is an Example:

//Prepare & connect to database
const db = require('dbutils')(*type*, [*useDev*, *devStoragePath*]);
await db.connect('testUser', '123', 'example.com', 1234, 'veryImportantMicroservice');

//Change settings for database
db.controller.setPath("/tmp/application/.devDB")
db.controller.changeApplication("anotherImportantData");

//Write data
const subsetOfData = db.access('testdata');
const firstEntry = db.access(subsetOfData, 'foo');
await db.newEntry(firstEntry, 'foo', 'bar', {expiration: {enabled: true, min: 10}});

//Read data
const value = await db.read(firstEntry, 'foo');
console.log(value);

//Close connection
db.close();

Documentation

connect(user, pw, domain, port, [application])

This method allows the initial connection establishment to the database. The method will return true on successful connection establishment.

The optional parameter 'application' can be used to define sub-databases in an application. An example usage could be separated sub-databases for different microservices

access(database/[key, value], [forceExisting])

This method is used to access:

  • a sub-database (already defined sub-databases in 'connect()', would create sub-databases in sub-database; useful for splitting of different types of data)
  • a data pair, defined by a key and a value, so you can modify or read it using later methods

Notice: using the second use case, by default it will create a new entry, if previous entries, matching the data pair, does not exist

newEntry(obj, key, value, [options])

Using await can be useful, if you depend on the data being written for the logic below

This method is used to write a new or update an existing data pair, defined by a key and a value, to the database object.

Option valid properties are currently:

  • expiration.enabled: Which enables the TTL based removal of documents. expiration.hours & expiration.min can be used to define the time from now until the event
  • found - whether it found any matching data
  • success - whether it was successful
  • error - message containing the error
  • createdNew - whether a new pair was created

Notice: you can only write to objects, once an object was selected using 'access()' above.

read(obj, key)

Using await can be useful, if you depend on the data being read for the logic below

This method is used to read an existing data pair, searched by the key from the database object.

Notice: you can only read from objects, once an object was selected using 'access()' above.

custom(instruction)

!!Warning: Using this kind of function, without knowing that you are doing, can lead to unsafe programs

This method can be used, if you need something more complex or more logic, without being easily reproducible by the functions above.

Note that this function heavily depends on the database type and isn't universal, if even supported.

An 'instruction' will be transferred to the database to be executed; can be unsupported.

Unsupported databases will throw an error object.

  • obj - internal obj for full control
  • value - returned value after instruction completion
  • error - if database does not support it

close()

This method is used to disconnect from the current database; in case you want to connect to a different database.