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

remote-sqlite-database

v1.0.8

Published

A remote nodejs Cached sqlite Database Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fast, stores the Cache before stopping and restores it again! it uses ENMAP

Downloads

10

Readme

remote-sqlite-database

  • A remote nodejs Database using sqlite
  • It has auto-restore features
  • It is fast
  • It uses enmap aka sqlite
  • The clients are cached
  • Supports SHARDED Applications (like Discord Bots, which used enmap before)

Installation

npm install https://github.com/Tomato6966/remote-sqlite-database
npm install remote-sqlite-database

Usage

  1. Create the DB - Create a File-Folder-Project, at your CACHE-SERVER (it's a cache and db at the same time) and put in this Code:
const { remoteCacheServer } = require("remote-sqlite-database");

const Server = new remoteCacheServer({
    username: "TheUserNameForTheCacheServer",
    password: "ThePasswordForTheCacheServer",
    name: "databaseName",
    dataDir: "./path/to/database/",
    port: 4040, // Any port
    tls: true,
    debug: false // if enabled u see all the actions ;)
});
// Following Events are optional
Server
    .on("serverReady", () => {
        console.log("DatabaseCacheServer ready and waiting for connections");
    })
    .on("serverError", (error) => {
        console.error("DatabaseCacheServer error, ERROR:\n", error, "\n---\n");
    })
    .on("serverClose", (reason) => {
        console.log("DatabaseCacheServer closed");
    })
    .on("serverConnect", (connection, payload) => {
        console.log("DatabaseCacheServer a Client Connected");
    })
    .on("serverDisconnect", (connection, reason) => {
        console.log("DatabaseCacheServer a Client Disconnected");
    })
    .on("serverMessage", (message) => {
        // console.log("DatabaseCacheServer, received a Message", message);
    })
    .on("serverRequest", async (request, response, client) => {
        // console.log("DatabaseCacheRequest, received a Request", request);
    });
  1. To connect the cache do this:
const { remoteCacheClient } = require("remote-sqlite-database");
const client = new remoteCacheClient({
    username: "db_cache",
    password: "db_cache",
    host: "localhost",
    port: 5000,
    tls: true,
    keyPathing: true, // true|false ... enables if the key contains a "." that it's splitted to a path, e.g.: "hello.world.hi" --> key = "hello", path = "world.hi", db.get("hello") --> {world: {hi: "value"}}
}); 
//keyPathing should be set to false, if you want to do "key.hello" as a key

// following events are optional
client
    .on("cacheReady", () => {
        console.log("DATABASECACHECLIENT ready and connected");
    })
    .on("cacheError", (error) => {
        console.error("DATABASECACHECLIENT error, ERROR:\n", error, "\n---\n");
    })
    .on("cacheClose", (reason) => {
        console.log("DATABASECACHECLIENT closed, REASON?:\n", reason, "\n---\n");
    })
    .on("cacheMessage", (message) => {
        console.log("message", message);
    })
    .on("cacheRequest", async (request, response, client) => {
        console.log("REQUEST", request);
    });

// example usage
async function yourProgram(){
    await client.set("hi", "bye").then(console.log).catch(console.error);
    await client.get("hi").then(console.log).catch(console.error);
    await client.set("array", []).then(console.log).catch(console.error);
    await client.push("array", "element").then(console.log).catch(console.error);
    await client.push("array", "element2").then(console.log).catch(console.error);
    await client.size().then(console.log).catch(console.error);
    await client.get("array").then(console.log).catch(console.error);
    await client.all().then(console.log).catch(console.error);
}

yourProgram();

Methods (Functions) for the CACHE-CLIENT(s)

  • all "path"'s are optional
  • get(key, path) get any value from a key
  • set(key, path) set any value in a key
  • add(key, amount, path) add a number to a key/path
  • substract(key, amount, path) removes a number from a key/path
  • math(key, operator, amount, path) make a mathematical operation like adding, substracting multiplying etc.
  • push(key, element, path) add an element in an array
  • remove(key, element, path) remove an element out of an array
  • has(key, path) check if the key / key-path exists
  • delete(key, path) delete something
  • clear() clears the whole cache Map
  • all() / values() array of all values
  • entries() array of [key, value]
  • keys() array of all keys
  • ping() shows the ping
  • size() shows the cache-map-size
  • ensure(key, data, path) ensures data in the db

Events for the CACHE-SERVER

  • serverReady shows when the server is ready, you don't need to listen to it!
  • serverError shows when the server errors, you don't need to listen to it!
  • serverClose shows when the server closes, you don't need to listen to it!
  • serverConnect shows when a client connects, you don't need to listen to it!
  • serverDisconnect shows when a client disconnects, you don't need to listen to it!
  • serverMessage receives messages from a cache-client, you don't need to listen to it!
  • serverRequest received requets from a cache-client, used for sending the cache datas, you don't need to listen to it!

Events for the CACHE-Client(s)

  • cacheReady shows when the server is ready, you don't need to listen to it!
  • cacheError shows when the server errors, you don't need to listen to it!
  • cacheClose shows when the server closes, you don't need to listen to it!
  • cacheMessage receives messages from the cache-server, you don't need to listen to it!
  • cacheRequest receives requets from the cache-server, you don't need to listen to it!