{"id":15373134,"url":"https://github.com/otiai10/chromestorm","last_synced_at":"2025-06-11T20:05:25.727Z","repository":{"id":65001312,"uuid":"579876860","full_name":"otiai10/chromestorm","owner":"otiai10","description":"ORM for Chrome Extension with `chrome.storage` API","archived":false,"fork":false,"pushed_at":"2023-01-06T01:47:33.000Z","size":195,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-16T09:44:54.916Z","etag":null,"topics":["chrome-extension","chrome-storage","chrome-storage-api","orm"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/chromestorm","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/otiai10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-19T06:46:57.000Z","updated_at":"2023-12-31T02:28:10.000Z","dependencies_parsed_at":"2023-01-13T15:12:33.356Z","dependency_job_id":null,"html_url":"https://github.com/otiai10/chromestorm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/otiai10/chromestorm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Fchromestorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Fchromestorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Fchromestorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Fchromestorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otiai10","download_url":"https://codeload.github.com/otiai10/chromestorm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Fchromestorm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259329501,"owners_count":22841445,"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":["chrome-extension","chrome-storage","chrome-storage-api","orm"],"created_at":"2024-10-01T13:54:21.459Z","updated_at":"2025-06-11T20:05:25.683Z","avatar_url":"https://github.com/otiai10.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chromestorm\n\n[![version](https://img.shields.io/npm/v/chromestorm)](https://www.npmjs.com/package/chromestorm)\n[![downloads](https://img.shields.io/npm/dt/chromestorm)](https://www.npmjs.com/package/chromestorm)\n[![Node.js CI](https://github.com/otiai10/chromestorm/actions/workflows/node.yml/badge.svg)](https://github.com/otiai10/chromestorm/actions/workflows/node.yml)\n[![Chrome E2E Test](https://github.com/otiai10/chromestorm/actions/workflows/chrome-test.yml/badge.svg)](https://github.com/otiai10/chromestorm/actions/workflows/chrome-test.yml)\n[![codecov](https://codecov.io/github/otiai10/chromestorm/branch/main/graph/badge.svg?token=z3Nzs6xVGF)](https://codecov.io/github/otiai10/chromestorm)\n[![Maintainability](https://api.codeclimate.com/v1/badges/df8271f73cd0791369f6/maintainability)](https://codeclimate.com/github/otiai10/chromestorm/maintainability)\n\nORM-like API provider for `chrome.storage`.\n\nNote: If you want it for `window.localStorage`, check [localstorm](https://github.com/otiai10/localstorm).\n\n# Example Usage\n\n```typescript\n// In your background.{ts|js}\n\nimport { Model } from \"chromestrom\";\n\n// Define your model,\nclass Player extends Model {\n    public name: string;\n    public age: number;\n    greet(): string {\n        return `Hello, my name is ${this.name}!`;\n    }\n}\n\n// and use it.\n(async () =\u003e {\n    // Save records to chrome.storage.\n    const x = await Player.create({ name: \"otiai10\", age: 17 });\n    const y = await Player.create({ name: \"hiromu\", age: 32 });\n\n    // Retrieve records from chrome.storage.\n    console.log(await Player.list()); // 2\n    console.log(await Player.find(x._id)); // Player {name:\"otiai10\", age: 17}\n})();\n```\n\n# Basic APIs\n\n## Defining your model class\n\n```typescript\nimport { Model } from \"chromestorm\";\n\nclass Player extends Model {\n    // You can define your own members of your model.\n    public name: string;\n    public age: number;\n\n    // Optional: If you'd like to minify/mangle your JS,\n    // you'd better set the namespace of this mode explicitly.\n    static override __namespace__ = \"Player\";\n}\n```\n\nThat's all to get started. Let's enjoy.\n\n## new\n\nTo construct new model object:\n\n```typescript\nconst john = Player.new({name: \"John\", age: 17});\nconsole.log(john._id); // null\n```\n\nNOTE: `new` does NOT save constructed object yet. Please use `save` to make it persistent.\n\n## save\n\nTo save unsaved obejct to `chrome.storage`:\n\n```typescript\nawait john.save();\nconsole.log(john._id); // 1672363730924\n```\n\nNow `_id` is generated because it's saved on `chrome.storage`.\n\n## create\n\nJust a short-hand of `new` and `save`:\n\n```typescript\nconst paul = await Player.create({name: \"Paul\", age: 16});\nconsole.log(paul._id); // 1672968746499\n```\n\n## list\n\nTo list up all entities saved on this namespace:\n\n```typescript\nconst all = await Player.list();\nconsole.log(all.length);  // 2\nconsole.log(all[0].name); // John\n```\n\n## dict\n\nTo get all entities saved on this namespace as a dict:\n\n```typescript\nconst dict = await Player.dict();\nconsole.log(Object.entries(dict));\n// [[1672363730924, Player], [1672968746499, Player]]\n```\n\n## find\n\nTo find specific object saved on this namespace:\n\n```typescript\nconst found = await Player.find(\"1672968746499\");\nconsole.log(found?.name); // Paul\n```\n\n## filter\n\nTo find objects which should match a specific criteria:\n\n```typescript\nconst criteria = (p: Player): bool =\u003e (Player.age \u003e 16);\nconst filtered = await Player.filter(criteria);\nconsole.log(filtered.length); // 1\n```\n\n## update\n\n// TODO:\n\n## delete\n\nTo delete a specific object:\n\n```typescript\nawait john.delete();\nconst found = await Player.find(john._id);\nconsole.log(found); // null\n```\n\n## drop\n\nTo delete all objects saved on this namespace:\n\n```typescript\nawait Player.drop();\nconst list = await Player.list();\nconsole.log(list.length); // 0\n```\n\n# Advanced properties\n\n## schema\n\n// TODO:\n\n# Issues\n\n- https://github.com/otiai10/chromestorm/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotiai10%2Fchromestorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotiai10%2Fchromestorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotiai10%2Fchromestorm/lists"}