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

octavia-db

v2.0.0

Published

OctaviaDB is a lightweight Node.js module for creating encrypted collections of data on the filesystem. It provides basic CRUD (Create, Read, Update, Delete) operations for collections and supports encryption for data security.

Downloads

64

Readme

Octavia DB

OctaviaDB is a lightweight Node.js module for creating encrypted collections of data on the filesystem and supports encryption for data security.

Installation

To install the OctaviaDB module, run the following command in your terminal:

npm install octavia-db

Features

  • Encryption: OctaviaDB provides built-in encryption for your database to ensure data security.

  • Database Information: Retrieve information about the database and collections

  • Schema Validation: Validate data against predefined schemas to ensure data integrity and consistency.

Methods

// database methods
db.info()
db.delete()
db.collectionExists(collectionName)

// collection methods. `dataScheme` are optional
collection.info()
collection.delete()
collection.insert(objectData, dataScheme)
collection.insertMany(ArrayOfDataObjects, dataScheme)
collection.find(queryData)
collection.findMany(queryData)
collection.update(queryData, newData, dataScheme)
collection.updateMany(queryData, newData, dataScheme)
collection.remove(queryData)
collection.removeMany(queryData)

Getting Started

Create a new database with a name and password

const { OctaviaDB } = require("octavia-db")

const db = new OctaviaDB({
	database: 'myDatabase',
	password: 'mySecretPassword',
});

Create a collection. db.Collection()

const userCollection = db.Collection(
	'users', // collection name
	true  // encryption, default true
);

Insert data into the collection. collection.insert()

const user = {
    username: 'john_doe',
    email: '[email protected]',
    age: 30
};

try {
	userCollection.insert(user)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Insert data into the collection. collection.insert() with data scheme

const user = {
    username: 'john_doe',
    email: '[email protected]',
    age: 30,
	active: true,
	languages: [
		'c++',
		'c',
		'golang',
		'js'
	]
};

try {
	userCollection.insert(user, {
		username: String,
    	email: String,
    	age: Number,
		active: Boolean,
		languages: Array
	})
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Insert multiple data objects into the collection.collection.insertMany()

const multipleUserData = [
	{
		username: "patrick_williams",
		email: "[email protected]",
		age: 25
  	},
	{
		username: "jane_smith",
		email: "[email protected]",
		age: 25
	},
	{
		username: "alex_johnson",
		email: "[email protected]",
		age: 35
	},
	{
		username: 'john_doe',
		email: '[email protected]',
		age: 25
	}
];

try {
	userCollection.insertMany(multipleUserData)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Find a user in the collection. collection.find()

try {
	const foundUser = userCollection.find({ username: 'john_doe' })
	console.log(result)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Find many users in the collection. collection.findMany()

try {
	const users = userCollection.findMany({ age: 25 })
	console.log(users);
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Update user information. collection.update()

try {
	const updatedUserData = {
    	age: 31,
    	city: 'New York'
	};

	const updated = userCollection.update({ username: 'alex_johnson' }, updatedUserData)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Update many user information. collection.updateMany()

try {
	const updatedUserData = {
    	status: "go to work"
	};

	const updated = userCollection.updateMany({ age: 25 }, updatedUserData)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Remove a user from the collection. collection.remove()

try {
	const removed = userCollection.remove({ username: 'alex_johnson' })
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Remove many user from the collection. collection.removeMany()

try {
	const removed = userCollection.removeMany({ age: 25 })
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Get information about the collection. collection.info()

try {
	const collectionInfo = userCollection.info()
	console.log(collectionInfo)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Get information about the entire database. databaseName.info()

try {
	const databaseInfo = db.info()
	console.log(databaseInfo)
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Delete the collection. collection.delete()

try {
	const response = userCollection.delete()
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Delete the entire database. db.delete()

try {
	const response = db.delete()
} catch(error) {
	console.log("Code:", error.code)
	console.log("Message:", error.msg)
}

Example

const { OctaviaDB } = require("octavia-db")

try {
    const DB = new OctaviaDB({
        database: "database",
        password: "mypassword"
    })

    const users = DB.Collection("users", false)

    const insert = users.insert({
        id: 1,
        username: "madhan",
        age: 20,
        records: { r1: 1, r2: 2 },
        languages: ["js", "c", "c++", "go", "php"],
        deep: {
            tags: {
                a: true,
                b: false
            },
            btns: {
                text: "click",
                className: "button",
                index: 0
            }
        }
    }, {
        id: Number,
        username: String,
        age: Number,
        records: Object,
        languages: Array,
        deep: {
            tags: {
                a: Boolean,
                b: Boolean
            },
            btns: {
                text: String,
                className: String,
                index: Number
            }
        }
    })

    console.log("[+] insert:", insert)

    const insertMany = users.insertMany([
        {
            id: 2,
            username: "madhan",
            age: 20,
            records: { r1: 1, r2: 2 },
            languages: ["js", "c", "c++", "go", "php"],
            deep: {
                tags: {
                    a: true,
                    b: false
                },
                btns: {
                    text: "click",
                    className: "button",
                    index: 0
                }
            }
        },
        {
            id: 3,
            username: "madhan",
            age: 25,
            records: { r1: 1, r2: 2 },
            languages: ["js", "c", "c++", "go", "php"],
            deep: {
                tags: {
                    a: true,
                    b: false
                },
                btns: {
                    text: "click",
                    className: "button",
                    index: 0
                }
            }
        }
    ], {
        id: Number,
        username: String,
        age: Number,
        records: Object,
        languages: Array,
        deep: {
            tags: {
                a: Boolean,
                b: Boolean
            },
            btns: {
                text: String,
                className: String,
                index: Number
            }
        }
    })

    console.log("[+] insertMany:", insertMany)

    const find = users.find({ age: 25 })
    console.log("[+] find:", find)

    const findMany = users.findMany({ age: 20 })
    console.log("[+] findMany:", findMany)

    const update = users.update({ age: 25 }, { status: "active" }, { status: String })
    console.log("[+] update:", update)

    const updateMany = users.updateMany({ age: 20 }, { status: "inActive" }, { status: String })
    console.log("[+] updateMany:", updateMany)

    const remove = users.remove({ age: 25 })
    console.log("[+] remove:", remove)

    const removeMany = users.removeMany({ age: 20 })
    console.log("[+] removeMany:", removeMany)

    console.log("[+] database information:", DB.info())
    console.log("[+] collection information:", users.info())

    const collectionDelete = users.delete()
    console.log("[+] collectionDelete:", collectionDelete)

    const databaseDelete = DB.delete()
    console.log("[+] databaseDelete:", databaseDelete)
} catch (error) {
    console.log("Message:", error.msg)
    console.log("Code:", error.code)
}