
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
Collie-DB is a simple JSON database package that provides basic database functionalities. It allows you to create, read, update, and delete data in JSON format. This package is designed to be easy to use and understand, making it suitable for small projects and applications.
You can install the package using npm:
npm install collie-db
First, import the database class into your project:
import DataBase from "collie-db";
const db = new DataBase({
tables: [{ name: "users", mod: "users.json" }],
});
| option | description | type | default |
|---|---|---|---|
| timeoutsTable | Table name for timeouts. | string | "timeouts" |
| autoSave | Indicates whether it will be saved automatically. | boolean | true |
| tables | List of tables in the database. | Table[] | [{ name: "main", mod: "main.json" }] |
| mod | Database directory path. | string | "./database/" |
Before using the database, you need to initialize it. You can do this asynchronously:
void (async function init() {
await db.init();
console.log("DataBase initialized and ready to use!");
})();
You can set data in the database using the set method:
// DataBase.set<T>(table: string | undefined, key: string | string[], value: T, emit?: boolean): T
db.set("users", "JonhDoe", { name: "John Doe", age: 30 });
To retrieve data, use the get method:
// DataBase.get<T extends unknown, K extends string | string[] = string, R = GetFieldType<T, K>>(table: string | undefined, key: K, dvalue?: R): R | undefined | null
const user = db.get("users", "JonhDoe");
console.log(user); // Output: { name: 'John Doe', age: 30 }
Update existing data using the set method:
db.set("users", "JonhDoe", { name: "John Doe", age: 31 });
Update existing data using the edit method:
// DataBase.edit<T>(table: string | undefined, key: string | string[], predicate: (value: T, key: string | string[]) => T, force?: boolean, emit?: boolean): boolean
db.edit("users", "JonhDoe", function (value) {
value.job = null; // ÂżChamban't?
return value;
});
Remove data from the database with the delete method:
// DataBase.delete(table: string | undefined, key: string): true
db.delete("users", "JonhDoe");
The database also supports timeouts. You can set a timeout for a specific piece of data:
// DataBase.timeout<T = unknown>(value: T, time: number, id?: string, table?: string): T
db.timeout(
"This will disappear after 5 seconds",
5000,
"unique-id" // If you don't put something, the dabase generates a random token.
);
The database emits events when data is updated, deleted, or when a timeout expires. You can subscribe to these events:
db.on("update", function (key, value, table) {
console.log(`Data updated: ${key} in table ${table}`);
});
db.on("delete", function (key, table) {
console.log(`Data deleted: ${key} from table ${table}`);
});
db.on("expires", function (data) {
console.log(`Timeout expired for data: ${data}`);
});
The database supports auto-saving, which means it will automatically save changes to the JSON files:
const db = new Database({ autoSave: true });
By default, the database will use the main table. You can customize table names and file paths when initializing the database.
Feel free to contribute to this project by reporting issues or creating pull requests. Your contributions are highly appreciated!
FAQs
A Simple JSON DB
The npm package collie-db receives a total of 1 weekly downloads. As such, collie-db popularity was classified as not popular.
We found that collie-db demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.