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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodejs-microdb

v0.0.2

Published

A Micro-sized key/document database - very simple. Auto-flush to disk and in-memory options

Downloads

63

Readme

MicroDB

Purpose

nodejs-microdb is a tiny in-process database. It has very few methods, but does feature auto-flushing to disk (for file based stores). It can also be used in a memory-only mode.

TOC

Usage

var microdb = require('nodejs-microdb');
var myDB = new microdb({'file':'somefile.db'});

Options

When making a new database, you have some choices:

var myDB = new microdb({
  'file': '',     // The filename to save to, or empty for memory only

  'savetime': 10, // In minutes, how often to flush to disk (approx)
                  // Set this to 0 to diable auto-save.

  'datatype': 0,  // Which data-type:
                  //  0 = Array-based, no keys. (useful for storing lists to disk)
                  //  1 = Object-based, with keys. (what most key/doc's do)
               
  'maxrec': 10,   // Maximum number of records (for datatype === 0 ONLY)

  'flushonexit': true,   // Auto-flush when program quits.
                         // I recommend you leave this on.

  'defalutClean': false, // Auto-remove incomplete records on sort opertaions.
                         // This is useful if your document type isn't consistent.
                         // It can also be turned on per-query.
});

API

Datatype === 1 Methods:

####MicroData.add(data, [ident]); Add an item to the store. If "ident" is not supplied, it will be created.
Return value is the "ident".

####MicroData.del(ident); Remove a named "ident" from the store.

####MicroData.find(key, value); Find a record "ident" by a named key/value pair. Returns first match, search order is arbitrary.

####MicroData.findAll(key, value); Return an array of record "ident"'s where key === value. Order is arbitrary.

####MicroData.findAllWithKey(key); Return an array of record "ident"'s the contain 'key'. Order is arbitrary.

####MicroData.sortByKey(key, [direction], [alpha], [cleanBad]); Returns an array of values and "ident"'s, sorted in "direction" (asc/desc). Set "alpha" to true for alphanumeric sort. If 'cleanBad' is true, results with one or more 'undefined' values for the specified keys will not be returned. NOTE: This is just a convience method to the below...

####MicroData.sortByKeys(sorts, [cleanBad]); Returns an array of values and "idents"'s sorted by "sorts" array - where sorts is an array of [key, direction, alpha] arrays. (see above). If 'cleanBad' is true, results with one or more 'undefined' values for the specified keys will not be returned.

Datatype === 0 Methods:

MicroData.add(data);

Add an item to the list.

MicroData.del(num);

Remove item number 'num' from list. 0-based.

Shared Methods:

####MicroData.load(); Load file from disk. Usually called automatically, but if you are before options.savetime, it might work as an undo.

####MicroData.save(); Save file to disk. This is an anonomized asych method (no callback, it'll do it eventually. Used internally, I don't recommend it)

####MicroData.flush(); Save file to disk now. Synch method. If you think you need to flush the db yourself, chances are this is the method you want.

Current status

This module is in a development stage. It is broken horribly in places. There are quite a few features missing. And it has zero room for error - this will always be intended for internal persistent storage, not a real replacement for what you should use a real database for.

Contributors

Compatibility

This module was only tested using node >= 0.8.8. There is no reason it shouldn't run under earlier versions though.

Licence

node-ansibuffer is licensed under the MIT license. Or the BSD license. Or no license if that's more convient for you.