{"id":34236470,"url":"https://github.com/ppp225/ndgo","last_synced_at":"2026-03-10T22:02:40.203Z","repository":{"id":57494443,"uuid":"193279723","full_name":"ppp225/ndgo","owner":"ppp225","description":"ndgo is a dgraph dgo wrapper. Provides abstractions and helper functions.","archived":false,"fork":false,"pushed_at":"2023-02-25T08:09:22.000Z","size":139,"stargazers_count":4,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-14T14:31:53.846Z","etag":null,"topics":["abstraction","dgo","dgraph","helper","helper-functions","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ppp225.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-22T21:10:56.000Z","updated_at":"2023-02-19T13:22:07.000Z","dependencies_parsed_at":"2024-06-19T06:13:08.228Z","dependency_job_id":null,"html_url":"https://github.com/ppp225/ndgo","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ppp225/ndgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppp225%2Fndgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppp225%2Fndgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppp225%2Fndgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppp225%2Fndgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppp225","download_url":"https://codeload.github.com/ppp225/ndgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppp225%2Fndgo/sbom","scorecard":{"id":742862,"data":{"date":"2025-08-11","repo":{"name":"github.com/ppp225/ndgo","commit":"435fb159a3febb05db4f3a0efa041986a5a1376e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T17:56:51.129Z","repository_id":57494443,"created_at":"2025-08-22T17:56:51.129Z","updated_at":"2025-08-22T17:56:51.129Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30357614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"ssl_error","status_checked_at":"2026-03-10T21:40:59.357Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["abstraction","dgo","dgraph","helper","helper-functions","wrapper"],"created_at":"2025-12-16T02:45:31.280Z","updated_at":"2026-03-10T22:02:40.197Z","avatar_url":"https://github.com/ppp225.png","language":"Go","readme":"# ndgo [![Build Status](https://travis-ci.org/ppp225/ndgo.svg?branch=master)](https://travis-ci.org/ppp225/ndgo)    [![codecov](https://codecov.io/gh/ppp225/ndgo/branch/master/graph/badge.svg)](https://codecov.io/gh/ppp225/ndgo)    [![Go Report Card](https://goreportcard.com/badge/github.com/ppp225/ndgo)](https://goreportcard.com/report/github.com/ppp225/ndgo)    [![Maintainability](https://api.codeclimate.com/v1/badges/7954fe4d199f0426bb5d/maintainability)](https://codeclimate.com/github/ppp225/ndgo/maintainability)   [![GoDoc](https://godoc.org/github.com/ppp225/ndgo?status.svg)](https://godoc.org/github.com/ppp225/ndgo)   \nndgo provides [dgraph](https://github.com/dgraph-io) [dgo](https://github.com/dgraph-io/dgo) txn abstractions and helpers.\n\n# Why\n\n* Reduce txn related boilerplate, thus making code more readable,\n* Make using ratel like queries easier,\n* Get query execution times the easy way, even for multi-query txns,\n* Be low level - don't do magic, keep dgo things exposed for them to be usable, if necessary,\n* No performance overhead compared to dgo, if possible.\n\n# Install\n\n```bash\ngo get -u github.com/ppp225/ndgo\n```\n\n```bash\nimport (\n  \"github.com/ppp225/ndgo/v5\"\n)\n```\n\n# Common uses\n\nRun transactions the same way one would do in ratel:\n\n```go\nq := QueryDQL(fmt.Sprintf(`\n  {\n    %s(func: eq(%s, \"%s\")) {\n      uid\n      name\n    }\n  }\n  `, \"favActor\", \"name\", \"Keanu Reeves\"))\n\nresp, err := q.Run(txn)\n```\n\nOr marshal structs:\n\n```go\njsonBytes, err := json.Marshal(myObj)\nif err != nil {\n  return nil, err\n}\nresp, err := txn.Setb(jsonBytes, nil)\n```\n\nOr don't:\n\n```go\nresp, err := txn.Seti(myObj, myObj2, myObj3)\n```\n\nDo Upserts:\n\n```go\nq := `{ a as var(func: eq(name, \"Keanu\")) }`\nmyObj := personStruct{\n\tUID:  \"uid(a)\",\n\tType: \"Person\",\n\tName: \"Keanu\",\n}\nresp, err := txn.DoSeti(q, myObj)\n```\n\nSee `TestBasic` and `TestComplex` and `TestTxnUpsert` in `ndgo_test.go` for a complete example.\n\n# ndgo.Txn\n\n### Create a transaction:\n\n```go\ndg := NewDgraphClient()\ntxn := ndgo.NewTxn(ctx, dg.NewTxn()) // or dg.NewReadOnlyTxn(), you can use any available dgo.txn options. You can also use ndgo.NewTxnWithoutContext(txn)\ndefer txn.Discard()\n...\nerr = txn.Commit()\n```\n\n### Do mutations and queries:\n\n```go\nresp, err := txn.Mutate(*api.Mutation)\nresp, err := txn.Setb(jsonBytes, rdfBytes)\nresp, err := txn.Seti(myObjs...)\nresp, err := txn.Setnq(nquads)\nresp, err := txn.Deleteb(jsonBytes, deleteRdfBytes)\nresp, err := txn.Deletei(myObjs...)\nresp, err := txn.Deletenq(nquads)\n\nresp, err := txn.Query(queryString)\nresp, err := txn.QueryWithVars(queryWithVarsString, vars...)\n\nresp, err := txn.Do(req *api.Request)\nresp, err := txn.DoSetb(queryString, jsonBytes)\nresp, err := txn.DoSeti(queryString, myObjs...)\nresp, err := txn.DoSetnq(queryString, nquads)\n```\n\n### Get diagnostics:\n\n```go\ndbms := txn.GetDatabaseTime()\nnwms := txn.GetNetworkTime()\n```\n\n# ndgo.Set/Delete JSON/RDF\n\nDefine and run txns through json, rdf or predefined helpers\n\n### Set:\n\n```go\nset := ndgo.SetJSON(fmt.Sprintf(`\n  {\n    \"name\": \"%s\",\n    \"age\": \"%s\"\n  }`, \"L\", \"25\"))\n// or\nset := ndgo.SetRDF(`\u003c_:new\u003e \u003cname\u003e \"L\" .\n                    \u003c_:new\u003e \u003cage\u003e \"25\" .`)\n// or\nset := ndgo.Query{}.SetPred(\"_:new\", name, \"L\") + \n       ndgo.Query{}.SetPred(\"_:new\", age, \"25\")\n\nresp, err := set.Run(txn)\n```\n\n### Delete:\n\n```go\ndel := ndgo.DeleteJSON(fmt.Sprintf(`\n  {\n    \"uid\": \"%s\"\n  }\n  `, uid))\n// or\ndel := ndgo.Query{}.DeleteNode(\"0x420\") + \n       ndgo.Query{}.DeleteEdge(\"0x420\", \"edgeName\", \"0x42\") +\n       ndgo.Query{}.DeletePred(\"0x42\", \"name\")\n\nresp, err := del.Run(txn)\n```\n\n### Query:\n\n```go\nq := ndgo.QueryDQL(fmt.Sprintf(`\n  {\n    %s(func: eq(%s, \"%s\")) {\n      uid\n    }\n  }\n  `, \"favActor\", \"name\", \"Keanu Reeves\"))\n\nresponse, err := q.Run(txn)\n```\n\n### Join:\n\nYou can chain queries and JSON mutations with Join, RDF mutations with + operator, assuming they are the same type:\n\n```go\nq1 := ndgo.QueryDQL(`{q1(func:eq(name,\"a\")){uid}})`\nq2 := ndgo.QueryDQL(`{q2(func:eq(name,\"b\")){uid}})`\nresp, err := q1.Join(q2).Run(txn)\n```\n\nNote that query blocks have to be named uniquely.\n\n# Other helpers\n\n### FlattenResp\n\nSometimes, when querying dgraph, we want just 1 resulting element, instead of a nested array.\n\n```go\n// Instead of having this:\ntype Queries struct {\n  Q []struct {\n    UID string `json:\"uid\"`\n  } `json:\"q\"`\n}\n// We can have:\ntype MyObj struct {\n  UID string `json:\"uid\"`\n}\n```\n```go\nresp, _ := ndgo.QueryDQL(`{q(func:uid(0x123)){uid}}`).Run(txn)\n// query block name -------^ must be one letter and only one query block must be in the query for this helper to work!\nvar result MyObj\nif err := json.Unmarshal(ndgo.Unsafe{}.FlattenRespToObject(resp.GetJson()), \u0026result); err != nil {\n\tpanic(err) // will fail, if result has more than 1 element!\n}\nvar resultSlice []MyObj\nif err := json.Unmarshal(ndgo.Unsafe{}.FlattenRespToArray(resp.GetJson()), \u0026resultSlice); err != nil {\n\tpanic(err) // will fail, if multiple query blocks are used in Query, but can have multiple results!\n}\nlog.Print(result)\nlog.Print(resultSlice)\n```\n\n# Future plans\n\n* add more upsert things\n\n# Note\n\nThis project uses semantic versioning, see the [changelog](https://github.com/ppp225/ndgo/blob/master/CHANGELOG.md) for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppp225%2Fndgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppp225%2Fndgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppp225%2Fndgo/lists"}