{"id":15482884,"url":"https://github.com/brandonbloom/jseg","last_synced_at":"2025-04-05T21:10:42.594Z","repository":{"id":57284311,"uuid":"46875354","full_name":"brandonbloom/jseg","owner":"brandonbloom","description":"A super simple, in-memory, JS graph database.","archived":false,"fork":false,"pushed_at":"2022-02-25T21:55:42.000Z","size":85,"stargazers_count":479,"open_issues_count":1,"forks_count":11,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-29T17:09:35.532Z","etag":null,"topics":["datomic","graph-database","graphql","json","relay"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/brandonbloom.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":"2015-11-25T17:03:40.000Z","updated_at":"2025-03-13T16:24:17.000Z","dependencies_parsed_at":"2022-09-16T22:41:44.990Z","dependency_job_id":null,"html_url":"https://github.com/brandonbloom/jseg","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/brandonbloom%2Fjseg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fjseg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fjseg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandonbloom%2Fjseg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandonbloom","download_url":"https://codeload.github.com/brandonbloom/jseg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399885,"owners_count":20932880,"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":["datomic","graph-database","graphql","json","relay"],"created_at":"2024-10-02T05:10:15.998Z","updated_at":"2025-04-05T21:10:42.577Z","avatar_url":"https://github.com/brandonbloom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript Entity Graph\n\nAn in-memory graph database for JavaScript data.\n\n\n## Overview\n\n- Entity/Attribute/Value graph-based information model.\n  - Schema enforces relationships, provides unique indexes, and validates data.\n- Operates on plain-old JavaScript objects.\n  - Hierarchical data is flattened on put and reconstituted on get.\n  - Not necessarily just JSON (allows dates, etc).\n- No spooky action at a distance.\n  - Every graph operation makes an implicit defensive copy.\n  - Many of the benefits of immutability without loss of JavaScript idioms.\n\n\n# Status\n\nThis is version 2 with lots of new/improved stuff and is deployed\nin at least one real product. I'm not personally working on that\nproduct anymore, but this version has been pretty stable and\nuseful there, so I don't expect much if any churn. I'm unlikely to\nconsider major feature requests, but bug fixes are still welcome.\n\nSee [the v1 readme][2] for rationale, background, goals, etc.\n\n\n# Usage\n\nThis is just a taste. See [docs](./doc) for more details.\n\n```javascript\nlet jseg = require('jseg');\n\nlet [builder, types] = jseg.newSchema();\n\nbuilder.entity('User');\nbuilder.trait('Likeable');\nbuilder.entity('Comment', types.Likeable);\nbuilder.entity('Link', types.Likeable);\n\nbuilder.finalize({\n\n  attributes: {\n\n    User: {\n      name: types.Text,\n    },\n\n    Comment: {\n      createdAt: types.Time,\n      message: types.Text,\n    },\n\n    Link: {\n      href: types.Key,\n    },\n\n  },\n\n  relationships: [\n\n    [[types.Likeable, 'many', 'likers'],\n     [types.User, 'many', 'likes']],\n\n    [[types.Comment, 'one', 'author'],\n     [types.User, 'many', 'comments', {\n       compare: (a, b) =\u003e Math.sign(a.createdAt - b.createdAt)\n     }]],\n\n  ],\n\n});\n\n\nlet graph = new jseg.Graph(types);\n\ngraph.put({\n\n  type: 'User',\n  lid: 'user:brandonbloom',\n  name: 'Brandon Bloom',\n\n  comments: [\n    {\n      type: 'Comment',\n      lid: 'comment-1',\n      createdAt: new Date('Sat May 21 2016 12:59:48 GMT-0700 (PDT)'),\n      message: 'It is kind of weird to like your own comments.',\n    },\n    {\n      type: 'Comment',\n      lid: 'comment-2',\n      createdAt: new Date('Sat May 21 2016 12:59:51 GMT-0700 (PDT)'),\n      message: 'This is a very important comment.',\n    },\n  ],\n\n  likes: [\n    {\n      type: 'Link',\n      lid: 'link-1',\n      href: 'example.com',\n    },\n    {\n      type: 'Comment',\n      lid: 'comment-1',\n    }\n  ],\n\n});\n\nconsole.log(graph.get('user:brandonbloom'));\n\nconsole.log(graph.get('comment-1', {depth: 3, json: true}));\n\nconsole.log(graph.lookup('Link', 'href', 'example.com'));\n\ngraph.destroy('comment-2');\nconsole.log(graph.get('comment-2'));\n```\n\n\n\n[1]: https://github.com/brandonbloom/jseg/tree/v1\n[2]: https://github.com/brandonbloom/jseg/blob/v1/README.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonbloom%2Fjseg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandonbloom%2Fjseg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandonbloom%2Fjseg/lists"}