{"id":28559235,"url":"https://github.com/toastdriven/localtable","last_synced_at":"2025-10-17T16:15:31.956Z","repository":{"id":57290499,"uuid":"433253003","full_name":"toastdriven/localtable","owner":"toastdriven","description":"A thin database-like wrapper over `window.localStorage`.","archived":false,"fork":false,"pushed_at":"2021-12-04T05:47:53.000Z","size":419,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-09T06:45:20.028Z","etag":null,"topics":["browser","database","javascript","localstorage","sessionstorage"],"latest_commit_sha":null,"homepage":"https://toastdriven.github.io/localtable/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toastdriven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-30T01:29:12.000Z","updated_at":"2024-12-07T13:26:16.000Z","dependencies_parsed_at":"2022-08-28T07:00:13.671Z","dependency_job_id":null,"html_url":"https://github.com/toastdriven/localtable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/toastdriven/localtable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Flocaltable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Flocaltable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Flocaltable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Flocaltable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toastdriven","download_url":"https://codeload.github.com/toastdriven/localtable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Flocaltable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279373944,"owners_count":26157800,"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-10-17T02:00:07.504Z","response_time":56,"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":["browser","database","javascript","localstorage","sessionstorage"],"created_at":"2025-06-10T08:36:19.610Z","updated_at":"2025-10-17T16:15:31.921Z","avatar_url":"https://github.com/toastdriven.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# localtable\n\nA thin database-like wrapper over `window.localStorage`.\n\nYou create a table (or tables) to store many similar rows in, \u0026 `localtable`\nhandles all the usual CRUD/database-style operations.\n\n\n## Usage\n\n```javascript\nimport { LocalTable } from \"localtable\";\n\nconst records = new LocalTable(\n    window.localStorage, // ...or 'window.sessionStorage', or any other 'Storage'-like object.\n    \"records\", // The name of the table.\n    {\n        fields: [\n            { name: \"firstName\", type: \"str\" },\n            { name: \"lastName\", type: \"str\" },\n            { name: \"createdAt\", type: \"timestamp\" },\n            { name: \"loginCount\", type: \"int\", default: 0, required: false },\n        ]\n    }\n);\n\nconsole.log(`Initial count: ${records.count()}`);\n\nrecords.insert(\n    1, // An ID, which can be any unique JSON-serializable identifier\n    {\n        firstName: \"Daniel\",\n        lastName: \"Lindsley\",\n        createdAt: Date.now(),\n    }\n);\nrecords.insert(2, {\n    firstName: \"Jane\",\n    lastName: \"Doe\",\n    createdAt: Date.now(),\n});\n\nconsole.log(`New count: ${records.count()}`);\n\n// Pull specific rows by ID.\nlet dl = records.get(1);\n\nconsole.log(`Hello, ${dl.firstName}!`);\n\n// Update information.\nrecords.update(2, {\n    firstName: \"Jenn\",\n    loginCount: 3,\n});\n\n// Grab all the rows in the table \u0026 iterate.\nfor(const record of records.all()) {\n    console.log(`Saw #${record.id}: ${record.firstName} - ${record.loginCount}`);\n}\n\n// Or filter down to specific data.\nconst filtered = records.filter({\n    createdAt: {\"\u003e=\": Date.parse(\"2021-11-24\")},\n    loginCount: {\"\u003c\": \"2\"},\n});\nconsole.log(filtered.length); // 1\nconsole.log(filtered[0].firstName); // \"Daniel\"\nconsole.log(filtered[0].loginCount); // 0\n\n// Delete a single row.\nrecords.delete(1);\n\n// Or drop the whole table.\nrecords.drop();\n```\n\n\n## API\n\n`const table = new LocalTable(store, tableName, options)` - Creates a new\n`LocalTable`.\n\n`table.create()` - Sets up the table in the `storage`.\n\n`table.drop()` - Deletes the table from `storage`.\n\n`table.get(id)` - Fetches a row from the table by ID.\n\n`table.insert(id, data)` - Inserts a new row into the table.\n\n`table.update(id, data)` - Updates (or inserts) a row in the table.\n\n`table.delete(id)` - Deletes a row from the table.\n\n`table.exists(id)` - Checks if a row is present in the table. Returns `true`\nor `false`.\n\n`table.count()` - Returns a count of the number of records in the table.\n\n`table.all()` - Returns all records in the table.\n\n`table.filter(filterDataOrFunc)` - Returns a filtered set of data from the\ntable. If a plain object is provided, an `AND`-style filtering of the data is\nperformed. If a function is provided, it should take a single `data` parameter\n\u0026 should return `true`/`false` if the row should be included in the output.\n\n\n## Testing\n\n`npm test`\n\n\n## Generating Docs\n\n`jsdoc -r -d ~/Desktop/out --package package.json --readme README.md src`\n\n\n## License\n\nNew BSD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Flocaltable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoastdriven%2Flocaltable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Flocaltable/lists"}