{"id":21569428,"url":"https://github.com/naturalcycles/github-db","last_synced_at":"2025-04-10T14:06:55.127Z","repository":{"id":37173325,"uuid":"262867785","full_name":"NaturalCycles/github-db","owner":"NaturalCycles","description":"GitHub branch as a Database","archived":false,"fork":false,"pushed_at":"2024-01-02T22:03:28.000Z","size":367596,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T10:18:59.766Z","etag":null,"topics":["commondb","gh-data","github"],"latest_commit_sha":null,"homepage":"","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/NaturalCycles.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}},"created_at":"2020-05-10T20:15:29.000Z","updated_at":"2024-02-02T18:17:35.000Z","dependencies_parsed_at":"2022-06-24T05:09:27.314Z","dependency_job_id":null,"html_url":"https://github.com/NaturalCycles/github-db","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fgithub-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fgithub-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fgithub-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fgithub-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaturalCycles","download_url":"https://codeload.github.com/NaturalCycles/github-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231904,"owners_count":21069425,"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":["commondb","gh-data","github"],"created_at":"2024-11-24T11:09:28.652Z","updated_at":"2025-04-10T14:06:55.109Z","avatar_url":"https://github.com/NaturalCycles.png","language":"TypeScript","readme":"## @naturalcycles/github-db\n\n\u003e GitHub branch as a Database\n\n[![npm](https://img.shields.io/npm/v/@naturalcycles/github-db/latest.svg)](https://www.npmjs.com/package/@naturalcycles/github-db)\n[![min.gz size](https://badgen.net/bundlephobia/minzip/@naturalcycles/github-db)](https://bundlephobia.com/result?p=@naturalcycles/github-db)\n[![](https://circleci.com/gh/NaturalCycles/github-db.svg?style=shield\u0026circle-token=123)](https://circleci.com/gh/NaturalCycles/github-db)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n# Intro\n\nStore your data for free in GitHub repo branch. Similar to `gh-pages`, but for data.\n\nImplements [CommonDB](https://github.com/NaturalCycles/db-lib) interface.\n\nStore as `*.ndjson` (newline-delimited json), or `*.ndjson.gz` (gzipped), or `*.sqlite` (binary).\n\nPush to preserve git commit history or force-push to reset history and only store the recent state.\n\n# Example\n\n```typescript\nconst db = new FileDB({\n  plugin: new GithubPersistencePlugin({\n    token: 'YOUR_GITHUB_TOKEN',\n    repo: 'NaturalCycles/github-db',\n  }),\n})\n\nconst items = [\n  { id: 'id1', a: 'a1' },\n  { id: 'id2', a: 'a2' },\n]\n\nawait db.saveBatch('TEST_TABLE', items)\n```\n\nIt will create, commit and push `data/TEST_TABLE.ndjson` file to the repo/branch that you've\nspecified (branch defaults to `gh-data`, similarly to `gh-pages`).\n\nNext saves will be either new commits, or force-push of new commit over previous (with\n`forcePush: true` option).\n\nCurrently, it needs some preparation steps to work (create empty branch), described further down.\n\n# Prepare an empty branch to store your data\n\nReplace `git@github.com:NaturalCycles/github-db.git` with your repo.\n\nReplace `gh-data` with the desired branch name (but `gh-data` is the default).\n\n```\nmkdir data \u0026\u0026 cd data\ngit clone git@github.com:NaturalCycles/github-db.git ./\ngit checkout --orphan gh-data\ngit reset --hard\ngit commit --allow-empty -m \"chore: init empty data branch\"\ngit push --set-upstream origin gh-data\n```\n\n# TODO\n\n- [ ] .ndjson.gzip option\n- [ ] .sqlite option\n- [ ] command to vacuum/force-push all commits in gh-data into one\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalcycles%2Fgithub-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaturalcycles%2Fgithub-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalcycles%2Fgithub-db/lists"}