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

hive-db

v2.1.0

Published

A peristant database for impressive storage and easy functionality

Downloads

6

Readme

hive-db

ChangeLog

Hive-db now has interactions based on the adapter you choose, so that you can swiftly use the whole module! Wiki for an in-dept guide

Hive-db

Hive-db is a persistent modular database to store data with ease, rather than complex structures.

Adapters

  1. mongodb -> hive.mongo
  2. sqlite -> hive.sqlite
  3. postgres -> hive.Postgres

An example of how it looks!

const hive = require('hive-db');
const db = hive.sqlite;
db.init('name',['Lason']);
db.get('name')
// output => Lason

/*
Array Functionality in Hive-db
*/

db.input('name','Tensor')
db.array('name');
// output => Lason, Tensor

Example with a discord.js bot

const Discord = require('discord.js');
const hive = require('hive-db');
const db = hive.sqlite;

 run = async (message, args, client) =>{
 message.channel.send('Enter your name');
 db.init('name', args[0]);
 }

//Trigger function using get.

const Discord = require('discord.js');
const db = require('hive-db');

 run = async (message, args, client) =>{
 message.channel.send('Your name is \t'+db.get('name'));
 }
 /*
 You can do only user based values that are unique for example, to remember
 the name of some users db.init(`name_${message.author.id}`, args[0]), because
 discord user ids are unique, same goes with guild values!
 */

Provided Functions as of now

  1. Initialize your key and value!
db.init('name',['Lason']);
  1. Get the value stored in the key!
db.fetch('name')
  1. Delete a key!
db.del('name')
  1. Input an element into an array value.
db.push('name','Tensor')
  1. Subtract a numeric value from a key storing a numeric value
db.subtract('age',1)
// subtracting 21 from 1, where age(key) contains -> 21
  1. Subtract a numeric value from a key storing a numeric value
db.add('age',1)
// Adding 1 to 21, where age(key) contains -> 21
  1. Fetching all elements as an array
db.fetchArray('name')
// output => Tensor, Lason
  1. Checks if a key stores a value or is null
db.has('name')
// output => true
  1. Outputs the datatype of the stored value in a key.
db.datatype('age')
// output => int

Mongo-Db interaction with Hive-db

You can use both localhost and MongoDb altas uri's to connect to mongodb. Here is an example of its support:-

const db = require('hive-db');
// Point to be noted, database is a constructor under db.mongo
const {database} = db.mongo;
const mongo= new database("mongodb+srv://wyvern:[email protected]", "JSON", { useUnique: true });
mongo.on("ready", () => {
    console.log(`Connected!`);
    test();
});
mongo.on("error", console.error);
mongo.on("debug", console.log);
async function test() {
  mongo.init('age','21');
  mongo.get('age')
  //-> 21
  mongo.init('name','Lason');
  mongo.get('name');
  //-> Lason
}

Creating Tables using hive-db mongo interaction!

const db = require('hive-db');
const mongo= new db.Mongo("mongodb+srv://wyvern:[email protected]", "JSON", { useUnique: true });
mongo.on("ready", () => {
    console.log(`Connected!`);
    test();
});
mongo.on("error", console.error);
mongo.on("debug", console.log);
async function test() {
  const test = db.table('test');
  test.init('slogan','hive-db is da best!')
  test.get('slogan');
  // output => hive-db is da best
  // while if we use mongo.get('slogan') it won't work!
  mongo.get('slogan');
  // returns null!
}

Mongo Methods

Initialize a value.

mongo.init("foo", "bar");

Get a value.

mongo.get("foo").then(console.log);
//-> bar

Input a value into an existing array.

mongo.push("name");
// assuming that the key name has an array, for example ["Lason", "Tensor"]

Add a value to a data(number) in a key

mongo.add('age', 4)
// adds 4 to the age

Subtract a value from a data(number) in a key

mongo.subtract('age', 4)
// subtracts 4 from the age

Create data models!

const age = mongo.table('age')
age.init('name', 'Lason')
age.get('name').then(console.log);
// -> Lason!

TIP You can use your own data table using a JSON base. Below stats an example using the key, data structure.

[
{
"ID":"something",
"data":"something"
}
]

Hive-db understands this without any external effort, and you don't even have to call the file anywhere in your code!

db.get("something");
//-> give you something as the output!

Postgres Methods

Yes hive-db offers postgres interaction! Isn't that super cool!

Connecting to the postgres pool:

{Postgres} = require('hive-db');
const db = new Postgres({
   host: 'localhost',
  user: 'postgres',
  password: '1234',
  database: 'myDatabase'
})
/*
Basic paradigm
new Postgres({
  config options, 
  table
})
*/

Create new schemas using the postgres pool!

{Postgres} = require('hive-db');
const db = new Postgres({
   host: 'localhost',
  user: 'postgres',
  password: '1234',
  database: 'myDatabase'
}, {
  schema:'people' //schema name
})

get data

await db.get('peope')

init data

await db.init('people', 'Jack');

delete data

await db.del('people', 'Lason');

push data into an array

await db.push('people', 'Tensor');

Fetch data as an array!

await db.fetchArray('people');
// output => [Jack, Tensor]

Search for a value in a key

await db.search('people','Tensor')
// output => true

Support Server | Documentation

Sponsors!

BytesToBits

Bytes To Bits

Reminder

The hive-db github repository is the development verision of hive-db.

Also

Check the wiki for a guide.