litemap
v1.38.0
Published
A TypeScript library for mapping and processing data with SQLite integration
Downloads
16
Readme
Litemap
A lightweight, persistent key-value database for Node.js, designed for simple user and item storage with SQLite as the backend. Litemap provides an easy-to-use API for managing users, items, and other records, making it ideal for bots, and other various apps.
Features
- 💾 Persistent storage – Data is saved to disk using SQLite.
- Any updates to the database will be stored in a queue to prevent "transcation within a transaction"
- 🔑 Key-value access – Store and retrieve users/items by key.
- 🏎️ Fast and lightweight – Minimal dependencies, quick operations.
- SQLite
- SQLite3
- 🤖 Perfect for bots – Designed for Discord bots and automation scripts.
Installation
npm install litemapUsage
const { DatabaseFactory } = require("litemap");
const fs = require("fs/promises");
(async () => {
await fs.mkdir("./db", { recursive: true });
const dbManager = DatabaseFactory.Instance("./db/litemap.db");
if (!(await dbManager.getUser("user1"))) {
await dbManager.addUsers([
{
key: "user1",
value: {
name: "Mad Hatter",
role: "superadmin",
email: "[email protected]",
createdAt: new Date().toISOString(),
lastLogin: null,
},
},
]);
} else {
console.log("user1 already exists, skipping creation.");
if (
(await dbManager.getUser("user1").lastLogin) !== new Date().toISOString()
) {
await dbManager.updateUser("user1", {
lastLogin: new Date().toISOString(),
});
console.log("Updated last login for user1.");
}
dbManager.getUser("user1").then((user) => {
console.log("Current user1 data:", user);
});
}
})();Exports
const { DatabaseFactory, SQLiteDatabase, UserDatabaseManager } = require("litemap");Types
You can import types for TypeScript:
import type { IUserRecord, UserRecord } from "litemap";Example Use Cases
- Discord bots: Store user profiles, stats, and settings.
- CLI tools: Save configuration or user data.
- Web apps: Lightweight persistent storage without a full database server.
- Prototyping: Quickly persist data during development.
