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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@popovmp/dbiler

v1.0.0

Published

DBil http client

Downloads

3

Readme

DBil

DBiler is a http client to DBil.

Installation

npm install @popovmp/dbiler

Usage

const {getDbiler} = require('@popovmp/dbiler')

const url    = 'http://example.com/api/dbil'
const secret = 'foo-bar'

const userDb = getDbiler(url, secret, 'user')

const query      = {email: '[email protected]'}
const projection = {name: 1, email: 1, _id: 0}

userDb.findOne(query, projection, (user) => {
	if (user) // Object or undefined
		console.log(`User name: ${user.name}, email: ${user.email}`)
	else
		console.log('Cannot find such a user!')
})

API

DBiler connects to a DBil client by url, secret, and DB name.

const dbiler = getDbiler(url, secret, dbName)

The dbiler object provides the same method as DBil plus a callback. The callback accepts a parameter corresponding to the DBil native return value.

For example DBil's count returns count of object, but DBiler's count accepts a callback, which accepts a parameter count.

// DBil
const dbil  = dbil.getDb(user)
const count = dbil.count({foo: 42})

// DBiler
const dbiler = dbiler.getDbiler(url, secret, user)
dbiler.count({foo: 42}, (count) => {
})

Inserting documents

A document is of type Object.

const doc     = {...}
const options = {skipSave: false}
dbiler.insert(doc, options, (id) => {
	console.log(typeof id) // string or undefined
})

Finding documents

Use find or findOne to look for one or multiple documents matching you query.

  • find returns an array of documents. If no matches, it returns an empty array.
  • findOne returns the first found document or undefined.
dbiler.find(query, projection, (docs) => {
	console.log( Array.isArray(docs) ) // => true
})

dbiler.findOne(query, projection, (doc) => {
	console.log(typeof doc) // => Object or undefined
})

Counting documents

You can use count to count documents. It accepts the same query as find.

dbiler.count(query, (count) => {
	console.log(typeof count) // => number
})

Updating documents

update returns the id of the inserted doc or undefined:

dbiler.update(query, update, options, (id) => {
	console.log(typeof id) // => string or undefined
})

Removing documents

dbiler.remove(query, options, (numRemoved) => {
	console.log(typeof numRemoved) // => number
})

Saving DB

Yuo can force the DB save with the save method. It is useful only if the previous insert, update, or remove were sent with option {skipSave: true}

dbiler.save((isSaved) => {
	console.log(typeof isSaved) // => boolean
})