{"_id":"@azarov-serge/indexed-db-client","_rev":"4-363e78b8140a55b0dcb94e7b9c0b8a2c","name":"@azarov-serge/indexed-db-client","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@azarov-serge/indexed-db-client","version":"1.0.0","keywords":["indexeddb","orm","client","database","browser","storage","typescript"],"author":{"name":"Sergey Azarov","email":"your-email@example.com"},"license":"MIT","_id":"@azarov-serge/indexed-db-client@1.0.0","maintainers":[{"name":"azarov-serge","email":"s.a.azarov@gmail.com"}],"homepage":"https://github.com/yourusername/indexed-db-client#readme","bugs":{"url":"https://github.com/yourusername/indexed-db-client/issues"},"dist":{"shasum":"912b0b3416710603bba97f9829028d7af3561381","tarball":"https://registry.npmjs.org/@azarov-serge/indexed-db-client/-/indexed-db-client-1.0.0.tgz","fileCount":12,"integrity":"sha512-7zIqtn1ioeYqLWAuuf4o+t1ACwiGvVIrynmu0M0DlfaJ97A5lXiFMf4ul3w8G/OYifCmQNySsL9jBVFxHHKMbA==","signatures":[{"sig":"MEQCID8PSecTjvk3xQRGUN2p0PyqhYiznBRMV8LKZqqMRRoPAiBvv9aue3f//6TJ2jdxJMG8NiUeeIijNy0wBGHPSgEP+w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32114},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ed90e30d2fdbd13a78aede9dac841aadcd6c572d","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","format":"npx prettier \"src/**/*.{js,jsx,ts,tsx}\" --write","prepare":"npm run build","publish:major":"npm run version:major && npm publish","publish:minor":"npm run version:minor && npm publish","publish:patch":"npm run version:patch && npm publish","version:major":"npm version major && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:minor":"npm version minor && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:patch":"npm version patch && git push origin main && git push origin $(npm version --json | jq -r '.[]')","prepublishOnly":"npm run build"},"_npmUser":{"name":"azarov-serge","email":"s.a.azarov@gmail.com"},"repository":{"url":"git+https://github.com/yourusername/indexed-db-client.git","type":"git"},"_npmVersion":"10.5.0","description":"A simple IndexedDB client for working with IndexedDB. Designed as ORM.","directories":{"example":"example"},"_nodeVersion":"20.12.2","_hasShrinkwrap":false,"devDependencies":{"husky":"9.0.11","eslint":"8.57.0","prettier":"3.2.5","typescript":"5.1.6","lint-staged":"15.2.2","@typescript-eslint/parser":"7.2.0"},"_npmOperationalInternal":{"tmp":"tmp/indexed-db-client_1.0.0_1752417701823_0.5534251020004786","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package renamed. Use web-idb-client instead: npm install web-idb-client"},"1.0.1":{"name":"@azarov-serge/indexed-db-client","version":"1.0.1","keywords":["indexeddb","orm","client","database","browser","storage","typescript"],"author":{"name":"Sergey Azarov","email":"your-email@example.com"},"license":"MIT","_id":"@azarov-serge/indexed-db-client@1.0.1","maintainers":[{"name":"azarov-serge","email":"s.a.azarov@gmail.com"}],"homepage":"https://github.com/azarov-serge/indexed-db-client#readme","bugs":{"url":"https://github.com/azarov-serge/indexed-db-client/issues"},"dist":{"shasum":"c570af2edc3e2044317ab7e09b85123b7dd13295","tarball":"https://registry.npmjs.org/@azarov-serge/indexed-db-client/-/indexed-db-client-1.0.1.tgz","fileCount":12,"integrity":"sha512-YxpYlWNSCpQxd58PnwEyBDMxFQqLmd7z7oEbcza0MQD/S2kMdn1S8suXarwiXW+FYjQsk3k6m1y5K3JUp1odsQ==","signatures":[{"sig":"MEUCIQC5yBlgwgp96CFn6qc0GHpC1OawAu0g/iH+ANQjaX3a1gIgGqp7JFo9p6z/SYtc2uoqjnK6c6FskFI44SoqCCL9G6k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32118},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"50ef794f1a19943e5b918bcdd204cd73d8ec795c","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","format":"npx prettier \"src/**/*.{js,jsx,ts,tsx}\" --write","prepare":"npm run build","publish:major":"npm run version:major && npm publish","publish:minor":"npm run version:minor && npm publish","publish:patch":"npm run version:patch && npm publish","version:major":"npm version major && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:minor":"npm version minor && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:patch":"npm version patch && git push origin main && git push origin $(npm version --json | jq -r '.[]')","prepublishOnly":"npm run build"},"_npmUser":{"name":"azarov-serge","email":"s.a.azarov@gmail.com"},"repository":{"url":"git+https://github.com/azarov-serge/indexed-db-client.git","type":"git"},"_npmVersion":"10.5.0","description":"A simple IndexedDB client for working with IndexedDB. Designed as ORM.","directories":{"example":"example"},"_nodeVersion":"20.12.2","_hasShrinkwrap":false,"devDependencies":{"husky":"9.0.11","eslint":"8.57.0","prettier":"3.2.5","typescript":"5.1.6","lint-staged":"15.2.2","@typescript-eslint/parser":"7.2.0"},"_npmOperationalInternal":{"tmp":"tmp/indexed-db-client_1.0.1_1752418311320_0.6717280261458114","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package renamed. Use web-idb-client instead: npm install web-idb-client"},"1.0.2":{"name":"@azarov-serge/indexed-db-client","version":"1.0.2","keywords":["indexeddb","orm","client","database","browser","storage","typescript"],"author":{"name":"Sergey Azarov","email":"your-email@example.com"},"license":"MIT","_id":"@azarov-serge/indexed-db-client@1.0.2","maintainers":[{"name":"azarov-serge","email":"s.a.azarov@gmail.com"}],"homepage":"https://github.com/azarov-serge/indexed-db-client#readme","bugs":{"url":"https://github.com/azarov-serge/indexed-db-client/issues"},"dist":{"shasum":"f0d524a94e2b46634f9d1ecb759c25158c52fe62","tarball":"https://registry.npmjs.org/@azarov-serge/indexed-db-client/-/indexed-db-client-1.0.2.tgz","fileCount":12,"integrity":"sha512-YD5OJgi+9r3ogOFVM57KgOZzGduD3my7y+W3AFJsHdhnQcsIZdMMO1Xw0iD3upWMDOgs5rcYKxSxdfkfkk/kKQ==","signatures":[{"sig":"MEQCICA0ELIDQOM/sHO3S/UCXCngi0cN5KCKtzsjjX3TGAfWAiA0W7a3DqFKEtg/ipk2bowf/3m2mhfxCin4C5tflFkeLQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32267},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"72e013606f5f7862152ded87b0859d940e271796","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","format":"npx prettier \"src/**/*.{js,jsx,ts,tsx}\" --write","prepare":"npm run build","publish:major":"npm run version:major && npm publish","publish:minor":"npm run version:minor && npm publish","publish:patch":"npm run version:patch && npm publish","version:major":"npm version major && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:minor":"npm version minor && git push origin main && git push origin $(npm version --json | jq -r '.[]')","version:patch":"npm version patch && git push origin main && git push origin $(npm version --json | jq -r '.[]')","prepublishOnly":"npm run build"},"_npmUser":{"name":"azarov-serge","email":"s.a.azarov@gmail.com"},"repository":{"url":"git+https://github.com/azarov-serge/indexed-db-client.git","type":"git"},"_npmVersion":"10.5.0","description":"A simple IndexedDB client for working with IndexedDB. Designed as ORM.","directories":{"example":"example"},"_nodeVersion":"20.12.2","_hasShrinkwrap":false,"devDependencies":{"husky":"9.0.11","eslint":"8.57.0","prettier":"3.2.5","typescript":"5.1.6","lint-staged":"15.2.2","@typescript-eslint/parser":"7.2.0"},"_npmOperationalInternal":{"tmp":"tmp/indexed-db-client_1.0.2_1752420340925_0.024178683141131918","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package renamed. Use web-idb-client instead: npm install web-idb-client"}},"time":{"created":"2025-07-13T14:41:41.730Z","modified":"2026-09-05T09:20:41.727Z","1.0.0":"2025-07-13T14:41:42.056Z","1.0.1":"2025-07-13T14:51:51.514Z","1.0.2":"2025-07-13T15:25:41.103Z"},"bugs":{"url":"https://github.com/azarov-serge/indexed-db-client/issues"},"author":{"name":"Sergey Azarov","email":"your-email@example.com"},"license":"MIT","homepage":"https://github.com/azarov-serge/indexed-db-client#readme","keywords":["indexeddb","orm","client","database","browser","storage","typescript"],"repository":{"url":"git+https://github.com/azarov-serge/indexed-db-client.git","type":"git"},"description":"A simple IndexedDB client for working with IndexedDB. Designed as ORM.","maintainers":[{"name":"azarov-serge","email":"s.a.azarov@gmail.com"}],"readme":"# IndexedDbClient\n\nA simple and powerful IndexedDB client for working with IndexedDB in the browser. Designed as an ORM-like interface that makes IndexedDB operations intuitive and type-safe.\n\n> 🇷🇺 [Читать на русском языке](README_RU.md)\n\n## Features\n\n- 🚀 **Simple API** - Intuitive ORM-like interface\n- 🔒 **Type Safety** - Full TypeScript support with generics\n- 📊 **Indexed Queries** - Support for custom indexes and range queries\n- 🔄 **Promise-based** - All operations return promises\n- 🎯 **Flexible Configuration** - Multiple ways to configure the client\n- 🛡️ **Error Handling** - Comprehensive error handling and validation\n\n## Installation\n\n```bash\nnpm install @azarov-serge/indexed-db-client\n```\n\n## Quick Start\n\n```typescript\nimport { IndexedDbClient } from '@azarov-serge/indexed-db-client';\n\n// Define your types\ntype Task = {\n  id: number;\n  name: string;\n  isDone: boolean;\n  createdAt: Date;\n};\n\n// Configure the client\nconst config = {\n  dbName: 'myApp',\n  dbVersion: 1,\n  storageNames: ['tasks'] as const,\n  storeNameToIndexes: {\n    tasks: [\n      { index: 'tasksName', key: 'name' },\n      { index: 'tasksCreatedAt', key: 'createdAt' }\n    ]\n  }\n};\n\n// Create and initialize\nconst client = new IndexedDbClient(config);\nawait client.init();\n\n// Use the client\nconst taskId = await client.from('tasks').insert({\n  name: 'Learn IndexedDB',\n  isDone: false,\n  createdAt: new Date()\n});\n```\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Configuration](#configuration)\n- [API Reference](#api-reference)\n- [Examples](#examples)\n- [Advanced Usage](#advanced-usage)\n- [Error Handling](#error-handling)\n\n## Configuration\n\n### 1. Define Types\n\nFirst, define your storage names and data types:\n\n```typescript\n// types.ts\nexport type StorageName = 'tasks' | 'categories';\n\nexport type Task = {\n  id: number;\n  name: string;\n  isDone: boolean;\n  createdAt: Date;\n  categoryId?: number;\n};\n\nexport type Category = {\n  id: number;\n  name: string;\n  color: string;\n};\n\n// Define index names for type safety\nexport type TaskIndexName = 'tasksName' | 'tasksCreatedAt' | 'tasksCategoryId';\nexport type CategoryIndexName = 'categoriesName';\n```\n\n### 2. Create Configuration\n\n```typescript\n// config.ts\nimport { IDBConfig } from '@azarov-serge/indexed-db-client';\nimport { StorageName, TaskIndexName, CategoryIndexName } from './types';\n\nexport const indexedDbConfig: IDBConfig<StorageName, TaskIndexName | CategoryIndexName> = {\n  dbName: 'myApp',\n  dbVersion: 1,\n  storageNames: ['tasks', 'categories'],\n  storeNameToIndexes: {\n    tasks: [\n      { index: 'tasksName', key: 'name' },\n      { index: 'tasksCreatedAt', key: 'createdAt' },\n      { index: 'tasksCategoryId', key: 'categoryId' }\n    ],\n    categories: [\n      { index: 'categoriesName', key: 'name', unique: true }\n    ]\n  }\n};\n```\n\n### 3. Initialize Client\n\nYou have two ways to configure the client:\n\n**Method 1: Constructor Configuration**\n```typescript\nconst client = new IndexedDbClient(indexedDbConfig);\nawait client.init();\n```\n\n**Method 2: Separate Configuration**\n```typescript\nconst client = new IndexedDbClient();\nawait client.configure(indexedDbConfig).init();\n```\n\n## API Reference\n\n### Constructor\n\n```typescript\nnew IndexedDbClient<StorageName, IndexName>(config?)\n```\n\n- `config` (optional): Initial configuration object\n\n### Methods\n\n#### `configure(config)`\nConfigure the client after instantiation.\n\n```typescript\nclient.configure(config).init();\n```\n\n#### `init()`\nInitialize the database connection.\n\n```typescript\nawait client.init();\n```\n\n#### `from(storageName)`\nSelect a storage to work with. Returns the client for chaining.\n\n```typescript\nclient.from('tasks')\n```\n\n#### `insert<T>(data)`\nInsert a new record. Returns the generated ID.\n\n```typescript\nconst id = await client.from('tasks').insert<Task>({\n  name: 'New Task',\n  isDone: false,\n  createdAt: new Date()\n});\n```\n\n#### `select<T>(params?)`\nSelect records from storage.\n\n```typescript\n// Select all records\nconst allTasks = await client.from('tasks').select<Task>();\n\n// Select with parameters\nconst tasks = await client.from('tasks').select<Task>({\n  key: 'tasksName',\n  value: 'Task Name',\n  count: 10,\n  orderBy: 'desc'\n});\n```\n\n**Select Parameters:**\n- `key`: Index name or 'id' for primary key\n- `value`: Value to search for or IDBKeyRange\n- `count`: Limit number of results\n- `orderBy`: 'asc' (default) or 'desc'\n\n#### `update<T>(data)`\nUpdate an existing record.\n\n```typescript\nawait client.from('tasks').update<Task>({\n  id: 1,\n  name: 'Updated Task',\n  isDone: true,\n  createdAt: new Date()\n});\n```\n\n#### `delete(params)`\nDelete records by ID or index.\n\n```typescript\n// Delete by ID\nawait client.from('tasks').delete({ key: 'id', value: 1 });\n\n// Delete by index\nawait client.from('tasks').delete({ \n  key: 'tasksName', \n  value: 'Task Name' \n});\n```\n\n#### `createStorage(storageName)`\nCreate a new storage (object store).\n\n```typescript\nawait client.createStorage('newStorage');\n```\n\n#### `deleteStorage(storageName)`\nDelete a storage.\n\n```typescript\nawait client.deleteStorage('tasks');\n```\n\n#### `deleteDb()`\nDelete the entire database.\n\n```typescript\nawait client.deleteDb();\n```\n\n### Properties\n\n#### `isInited`\nCheck if the client is initialized.\n\n```typescript\nif (client.isInited) {\n  // Client is ready to use\n}\n```\n\n## Examples\n\n### Basic CRUD Operations\n\n```typescript\nimport { IndexedDbClient } from '@azarov-serge/indexed-db-client';\n\n// Setup\nconst client = new IndexedDbClient(config);\nawait client.init();\n\n// Create\nconst taskId = await client.from('tasks').insert({\n  name: 'Learn TypeScript',\n  isDone: false,\n  createdAt: new Date()\n});\n\n// Read\nconst task = await client.from('tasks').select<Task>({ \n  key: 'id', \n  value: taskId \n});\n\n// Update\nawait client.from('tasks').update({\n  id: taskId,\n  name: 'Learn TypeScript (Updated)',\n  isDone: true,\n  createdAt: new Date()\n});\n\n// Delete\nawait client.from('tasks').delete({ key: 'id', value: taskId });\n```\n\n### Advanced Queries\n\n```typescript\n// Select all tasks ordered by creation date (newest first)\nconst recentTasks = await client\n  .from('tasks')\n  .select<Task>({ orderBy: 'desc' });\n\n// Select first 5 tasks\nconst firstFive = await client\n  .from('tasks')\n  .select<Task>({ count: 5 });\n\n// Select tasks by name\nconst tasksByName = await client\n  .from('tasks')\n  .select<Task>({ \n    key: 'tasksName', \n    value: 'Learn TypeScript' \n  });\n\n// Select tasks created after a specific date\nconst recentTasks = await client\n  .from('tasks')\n  .select<Task>({\n    key: 'tasksCreatedAt',\n    value: IDBKeyRange.lowerBound(new Date('2024-01-01'))\n  });\n\n// Select tasks in a date range\nconst tasksInRange = await client\n  .from('tasks')\n  .select<Task>({\n    key: 'tasksCreatedAt',\n    value: IDBKeyRange.bound(\n      new Date('2024-01-01'),\n      new Date('2024-12-31')\n    )\n  });\n\n// Select tasks by category\nconst tasksByCategory = await client\n  .from('tasks')\n  .select<Task>({\n    key: 'tasksCategoryId',\n    value: 1\n  });\n```\n\n### Working with Multiple Storages\n\n```typescript\n// Insert category\nconst categoryId = await client.from('categories').insert({\n  name: 'Work',\n  color: '#ff0000'\n});\n\n// Insert task with category\nconst taskId = await client.from('tasks').insert({\n  name: 'Complete project',\n  isDone: false,\n  createdAt: new Date(),\n  categoryId: categoryId\n});\n\n// Get all categories\nconst categories = await client.from('categories').select<Category>();\n\n// Get tasks by category\nconst workTasks = await client\n  .from('tasks')\n  .select<Task>({\n    key: 'tasksCategoryId',\n    value: categoryId\n  });\n```\n\n### Error Handling\n\n```typescript\ntry {\n  await client.init();\n  \n  const taskId = await client.from('tasks').insert({\n    name: 'Task',\n    isDone: false,\n    createdAt: new Date()\n  });\n  \n  console.log('Task created with ID:', taskId);\n} catch (error) {\n  console.error('Error:', error);\n  \n  if (error instanceof Error) {\n    switch (error.message) {\n      case 'Config is not exist':\n        console.error('Client not configured');\n        break;\n      case 'DB is not init':\n        console.error('Database not initialized');\n        break;\n      case 'No storage selected':\n        console.error('No storage selected');\n        break;\n      default:\n        console.error('Unknown error:', error.message);\n    }\n  }\n}\n```\n\n## Advanced Usage\n\n### Custom Indexes\n\n```typescript\n// Create unique index\nconst config = {\n  // ... other config\n  storeNameToIndexes: {\n    users: [\n      { index: 'usersEmail', key: 'email', unique: true },\n      { index: 'usersUsername', key: 'username', unique: true }\n    ]\n  }\n};\n\n// Use unique index\nconst user = await client\n  .from('users')\n  .select<User>({ \n    key: 'usersEmail', \n    value: 'user@example.com' \n  });\n```\n\n### Database Versioning\n\n```typescript\n// Increment version to trigger schema updates\nconst config = {\n  dbName: 'myApp',\n  dbVersion: 2, // Increased from 1\n  // ... rest of config\n};\n\n// The client will automatically handle schema migrations\nawait client.init();\n```\n\n### Bulk Operations\n\n```typescript\n// Insert multiple records\nconst tasks = [\n  { name: 'Task 1', isDone: false, createdAt: new Date() },\n  { name: 'Task 2', isDone: false, createdAt: new Date() },\n  { name: 'Task 3', isDone: false, createdAt: new Date() }\n];\n\nconst ids = await Promise.all(\n  tasks.map(task => client.from('tasks').insert(task))\n);\n\n// Delete multiple records\nawait Promise.all(\n  ids.map(id => client.from('tasks').delete({ key: 'id', value: id }))\n);\n```\n\n## Browser Support\n\nThis library works in all modern browsers that support IndexedDB:\n\n- Chrome 23+\n- Firefox 16+\n- Safari 10+\n- Edge 12+\n- Internet Explorer 10+\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n---\n\n> 🇷🇺 [Читать на русском языке](README_RU.md)\n","readmeFilename":"README.md"}