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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@erxprojects/syntx-db

v1.0.0

Published

A simple and lightweight database for managing Discord bot variables. Built for Syntx.js, but usable in any project.

Readme

@erxprojects/syntx-db

A simple, lightweight JSON-based database for Discord bots. Built for Syntx.js, but usable in any Node.js project.

Installation

npm i github:erxproject/syntx-db

Table of contents


Setup

const { Database } = require("@erxprojects/syntx-db")

const db = new Database({
    path: "./database",
    cache: true,
    backup: true,
    pretty: false
})

| Option | Type | Default | Description | | ----------- | --------- | ------- | -------------------------------------------------- | | path | string | — | Folder where the data will be stored. Required. | | cache | boolean | true | Enables in-memory cache for faster reads. | | cacheMax | number | 0 | Max number of cached entries. 0 = unlimited. | | cacheTTL | number | 0 | Cache TTL in milliseconds. 0 = no expiry. | | backup | boolean | true | Creates .bak backups before overwriting files. | | pretty | boolean | false | Pretty-prints the JSON files. |


Creating variables

Before reading or writing, you must create a variable and define its scope and default value.

await db.create("coins", { scope: "user", default: 0 })
await db.create("welcome", { scope: "guild", default: true })
await db.create("maintenance", { scope: "global", default: false })

Scopes

Every variable has a scope that determines what key it's stored under.

| Scope | Access method | Keyed by | | -------- | --------------------------| --------------------- | | user | db.user(userId, guildId)| User + guild pair | | guild | db.guild(guildId) | Guild | | global | db.global(userId) | User (across guilds) |

// User scope — per user per server
const handle = db.user(message.author.id, message.guild.id)

// Guild scope — per server
const handle = db.guild(message.guild.id)

// Global scope — per user across all servers
const handle = db.global(message.author.id)

Reading and writing

const handle = db.user(message.author.id, message.guild.id)

// Get the current value (returns default if not set)
const coins = await handle.get("coins")

// Set a value
await handle.set("coins", 100)

// Check if a value has been set
const hasCoins = await handle.has("coins")

// Reset to the default value
await handle.reset("coins")

// Delete the entry entirely
await handle.delete("coins")

Array and number helpers

These methods are atomic — safe to use in concurrent environments.

const handle = db.user(userId, guildId)

// Add to a number
await handle.add("coins", 50)   // coins += 50
await handle.add("coins", -10)  // coins -= 10

// Append to an array
await handle.push("inventory", "sword")

// Remove all occurrences of a value from an array
await handle.pull("inventory", "sword")

add() requires the variable's default to be a number. push() and pull() require it to be an array.


Expiring values

Store a value that automatically resets to its default after a set time.

// Stores "boosted" as true for 1 hour, then reverts to default
await db.guild(guildId).setExpiring("boosted", true, 60 * 60 * 1000)

Database utilities

// Check if a variable exists
await db.exists("coins")             // true | false

// Get metadata about a variable
await db.info("coins")
// → { name, scope, default, createdAt }

// Get all stored entries for a variable (useful for leaderboards)
await db.getAll("coins")
// → { "u_123-g_456": 200, "u_789-g_456": 50, ... }

// List all registered variable names
await db.list()                      // ["coins", "welcome", ...]

// Remove a variable and all its data
await db.remove("coins")

// Get database stats
await db.stats()
// → { variables: 3, size: "12.4 KB" }

// Clear the in-memory cache
db.clearCache()