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

betterqdb

v0.0.7

Published

A revamped version of Quick.db! More functions and weekly updates!

Downloads

1

Readme

BetterQDB

Quick.db but with a slight few adjustments. Added more functions/methods to fiddle around with. Fixed Bugs that quick.db could not offer at the moment.

| Original Makers | Discord Support (600+ Members) | NPM Page | |:--------------------------------------------------: |:------------------------------: |:-----------: | | Quick.db |discord.gg/WYH6n6w| Coming Soon |

Introduction

Most functions shown are similar to the original quick.db documentation. This package just altars everything. Credit to TrueXPixels

const db = require('betterdqb');
 
// Setting an object into the key "Bob"
db.set('Bob', { health: 100, mana: 100 })
// Whole key returns -> { health: 100, mana: 100 }
 
// Pushing an element into an array ( This array does not exist yet )
db.push('Bob.inventory', 'Apple')
// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple'] }
// Bob.inventory returns => ['Apple']
 
// Adding a number to a new field ( This field does not exist yet )
db.add('Bob.balance', 500)
// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple'], balance: 500 }
// Bob.balance returns => 500
 
// Repeating previous examples:
db.push('Bob.inventory', 'Grape')
// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple', 'Grape'], balance: 500 }
// Bob.items returns => ['Apple', 'Grape']

db.set('Bob.balance', 1000)
// Whole key returns -> { health: 100, mana: 100, inventory: ['Apple', 'Grape'], balance: 1000 }
// Bob.balance returns => 1000
 
// Fetching individual properties
// Using either .get or .fetch works

db.get('Bob.balance') // -> 1000
db.fetch('Bob.inventory') // ['Sword', 'Watch']

Documentation

Methods

  • new db.table(name)
  • add(key, number, [options])
  • .all() -> array
  • .delete(key, [options])
  • get(key, [options])
  • .has(key, [options])
  • .push(key, element, [options])
  • .set(key, data, [options])
  • .subtract(key, number, [options])

new .table(name)

This function creates a new table, allowing you to separate your data while being used exactly the same.

const db = require('betterqdb');

let economy = new db.table('economy')
economy.set('balance', 500) // output -> 500
economy.get('balance') // output -> 500
db.get('balance') // output -> null

.add(key, number, [options])

This function adds a number to a key in the database. (If no existing number, it will add to 0)

db.get('balance') // output -> 500
db.add('balance', 250) // output -> 750

Also allows for accessing properties using dot notation

db.get('Bob') output // -> { guild: null, balance: 500 }
db.add('Bob.balance', 250) // output -> { guild: null, balance: 750 }

.all() -> array

This function returns the entire active table as an array.

db.all() // output -> [Array]

.delete(key, [options])

This function deletes the specified key. Returns if it was a success or not.

db.get('data') // -> "Hello World!"
db.delete('data') // true

Also allows for accessing properties using dot notation

db.get('Bob') // output -> { guild: null, balance: 500 }
db.delete('Bob.balance') // output -> true
db.get('Bob') // output -> { guild: null }

.get(key, [options])

This function returns data from a row based on the key. Alias: .fetch()

db.set('data', 'Hello World!') // output -> 'Hello World!'
db.get('data') // output -> 'Hello World!'

Also allows for accessing properties using dot notation\

db.set('Bob', { guild: 'Plexi', balance: 500 }) // output -> { guild: 'Plixi Divilopmint', balance: 500 }
db.get('Bob.guild') // output -> "Plixi Divilopmint"
db.get('Bob.balance') // output -> 500
db.get('Bob.qwerty') // output -> undefined

.has(key, [options])

This function returns a boolean based on whether an element or property exists. Alias: .exists()

db.set('data', 'Hello World!') // output -> 'Hello World!'
db.has('data') // output -> true

Also allows for accessing properties using dot notation

db.set('Bob', { guild: 'Plixi Divilopmint', balance: 500 }) // output -> { guild: 'Plixi Divilopmint', balance: 500 }

db.has('Bob.guild') // output -> true
db.has('Bob.items') // output -> false

.push(key, element, [options])

This function will push into an array in the database based on the key. (If no existing array, it will create one)

db.set('Bob.inventory', ['Grape', 'Apple']) // output -> ['Grape', 'Apple']
db.push('Bob.inventory', 'Pear') // output -> ['Grape', 'Apple', 'Pear']

Also allows for accessing properties using dot notation

db.set('Bob', { balance: 500, inventory: ['Grape', 'Apple'] }) // output -> { balance: 500, inventory: ['Grape', 'Apple'] }
db.push('Bob.inventory', 'Pear') // output -> { balance: 500, items: ['Grape', 'Apple', 'Pear'] }

.set(key, data, [options])

This function sets new data based on a key in the database. (When using dot notation, if the object doesn't exist it'll create one)

db.set('data', 'Hello World!') // output -> 'Hello World!'
db.set('data', 50) // output -> 50
db.set('data', { foo: 'bar' }) // output -> { foo: 'bar' }

Also allows for accessing properties using dot notation

db.get('Bob') // -> null
db.set('Bob.guild.rank', 'Plixi Pro') // output -> { guild: { rank: 'Plixi Pro' } }
db.set('Bob.balance', 500) // output -> { guild: { rank: 'Plixi Pro' }, balance: 500 }
db.set('Bob.guild.rank', 'Plixi Overlord') // output -> { guild: { rank: 'Plixi Overlord' }, balance: 500 }

.subtract(key, number, [option])

This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)

db.get('balance') // output -> 500
db.subtract('balance', 200) // output -> 300

Also allows for accessing properties using dot notation

db.get('Bob', { league: 'Gold', XP: 500 }) // output -> { league: 'Gold', XP: 500 }
db.subtract('Bob.XP', 200) // output -> { league: 'Gold', XP: 300 }