Tona-DB mini is a JavaScript library for simulating small local databases in JSON.
npm install tona-db-miniA simple library to store and retrieve JSON data



``shell`
npm install tona-db-mini
in the root directory of your project. This file should contain the following properties:`json
{
"dbPath": "./tdb-mini-data",
"prettyJson": false
}
`-
dbPath - The path to the database folder.
- prettyJson - A boolean value that determines whether the JSON data should be formatted with indentation.Usages
$3
`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Add a new user
users.add({ name: "John Doe", age: 30 });
// Get user by name
const user = users.get({ name: "John Doe" });
`$3
To add data to a collection, you can use the add method.
The add method takes an object or an array of objects as an argument.`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Add a new user
users.add({ name: "John Doe", age: 30 });
// Add multiple users
users.add([{ name: "Jane Doe", age: 25 }, { name: "Bob Smith", age: 35 }]);
`$3
To get data from a collection, you can use the get method.
The get method takes an Filter as an argument. If no filter is provided, it will return all data from the collection.`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Get data from collection
const specificUser = users.get({ name: "John Doe" });
// Get all data from collection
const allUsers = users.get();
`$3
To update data in a collection, you can use the update method.
The update method takes a Filter and a partial data object as arguments.`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Update data in collection
users.update({ name: "John Doe" }, { age: 31 });
`
$3
To delete data from a collection, you can use the del method.
The del method takes an Filter as an argument. If no filter is provided, it will delete all data from the collection.`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Delete data from collection
users.del({ name: "John Doe" });
// Delete all data from collection
users.del();
`$3
You can use a filter to specify which data you want to get, update, or delete from a collection. The filter can be an object or a predicate function.`ts
import db from "tona-db-mini";// Create your type for your collection
type User = {
name: string;
age: number;
};
const users = db.collection("users");
// Get user with name "John Doe"
const specificUser = users.get({ name: "John Doe" });
// Get users with age greater than 30
const olderUsers = users.get((user) => user.age > 30);
`Compatibility
Tona DB mini is a very flexible JavaScript/TypeScript module: it works in Node.js (backend, scripts, serverless), in Deno, with the older CommonJS format (
require), and even with a TypeScript runtime like tsx without a build step. In short, it fits smoothly into most modern or existing stacks.| Environment / stack | Supported? | Usage notes |
| ------------------------ | ---------- | --------------------------------------------- |
| Node.js | ✅ | Backend apps, scripts, serverless |
| Deno | ✅ | URL imports, secure runtime |
| CommonJS (
require) | ✅ | No need to migrate to ES Modules |
| TS runtime (tsx) | ✅ | Run TypeScript directly, no build step needed |
$3
`js
const db = require("tona-db-mini").default;const users = db.collection("users");
// Add a new user
users.add({ name: "John Doe", age: 30 });
// Get user by name
const user = users.get({ name: "John Doe" });
``