{"id":25421468,"url":"https://github.com/nightdevilpt/react-indexeddb-kit","last_synced_at":"2025-10-03T14:08:05.499Z","repository":{"id":277830214,"uuid":"933655365","full_name":"NightDevilPT/react-indexeddb-kit","owner":"NightDevilPT","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-16T12:15:37.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T19:04:49.047Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NightDevilPT.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-16T11:58:40.000Z","updated_at":"2025-02-16T12:15:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"e99ce68f-74b8-4db8-abe6-9436ae020650","html_url":"https://github.com/NightDevilPT/react-indexeddb-kit","commit_stats":null,"previous_names":["nightdevilpt/react-indexeddb-kit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NightDevilPT/react-indexeddb-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NightDevilPT%2Freact-indexeddb-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NightDevilPT%2Freact-indexeddb-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NightDevilPT%2Freact-indexeddb-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NightDevilPT%2Freact-indexeddb-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NightDevilPT","download_url":"https://codeload.github.com/NightDevilPT/react-indexeddb-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NightDevilPT%2Freact-indexeddb-kit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269976794,"owners_count":24506467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-16T20:48:46.541Z","updated_at":"2025-10-03T14:08:05.397Z","avatar_url":"https://github.com/NightDevilPT.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-indexeddb-kit\n\nA TypeScript-based React IndexedDB wrapper that provides seamless CRUD operations and schema validation for your web applications.\n\n## Features\n\n- 🚀 Full TypeScript support\n- 💾 Simple and intuitive IndexedDB operations\n- 🔍 Advanced querying capabilities\n- ✨ Schema validation\n- 🎯 React hooks and context for easy integration\n- 📦 Built-in connection management\n- 🛡️ Type-safe database operations\n\n\u003e **Note:** Relationship data querying using `include` is coming soon! This feature will allow you to easily fetch related records across different stores. If you'd like to track this feature or report issues, please visit our [GitHub Issues](https://github.com/NightDevilPT/react-indexeddb-kit/issues).\n\n## Installation\n\n```bash\nnpm install react-indexeddb-kit\n# or\nyarn add react-indexeddb-kit\n```\n\n## Quick Start\n\n### 1. Define Your Schema\n\n```typescript\nimport { Schema } from 'react-indexeddb-kit';\n\nconst schema: Schema = {\n  models: [\n    {\n      name: 'users',\n      fields: {\n        id: { type: 'number', required: true },\n        name: { type: 'string', required: true },\n        email: { type: 'string', required: true, unique: true },\n        age: { type: 'number' },\n        createdAt: { type: 'date', default: new Date() }\n      }\n    }\n  ]\n};\n```\n\n### 2. Set Up the Provider\n\n```tsx\nimport { ReactIndexDBProvider } from 'react-indexeddb-kit';\n\nfunction App() {\n  return (\n    \u003cReactIndexDBProvider dbName=\"myApp\" schema={schema}\u003e\n      \u003cYourComponents /\u003e\n    \u003c/ReactIndexDBProvider\u003e\n  );\n}\n```\n\n### 3. Use the Database in Your Components\n\n```tsx\nimport { useReactIndexDB } from 'react-indexeddb-kit';\n\nfunction UserComponent() {\n  const { client } = useReactIndexDB();\n\n  const createUser = async () =\u003e {\n    try {\n      const users = client.model('users');\n      const newUser = await users.create({\n        name: 'John Doe',\n        email: 'john@example.com',\n        age: 25\n      });\n      console.log('User created:', newUser);\n    } catch (error) {\n      console.error('Error creating user:', error);\n    }\n  };\n\n  return (\n    \u003cbutton onClick={createUser}\u003e\n      Create User\n    \u003c/button\u003e\n  );\n}\n```\n\n## API Reference\n\n### ReactIndexDBProvider\n\nThe provider component that initializes the database connection.\n\n```tsx\n\u003cReactIndexDBProvider\n  dbName=\"myApp\"\n  schema={schema}\n\u003e\n  {children}\n\u003c/ReactIndexDBProvider\u003e\n```\n\n### useReactIndexDB\n\nA hook to access the IndexedDB client within components.\n\n```typescript\nconst { client, error } = useReactIndexDB();\n```\n\n### Database Operations\n\n#### Create\n\n```typescript\nconst newRecord = await client.model('modelName').create({\n  field1: 'value1',\n  field2: 'value2'\n});\n```\n\n#### Find Many\n\n```typescript\nconst records = await client.model('modelName').findMany({\n  where: { field: 'value' },\n  orderBy: { field: 'fieldName', direction: 'asc' },\n  limit: 10,\n  skip: 0,\n  select: { field1: true, field2: true }\n});\n```\n\n#### Find Unique\n\n```typescript\nconst record = await client.model('modelName').findUnique(id, {\n  select: { field1: true, field2: true }\n});\n```\n\n#### Update\n\n```typescript\nconst updatedRecord = await client.model('modelName').update(id, {\n  field1: 'newValue'\n});\n```\n\n#### Delete\n\n```typescript\nawait client.model('modelName').delete(id);\n```\n\n## Query Options\n\nThe `findMany` method supports various query options:\n\n```typescript\ninterface QueryOptions {\n  where?: Record\u003cstring, any\u003e;           // Filter conditions\n  include?: string[];                    // Related records to include\n  orderBy?: {                           // Sorting options\n    field: string;\n    direction: 'asc' | 'desc';\n  };\n  skip?: number;                        // Pagination offset\n  limit?: number;                       // Pagination limit\n  select?: Record\u003cstring, true\u003e;        // Fields to select\n}\n```\n\n## Schema Definition\n\n```typescript\ninterface Schema {\n  models: ModelDefinition[];\n}\n\ninterface ModelDefinition {\n  name: string;\n  fields: Record\u003cstring, FieldDefinition\u003e;\n}\n\ninterface FieldDefinition {\n  type: 'string' | 'number' | 'boolean' | 'date' | 'object' | 'array';\n  required?: boolean;\n  unique?: boolean;\n  default?: any;\n  references?: {\n    model: string;\n    field: string;\n  };\n}\n```\n\n## Error Handling\n\nThe package provides two main error types:\n\n- `DatabaseError`: For database operation failures\n- `ValidationError`: For schema validation failures\n\n```typescript\ntry {\n  await client.model('users').create(userData);\n} catch (error) {\n  if (error instanceof ValidationError) {\n    console.error('Validation failed:', error.message);\n  } else if (error instanceof DatabaseError) {\n    console.error('Database operation failed:', error.message);\n  }\n}\n```\n\n## License\n\nMIT © [NightDevilPT]\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightdevilpt%2Freact-indexeddb-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightdevilpt%2Freact-indexeddb-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightdevilpt%2Freact-indexeddb-kit/lists"}