todo-app-engine
v1.0.3
Published
A lightweight, type-safe CRUD engine for managing todo items using IndexedDB.
Downloads
29
Maintainers
Readme
📝 Todo App Engine
A lightweight, type-safe CRUD engine for managing todo items using IndexedDB — perfect for offline-capable React and TypeScript applications.
🚀 Features
- ⚡ Simple CRUD operations
- 🧱 Built on modern idb wrapper
- 💾 Persistent local storage using IndexedDB
- 🧩 Fully typed with TypeScript
- ⚙️ Works seamlessly in React, Next.js, or plain JS projects
📦 Installation
npm install todo-app-engine
# or
yarn add todo-app-engine📦 Usage Example
import { Todo, TodoEngine } from "todo-app-engine";
await todos.init();
// Add a todo
const task = await todos.add("Buy groceries");
console.log("Added:", task);
// Update a todo
await todos.update(task.id!, "Buy groceries and cook dinner");
// Mark as complete
await todos.complete(task.id!, true);
// List all todos
const all = await todos.listAll();
console.log("All Todos:", all);
// Delete a todo
await todos.delete(task.id!);🧩 Api Reference
| Method | Description |
| -------------------------------------- | -------------------------------------------------------------- |
| init() | Initializes the IndexedDB database and creates the todo store. |
| add(text: string) | Adds a new todo item. |
| update(id: number, text: string) | Updates an existing todo item. |
| complete(id: number, done?: boolean) | Marks a todo as complete or incomplete. |
| delete(id: number) | Deletes a todo by ID. |
| listAll() | Returns all stored todos. |
| get(id: number) | Retrieves a todo by its ID. |
| clear() | Clears all todos from the database. |
🧾 Types
// Todo Item
interface Todo {
id?: number;
text: string;
done?: boolean;
createdAt?: number;
updatedAt?: number;
}
// Config
interface TodoEngineConfig {
dbName?: string;
storeName?: string;
}