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

slayer.db

v1.5.11

Published

Slayers database module

Downloads

33

Readme

What is this?

Easy to use database

Installation

npm i slayer.db

SlayersDBMongo

Basic Setup

//Import the class
import { slayersDBmongo } from "slayer.db";

// Create a new class of slayersDBmongo
const db = new slayersDBmongo({ options });

Set

// Takes a key and a value

db.set(key, value) --> // Key: String | Value: any;

deleteOne

// Delete one key from the database

db.deleteOne(key) --> // Key: String

deleteMany

// Exactly like "deleteOne" but deletes multiple

db.deleteMany(key) --> // Key: Array

has

// Check if the database has a key

db.has(key) --> // Key: String | Returns: Boolean

get

// Get a value by searching with key

db.get(key) --> // Key: String | Returns: Any;

deleteAll

// Delete everything from the database

db.deleteAll();

find

// Find data

db.find(); // Returns an array with all data

db.find({ Object }); // Returns an array with all data that has similar keys to the Object

reloadData

// Reload all data from the database
// NOTE: this is done on start up

db.reloadData();

findOneAndUpdate

// Name says its self..
// Find one and Update

db.findOneAndUpdate({find}, { toUpdate }, { options }) --> // Options have a default value of: { upsert: true }

SlayersDBJSON

Basic setup

import { slayersDBJSON } from "slayer.db";

// or

const { slayersDBJSON } = require("slayer.db");

// Create a new instance of the database

const data = new slayersDBJSON({ options }, [client]); --> // Client is optional

// DONT make new instances of the DB unless you plain on saving different data
// with the "saveInternal" option

Save

// No data will be saved for a restart until data.save() is used or db options say otherwise
// We recommend not saving too fast as it could corrupt the data, There is already a save cooldown

data.save() -> // Saves the data

Set

// Save the data with the set method

data.set(key, value);

// Advanced set

data.set("items.123", 10);

// Will save as: items: { 123: 10 }

Get

// Fetch set data with the get method

data.get(value) -> // If there is no data on the value undefined will be returned

// Advanced get

data.get('items.123')

// Gets In Object
// Gets format as: items: {123: value}
// Will return "value"

Has

//Check if the database has the key

data.has(key) -> // Returns a boolean

// Advanced

data.has('something.nested.very')

// Checks as:
// something: {nested: {very: }}

Delete

// Delete a key from the database

data.delete(key);

Clear

// Delete all saved data
// You cannot reverse this

data.clear();

Size

// Return how much data is saved

data.size -> // Returns a interger

Push

// Push more info into a value that is an Array

data.push(key, [WhatToPush]);

Splice

// Remove a certain element from an array

data.splice(key, query);

Clone

// Greate a clone of the entire Collection

data.clone() -> // Returns all methods

Add

// Add more to a number saved

data.add(key, Number);

Subtract

// Subtract a amount from a saved number

data.subtract(key, Number);

Table

// Create a new table and save data in different places

const table = new data.table({ options }, [client]) --> // Client is optional

Keys

// Returns an array of all saved keys

data.keys();

Values

// Returns an array of all saved values

data.values();

Random

// Returns randomly from all values
// Required the data.values() method

data.random() -> // Returns an Interger , String, Array

Random Key

// Returns randomly from all keys
// Required the data.keys() method

data.randomKey() -> // Returns an Interger , String, Array

Includes

// Serches through values

data.includes(query) -> // Returns a array if what includes the query

Includes Key

// Serches through keys

data.includesKey(query) -> // Returns a array if what includes the query

to JSON

// Returns all data in JSON format

data.toJSON({options}) -> // Returns a Object

Options

DB create

// When creating the instance of the db
new slayersDB({
  saveOnSet: false, // This will auto save when ever "data.set" is used

  saveOnUpdate: true, // Will save everytime the data updates
  // This option is highly recommended

  saveOnTimeout: {
    // This will save all the data on the timeout
    // NOTE: This will constantly keep your app alive
    func: true,
    timeout: 10 * 1000, // This will save on a 10 second interval
    // We do not recommended going anything under 5 seconds
    // If the app restarts before the interval runs again the data will not   be saved unless a "data.save" was used
  },
  saveOnDelete: false,
  // This will auto save the data when "data.delete" is used
  saveInternal: {
    func: true, // This is the toggle of it
    dir: "data", // This is the folder it should be stored in
    // Defualt dir is data folder. NOTE: dir stands for "directory"
    fileName: "db", // This is what the file will be called (DON'T add file extensions)
    // Default is "db"
  },
  // This will save the data outside of the node_modules folder
  // If you are using repl I highly recommend it
  // Either way this option is recommended for all users
  enableCooldown: false,
});

to JSON

data.toJson({
  straight: true, // This will format the way it is returned
});

SlayersEconomy

Basic setup

import { slayersEconomy } from "slayer.db";

// or

const { slayersEconomy } = require("slayer.db");

// Create a new instance of the database

const data = new slayersEconomy();

Save

// Make sure to use or the data wont be saved for a restart

data.save();

Add coins

// Add coins to a specific user

data.addCoins(userID, amount);

Remove coins

// Remove coins from a user

data.removeCoins(userID, amount);

Get Coins

// Get the amount of coins from a user

data.getCoins(userID);

Delete user

// Delete all users coins

data.deleteUser(userID);

Leader board

// Get a leaderboard on users

data.leaderBoard(amount);
// The amount is from how much must be returned
// If You put 10 the amount will be top 10
// Defualt is: 10

Clear

// Delete all data

data.clear();