{"id":19025736,"url":"https://github.com/humphreyja/objectdb","last_synced_at":"2026-04-30T09:30:19.228Z","repository":{"id":42267914,"uuid":"267113966","full_name":"humphreyja/ObjectDB","owner":"humphreyja","description":"A database for javascript objects. References, indexes, and referencial integrity","archived":false,"fork":false,"pushed_at":"2022-12-11T07:37:32.000Z","size":1238,"stargazers_count":0,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T02:20:48.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/humphreyja.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}},"created_at":"2020-05-26T17:55:59.000Z","updated_at":"2020-06-09T17:41:17.000Z","dependencies_parsed_at":"2023-01-26T18:16:26.209Z","dependency_job_id":null,"html_url":"https://github.com/humphreyja/ObjectDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2FObjectDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2FObjectDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2FObjectDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/humphreyja%2FObjectDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/humphreyja","download_url":"https://codeload.github.com/humphreyja/ObjectDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240072131,"owners_count":19743526,"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-11-08T20:44:28.278Z","updated_at":"2026-04-30T09:30:19.176Z","avatar_url":"https://github.com/humphreyja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObjectDB\n\nFlux/React framework for creating any document, just define a few DOM components to transform into the document.\n\nSee an example of how to generate Spreadsheets https://github.com/humphreyja/sample-doc-flux-spreadsheets\n\n# Examples\n\n### Create the data model and populate the database\n```js\n\n// Create data model\nObjectDB.addTable('users');\nObjectDB.addTable('tasks');\n\nObjectDB.addUniqueIndex('users.email');\nObjectDB.addIndex('tasks.completed');\nObjectDB.addReference('tasks.user_id', 'users.task_ids', { scope: d =\u003e !d.parent_task_id });\nObjectDB.addReference('tasks.parent_task_id', 'tasks.task_ids', { scope: d =\u003e !!d.parent_task_id });\n\n\n\nconst data = {\n  users: {\n    1: { id: 1, email: 'johndoe@gmail.com' }\n  },\n  tasks: {\n    1: { id: 1, name: 'Clean House', completed: false, user_id: 1, parent_task_id: null },\n    2: { id: 2, name: 'Wash Dishes', completed: false, user_id: 1, parent_task_id: 1 },\n    3: { id: 3, name: 'Do Laundry',completed: true, user_id: 1, parent_task_id: 1 },\n  }\n}\n\n// Build the database\nObjectDB.rebuildIndexes(data);\n```\n\n**Important: Data is not stored in database**. The database only contains indexes\n\n\n### Assign References to a record\n```js\nconst user = ObjectDB.assignReferences('users', data.users[1]);\nconsole.log(user);\n// =\u003e { id: 1, email: 'johndoe@gmail.com', task_ids: [1] }\n\nconst task = ObjectDB.assignReferences('tasks', data.tasks[1]);\nconsole.log(task);\n// =\u003e { id: 1, name: 'Clean House', task_ids: [2, 3], ... }\n```\n\n### Search indexes\n```js\nconsole.log(ObjectDB.searchIndex('users.email', 'johndoe@gmaill.com'));\n// =\u003e 1\n\nconsole.log(ObjectDB.searchIndex('tasks.completed', false));\n// =\u003e [1, 2]\n```\n\n### Cascade changes\nFind the records that should be deleted if you delete the provided record.\n```js\n// cascade creates a changeset containing the records that need to be deleted\nconst changeset = ObjectDB.cascade('users', data.users[1]);\nconsole.log(changeset);\n// =\u003e { users: { 1: {}}, tasks: { 1: {}, 2: {}, 3: {}}}\n\n// Rebuild the indexes by providing the original(or cloned) dataset and the changeset as the second argument\nObjectDB.rebuildIndexes(data, changeset);\n\n// Finally, delete the records\nObject.keys(changeset).forEach((table) =\u003e {\n  Object.keys(changeset[tabe]).forEach((id) =\u003e {\n    delete data[table][id];\n  });\n});\n```\n\n## Development\n[Clone](https://help.github.com/articles/cloning-a-repository/) this repo, and begin committing changes. PRs are preferred over committing directly to master.\n\nTo run tests locally on your machine, run the following:\n```bash\nyarn run test\n```\n\nTo preview documentation locally on your machine, run the following:\n```bash\nyarn run build-docs\n```\n\nAfter merging your pull request, consider updating the documentation with the following command:\n```bash\nyarn run publish-docs\n```\n\nTo deploy a new version to NPM, bump the version number, commit/merge to `master`, and run the following:\n```bash\nyarn run clean\nyarn run build\n\n# Either NPM\nnpm publish\n# Or Yarn, they do the same thing\nyarn publish\n```\n\n## License\nThis project is [MIT licensed](https://github.com/HarvestProfit/DocFlux/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphreyja%2Fobjectdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhumphreyja%2Fobjectdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhumphreyja%2Fobjectdb/lists"}