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

@ndiinginc/store

v1.0.1

Published

Key-value store sederhana di atas [@ndiinginc/dal](https://www.npmjs.com/package/@ndiinginc/dal), dengan scoping otomatis berdasarkan `apiId` dan `sessionId`. Cocok untuk menyimpan session data, state, atau cache kecil per API/session di dalam tabel SQL.

Readme

@ndiinginc/store

Key-value store sederhana di atas @ndiinginc/dal, dengan scoping otomatis berdasarkan apiId dan sessionId. Cocok untuk menyimpan session data, state, atau cache kecil per API/session di dalam tabel SQL.

Fitur:

  • Auto-create table saat pertama kali dipakai (ensureTable)
  • Data terisolasi per apiId + sessionId
  • Operasi dasar: get, set, has, delete, clear, getAll
  • Upsert otomatis lewat onConflict(...).doUpdate()

Instalasi

npm install @ndiinginc/store

Penggunaan

const Store = require("@ndiinginc/store");
const db = require("@ndiinginc/dal")(/* konfigurasi db */);

const store = new Store(db, {
    tableName: "stores", // opsional, default "stores"
    apiId: "my-api",     // opsional, default "default"
    sessionId: "user-123" // opsional, default "default"
});

await store.set("token", "abc123");
console.log(await store.get("token")); // "abc123"
console.log(await store.has("token")); // true

await store.delete("token");
console.log(await store.has("token")); // false

API

new Store(db, options)

Membuat instance store baru.

| Parameter | Tipe | Default | Keterangan | |---|---|---|---| | db | import("@ndiinginc/dal") | — | Instance DAL yang sudah terkoneksi ke database | | options.tableName | String | "stores" | Nama tabel yang dipakai/dibuat | | options.apiId | String | "default" | Namespace berdasarkan API | | options.sessionId | String | "default" | Namespace berdasarkan session |

store.set(name, value)

Menyimpan atau memperbarui (upsert) sebuah key. Mengembalikan Promise hasil query insert/update.

await store.set("theme", "dark");

store.get(name)

Mengambil value dari sebuah key. Mengembalikan Promise<any> (value saja, bukan row lengkap), atau undefined jika tidak ditemukan.

const theme = await store.get("theme");

store.has(name)

Mengecek apakah sebuah key ada. Mengembalikan Promise<Boolean>.

if (await store.has("theme")) { ... }

store.delete(name)

Menghapus satu key spesifik dalam scope apiId + sessionId saat ini.

await store.delete("theme");

store.clear()

Menghapus semua key dalam scope apiId + sessionId saat ini (tidak memengaruhi apiId/sessionId lain).

await store.clear();

store.getAll()

Mengambil seluruh key-value dalam scope saat ini sebagai object biasa.

const all = await store.getAll();
// { token: "abc123", theme: "dark" }

Struktur Tabel

Tabel dibuat otomatis (jika belum ada) dengan skema berikut:

| Kolom | Tipe | Keterangan | |---|---|---| | api_id | text, NOT NULL | Bagian dari primary key | | session_id | text, NOT NULL | Bagian dari primary key | | name | text, NOT NULL | Bagian dari primary key (nama key) | | value | text | Nilai yang disimpan |

Primary key: (api_id, session_id, name) Index tambahan: (api_id, session_id)

Catatan: pembuatan tabel otomatis (_ensureTable) berjalan setiap kali method dipanggil selama ensureTable = true (default). Set store.ensureTable = false setelah tabel dipastikan ada jika ingin menghindari overhead cek exists() di setiap call.

Lisensi

ISC / sesuai kebijakan internal @ndiinginc.