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

@allnulled/simplest-db

v1.0.3

Published

Small synchronous database implementation for node.js and browsers

Downloads

4

Readme

simplest-db

Small synchronous database implementation for node.js and browsers.

NPM

1. Installation

~$ npm i -s @allnulled/simplest-db

2. How it works

This script works the same for node.js and browser.

What the script is thought for, is to be used as synchronous database for both javascript environments.

On the node.js side, it works with files and the require("fs") API.

On the browser side, it works with localStorage API.

3. Usage

3.1. Install:

In node.js you rely on require function and the node_modules of the npm.

In browser you need to import simplest-db.js by a script tag like:

<script src="/path/to/some/cdn/network/and/find/simplest-db.js"></script>

If case you use webpack or browserify or some tool to pack your browser scripts, you can use import and require syntax too with "simplest-db" parameter.

3.2. Import:

In node.js:

const SimplestDB = global.SimplestDB || require("@allnulled/simplest-db");

In browser:

const SimplestDB = window.SimplestDB;

Note: the import syntax of ES6 will also work.

3.3. Create database:

const db = SimplestDB.create({
    schema: "Unique schema id",
    attributes: { /* custom schema attributes */ },
    tables: {
        fichero: {
            attributes: { /* custom table attributes */ }.
            columns: {
                ruta: {
                    attributes: { /* custom column attributes */ },
                    is_type: "string",
                }
            }
        }
    }
});

3.4. Insert into database:

db.insert("fichero", {
    ruta: "/root/index.js",
    contenido: "console.log('hi!!!')"
});

3.5. Select from database:

db.select("fichero", f => {
    return f.ruta && f.ruta.startsWith("/root/");
});

3.6. Update from database:

db.update("fichero", 1, {
    contenido: "console.log('bye!')"
});

3.7. Delete from database:

db.delete("fichero", 1);

4. Features

Some enjoyable features:

  • Fully synchronous API.
  • Browser (localStorage) and node.js (require("fs")) support.

Some missing features:

  • NO support for automatic column checkings, only for table checking. To do so, override validateRow method.

4.1. Extra features

Since version 1.0.3, @allnulled/simplest-db comes with 2 extra APIs: Cache API and Filesystem API.

The Filesystem API:

  • Included API for files at: SimplestDB.getFS().
    • Contains a SimplestDB instance with "system" as schema (so: ./sdb_modules/system.data.json or localStorage.SDB_STORAGE_FOR_system).
    • Accepts tables: fs.
    • Accepts columns: fs.path, fs.contents, fs.metadata.

The Cache API:

  • Included API for cache at: SimplestDB.getCache().
    • Contains a SimplestDB instance with "system" as schema too (so also: ./sdb_modules/system.data.json or localStorage.SDB_STORAGE_FOR_system).
    • Accepts tables: cache.
    • Accepts columns: cache.key, cache.value.

5. License

No license.

6. Why?

To have another awesome javascript database. Synchronous. Light. Simpler.