{"id":23503039,"url":"https://github.com/iamevanyt/electron-datastore","last_synced_at":"2026-02-02T11:35:29.229Z","repository":{"id":267992449,"uuid":"902978834","full_name":"iamEvanYT/electron-datastore","owner":"iamEvanYT","description":"Simple and secure electron store with template-based data reconciliation","archived":false,"fork":false,"pushed_at":"2024-12-13T20:44:54.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T22:44:04.125Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamEvanYT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-12-13T17:03:07.000Z","updated_at":"2024-12-13T20:44:57.000Z","dependencies_parsed_at":"2024-12-13T18:37:23.121Z","dependency_job_id":"ab95f539-2f22-478b-8281-810eba469ca5","html_url":"https://github.com/iamEvanYT/electron-datastore","commit_stats":null,"previous_names":["iamevanyt/electron-datastore"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamEvanYT%2Felectron-datastore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamEvanYT%2Felectron-datastore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamEvanYT%2Felectron-datastore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamEvanYT%2Felectron-datastore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamEvanYT","download_url":"https://codeload.github.com/iamEvanYT/electron-datastore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239167368,"owners_count":19593221,"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","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":"2024-12-25T08:13:11.627Z","updated_at":"2025-10-31T09:31:02.760Z","avatar_url":"https://github.com/iamEvanYT.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-datastore\n\nSimple and secure electron store with template-based data reconciliation, dot notation access, and encryption support.\n\n## Installation\n\n```bash\nnpm install electron-datastore\n```\n\n## Usage\n\n```typescript\nimport { Store } from \"electron-datastore\";\n\ninterface FrecencyData {\n  count: number;\n  lastAccessed: number;\n}\n\ninterface FrecencyStore {\n  commands: Record\u003cstring, FrecencyData\u003e;\n  settings: {\n    maxItems: number;\n  };\n}\n\n// Create a store instance with a template\nconst store = new Store\u003cFrecencyStore\u003e({\n  name: \"commands-frecency\",\n  template: {\n    commands: {},\n    settings: {\n      maxItems: 100,\n    },\n  },\n  // Optional: custom working directory\n  cwd: \"/custom/path\",\n  // Optional: encryption key\n  encryptionKey: \"your-secret-key\",\n  // Optional: enable/disable dot notation access (default: true)\n  accessPropertiesByDotNotation: true,\n  // Optional: enable/disable auto reconciliation on load (default: true)\n  autoReconcile: true,\n});\n\n// Set data (will be reconciled with template)\nstore.set(\"commands.some-command\", {\n  count: 1,\n  lastAccessed: Date.now(),\n});\n\n// Get data\nconst someCommand = store.get(\"commands.some-command\");\n\n// Set multiple values at once\nstore.setAll({\n  commands: {\n    \"command-1\": { count: 1, lastAccessed: Date.now() },\n    \"command-2\": { count: 2, lastAccessed: Date.now() },\n  },\n});\n\n// Reset a key to template value\nstore.delete(\"settings.maxItems\");\n\n// Delete a field entirely\nstore.deleteField(\"commands.some-command\");\n\n// Reset entire store to template\nstore.clear();\n\n// Manually reconcile with template\nstore.reconcile();\n\n// Access entire store\nconsole.log(store.store);\n\n// Get store file path\nconsole.log(store.path);\n```\n\n## API\n\n### `Store\u003cT\u003e`\n\n#### Constructor Options\n\n- `name` (required): Name of the store file (without extension)\n- `template` (required): Template object that defines the structure and default values\n- `cwd` (optional): Custom working directory. Defaults to `app.getPath('userData')`\n- `encryptionKey` (optional): Key for encrypting the store data\n- `accessPropertiesByDotNotation` (optional): Whether to allow accessing nested properties using dot notation. Defaults to `true`\n- `autoReconcile` (optional): Whether to automatically reconcile data with template on load. Defaults to `true`\n\n#### Methods\n\n- `get(key: K): T[K]`: Get value for a key\n- `get\u003cP extends Path\u003cT\u003e\u003e(path: P): PathValue\u003cT, P\u003e`: Get value using dot notation\n- `set\u003cK extends keyof T\u003e(key: K, value: T[K]): void`: Set value for a key\n- `set\u003cP extends Path\u003cT\u003e\u003e(path: P, value: PathValue\u003cT, P\u003e): void`: Set value using dot notation\n- `setAll(data: Partial\u003cT\u003e): void`: Set multiple values at once\n- `delete\u003cK extends keyof T\u003e(key: K): void`: Reset key to template value\n- `delete\u003cP extends Path\u003cT\u003e\u003e(path: P): void`: Reset value to template value using dot notation\n- `clear(): void`: Reset entire store to template\n- `reconcile(): void`: Manually reconcile the current data with the template\n- `store: T`: Get the entire store data\n- `path: string`: Get the store file path\n\n## Template-based Reconciliation\n\nThe store uses the provided template to:\n\n1. Define the initial state\n2. Validate and reconcile data structure\n3. Provide default values for missing fields\n4. Reset deleted keys to their template values\n\n## Dot Notation Access\n\nWhen enabled, you can access and modify nested properties using dot notation:\n\n```typescript\nstore.get(\"settings.theme.primary\");\nstore.set(\"settings.theme.primary\", \"#000000\");\n```\n\n## Security\n\nData can be optionally encrypted using AES-256-CBC encryption. When encryption is enabled, the data is stored in an encrypted format and decrypted only when accessed through the API.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamevanyt%2Felectron-datastore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamevanyt%2Felectron-datastore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamevanyt%2Felectron-datastore/lists"}