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

@sojs_coder/sodb

v1.5.9

Published

A file system database with encryption support.

Downloads

40

Readme

SoDB

Support for database encryption and automatic compression. The most cost effective database solution. Free to use, and simple to set up.

Data is stored as documents. Documents are sets of attributes linked under one key. Documents are stored in individual JSON files for maximum read speeds.

After a set time of no interaction with a document, it is compressed for more efficient storage. Once it is read or edited again, the timer resets.

Docs:

Installation

npm install @sojs_coder/sodb
const so_db = require("@sojs_coder/sodb");

Usage

const { Database } = require('@sojs_coder/sodb');

// Create a new database
const myDB = new Database('myTable',{
  encrypt: true
});

// Add a new document
myDB.addDoc('document1', {property1: 'value1', property2: 'value2'})
    .then((document) => console.log(document))
    .catch((err) => console.error(err));

// Update an existing document
myDB.updateDoc('document1', {property1: 'newValue1'})
    .then(() => console.log('Document updated'))
    .catch((err) => console.error(err));

// Get a document
myDB.getDoc('document1')
    .then((document) => console.log(document))
    .catch((err) => console.error(err));

// Delete a document
myDB.deleteDoc('document1')
    .then(() => console.log('Document deleted'))
    .catch((err) => console.error(err));

// Dump all documents
myDB.dump()
    .then((documents) => console.log(documents))
    .catch((err) => console.error(err));


// Encrypt all documents
myDB.encryptDocs()


// Decrypt all documents
myDB.unencryptDocs()

Class Database

new Database(table_name, options)

Creates a new Database instance.

  • table_name: the name of the table for the database. This will be used as the name of the directory in which the documents will be stored.
  • options: JSON object to improve database performance and optimize for your use case.
    • encrypt: defualt false. If true, data in the data base will be encypted using AES encrytion. Set an enviroment variable called SO_DB_KEY for this to work (do not share this with anyone, it will allow them to decrypt your database)
    • timeToCompress: defualt 24. The quantity of time (in hours) that an untouched document takes to compress. A document is considered touched when it is created, modified, or read from.

addDoc(id, obj)

Adds a new document to the database.

  • id: the unique identifier for the document to be updated.
  • obj: the updated content of the document, in the form of a JavaScript object.

updateDoc(id, obj)

Updates an existing document in the database, and returns the contents of the updated document as a promise.

  • id: the unique identifier for the document to be updated.
  • obj: the updated content of the document, in the form of a JavaScript object.

deleteDoc(id)

Deletes a document from the database.

  • id: the unique identifier for the document to be deleted.

dump()

  • Retrieves all documents from the database.

encryptDocs

  • Encrypts database completely, useful for changing from decrypted database to encrypted

unencryptDocs

  • Completely decrypts database, useful for viewing encrypted data (use at your own risk)

Speeds

  • 166 Kilobytes
    • (Compressed) 24.475886998698115 milliseconds
    • (Compressed + encrypted) --- milliseconds
  • 332 Kilobytes
    • (Compressed) 28.68665700033307 milliseconds
    • (Compressed + encrypted) 884.8475460037589 milliseconds
  • 829 Kilobytes
    • (Compressed) 47.736504999920726 milliseconds
    • (Compressed + encrypted) 966.7856909930706 milliseconds
  • Sample 1 (Small sample data)
    • (Compressed + encrypted) 17.297598004341125 milliseconds