{"id":19168553,"url":"https://github.com/xanthous-tech/dgraph-orm","last_synced_at":"2025-05-07T14:41:55.228Z","repository":{"id":44013160,"uuid":"234218926","full_name":"xanthous-tech/dgraph-orm","owner":"xanthous-tech","description":"dGraph ORM written in TypeScript","archived":false,"fork":false,"pushed_at":"2023-01-11T22:22:14.000Z","size":1640,"stargazers_count":17,"open_issues_count":26,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-19T23:32:00.042Z","etag":null,"topics":["dgraph","dgraph-orm","orm","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/xanthous-tech.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-01-16T02:38:26.000Z","updated_at":"2024-01-05T00:05:27.000Z","dependencies_parsed_at":"2023-02-09T08:16:40.045Z","dependency_job_id":null,"html_url":"https://github.com/xanthous-tech/dgraph-orm","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xanthous-tech%2Fdgraph-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xanthous-tech%2Fdgraph-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xanthous-tech%2Fdgraph-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xanthous-tech%2Fdgraph-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xanthous-tech","download_url":"https://codeload.github.com/xanthous-tech/dgraph-orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252897442,"owners_count":21821438,"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":["dgraph","dgraph-orm","orm","typescript"],"created_at":"2024-11-09T09:43:05.607Z","updated_at":"2025-05-07T14:41:55.203Z","avatar_url":"https://github.com/xanthous-tech.png","language":"TypeScript","readme":"# DGraph ORM\n\nA decorator based object mapper, schema handler, mutation tracker to use with dgraph.\n\nThis library handles objects and their relation and generates mutation/deletion strings based on\nchanges. These strings can be used with any dgraph client to mutate the data.\n\n# Getting started\n\n```\nyarn add @xanthous/dgraph-orm\n```\n\nHere is an example to create a new graph using some of the public APIs exposed by the ORM.\n\n```typescript\nimport {\n  Uid,\n  Node,\n  Property,\n  Predicate,\n  IPredicate,\n  QueryBuilder,\n  SchemaBuilder,\n  TransactionBuilder\n} from '@xanthous/dgraph-orm';\n\n/**\n * A Node definition of person\n */\n@Node()\nclass Person {\n  @Uid()\n  id: string;\n\n  @Property()\n  name: string;\n\n  @Predicate({ type: () =\u003e Person })\n  friends: IPredicate\u003cPerson\u003e;\n}\n\n// Schema generated based on the node definitions.\nconst schema = SchemaBuilder.build();\nconsole.log(schema);\n// type Person {\n//   Person.name: string\n//   Person.friends: [Person]\n// }\n// Person.name: string .\n// Person.friends: [uid] @count .\n\n// Query builder can be used to easily create query fragments based on the definitions.\nconst { handle, fragment } = QueryBuilder.buildFragment(Person);\nconsole.log(handle);\n// ...personDataFragment\n\nconsole.log(fragment);\n// fragment personDataFragment {\n//    Person.name\n//    Person.friends\n//    id\n// }\n\n// Create a transaction\nconst transaction = TransactionBuilder.build();\n\n// Create some people\nconst john = transaction.nodeFor(Person);\nconst jane = transaction.nodeFor(Person);\nconst kamil = transaction.nodeFor(Person);\n\n// A temporary uid is assigned during object creation.\nconsole.log(john.id);\n// b830c1f5ca09d466 ## random\n\n// Change their names\njohn.name = 'John';\njane.name = 'Jane';\nkamil.name = 'Kamil';\n\n// Create connections between them\nkamil.friends.add(jane);\nkamil.friends.add(john);\n\n// Create a mutation string to use with dgraph js client.\nconst mutation = transaction.getSetNQuadsString();\nconsole.log(mutation);\n// _:b830c1f5c787c210 \u003cdgraph.type\u003e \"Person\" .\n// _:b830c1f5c787c210 \u003cPerson.name\u003e \"John\"^^\u003cxs:string\u003e .\n// _:b830c1f5c78a5947 \u003cdgraph.type\u003e \"Person\" .\n// _:b830c1f5c78a5947 \u003cPerson.name\u003e \"Jane\"^^\u003cxs:string\u003e .\n// _:b830c1f5c78afce1 \u003cdgraph.type\u003e \"Person\" .\n// _:b830c1f5c78afce1 \u003cPerson.name\u003e \"Kamil\"^^\u003cxs:string\u003e .\n// _:b830c1f5c78afce1 \u003cPerson.friends\u003e _:b830c1f5c78a5947 .\n// _:b830c1f5c78afce1 \u003cPerson.friends\u003e _:b830c1f5c787c210 .\n```\n\n# Sponsors\n\n[Treelab](https://treelab.com.cn)\n\n# License\n\n[MIT](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxanthous-tech%2Fdgraph-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxanthous-tech%2Fdgraph-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxanthous-tech%2Fdgraph-orm/lists"}