New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

octavia-db

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

octavia-db

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.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
increased by10%
Maintainers
1
Weekly downloads
 
Created
Source

Octavia DB

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.

Authors

Buy Me A Coffee

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.

  • CRUD Operations: Perform Create, Read, Update, and Delete operations on collections.

  • Database Information: Retrieve information about the database, collections, and file sizes.

Getting Started

Create a new database with a name and password
const myDatabase = new OctaviaDB({
	databaseName: 'myDatabase',
	databasePassword: 'mySecretPassword',
	logging: true // Set to false to disable logging
});
Create a collection. databaseName.collection()
const userCollection = myDatabase.collection(
	'users', // collection name
	true  // encryption, default true
);
Insert data into the collection. collectionName.insert()
const user1 = {
    username: 'john_doe',
    email: 'john.doe@example.com',
    age: 30
};

const result = userCollection.insert(user1);

if(result) {
	console.log(`inserted successfully`)
} else {
	console.log(`error while inserting the data`)
}
Insert multiple data objects into the collection. collectionName.insertMany()
const multipleUserData = [
	{
		username: "patrick_williams",
		email: "patrick.williams@example.com",
		age: 25
  	},
	{
		username: "jane_smith",
		email: "jane.smith@example.com",
		age: 25
	},
	{
		username: "alex_johnson",
		email: "alex.johnson@example.com",
		age: 35
	},
	{
		username: 'john_doe',
		email: 'john.doe@example.com',
		age: 25
	}
];

const insertResult = userCollection.insertMany(multipleUserData);

if(insertResult) {
	console.log("success")
} else {
	console.log(`error while inserting the data`)
}
Find a user in the collection. collectionName.find()
const foundUser = userCollection.find({ username: 'john_doe' });

if (foundUser) {
    console.log('Found User:', foundUser);
} else {
    console.log('User not found.');
}
Find many users in the collection. collectionName.findMany()
const foundUser = userCollection.findMany({ age: 25 });

if (foundUser) {
    console.log('Found User:', foundUser);
} else {
    console.log('User not found.');
}
Update user information. collectionName.update()
const updatedUserData = {
    age: 31,
    city: 'New York'
};

const updated = userCollection.update({ username: 'alex_johnson' }, updatedUserData);

if (updated) {
    console.log("success");
} else {
    console.log("failed");
}
Update many user information. collectionName.updateMany()
const updatedUserData = {
    status: "active"
};

const updated = userCollection.updateMany({ age: 25 }, updatedUserData);

if (updated) {
    console.log("success");
} else {
    console.log("failed");
}
Remove a user from the collection. collectionName.remove()
const removed = userCollection.remove({ username: 'alex_johnson' });

if (removed) {
    console.log("success");
} else {
    console.log("failed");
}
Remove many user from the collection. collectionName.removeMany()
const removed = userCollection.removeMany({ username: 'john_doe' });

if (removed) {
    console.log("success");
} else {
    console.log("failed");
}
Get information about the collection. collectionName.info()
const collectionInfo = userCollection.info();

if (collectionInfo) {
    console.log('Collection Information:', collectionInfo);
} else {
    console.log('Collection not found.');
}
Get information about the entire database. databaseName.info()
const databaseInfo = myDatabase.info();

if (databaseInfo) {
    console.log('Database Information:', databaseInfo);
} else {
    console.log('Database not found.');
}
Delete the collection
const isUserCollectionDeleted = userCollection.delete();

if (isUserCollectionDeleted) {
    console.log('Collection deleted successfully.');
} else {
    console.log('Error deleting collection.');
}
Delete the entire database
const isDatabaseDeleted = myDatabase.delete();

if (isDatabaseDeleted) {
    console.log('Database deleted successfully.');
} else {
    console.log('Error deleting database.');
}

Keywords

FAQs

Package last updated on 15 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc