{"id":17924085,"url":"https://github.com/benpate/data","last_synced_at":"2026-02-16T14:34:01.441Z","repository":{"id":37601539,"uuid":"184512182","full_name":"benpate/data","owner":"benpate","description":"Swappable database adapters for Go","archived":false,"fork":false,"pushed_at":"2025-12-29T04:55:57.000Z","size":170,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-31T14:44:35.649Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benpate.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-02T02:49:23.000Z","updated_at":"2025-12-29T04:56:01.000Z","dependencies_parsed_at":"2023-11-22T20:34:47.836Z","dependency_job_id":"a723ee91-de88-4918-99d8-9dfaffe856de","html_url":"https://github.com/benpate/data","commit_stats":null,"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/benpate/data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benpate%2Fdata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benpate%2Fdata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benpate%2Fdata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benpate%2Fdata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benpate","download_url":"https://codeload.github.com/benpate/data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benpate%2Fdata/sbom","scorecard":{"id":233556,"data":{"date":"2025-08-11","repo":{"name":"github.com/benpate/data","commit":"052d5f220aa1b7053942156cd76655b438558bbf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/go.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/benpate/data/go.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"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":"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":"SAST","score":10,"reason":"SAST tool detected: CodeQL","details":["Info: SAST configuration detected: CodeQL","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":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: 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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":10,"reason":"0 existing vulnerabilities detected","details":null,"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-17T05:13:46.457Z","repository_id":37601539,"created_at":"2025-08-17T05:13:46.457Z","updated_at":"2025-08-17T05:13:46.457Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29510215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: 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":[],"created_at":"2024-10-28T20:47:01.975Z","updated_at":"2026-02-16T14:34:01.414Z","avatar_url":"https://github.com/benpate.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data 📚\n\n[![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://pkg.go.dev/github.com/benpate/data)\n[![Version](https://img.shields.io/github/v/release/benpate/data?include_prereleases\u0026style=flat-square\u0026color=brightgreen)](https://github.com/benpate/data/releases)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/benpate/data/go.yml?branch=main\u0026style=flat-square)](https://github.com/benpate/data/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/benpate/data?style=flat-square)](https://goreportcard.com/report/github.com/benpate/data)\n[![Codecov](https://img.shields.io/codecov/c/github/benpate/data.svg?style=flat-square)](https://codecov.io/gh/benpate/data)\n\n## Swappable Database Adapters for Go\n\nThis library provides a common interface for making simple database calls.  The goal of this package is to provide simple [CRUD operations](https://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete) only, so each database will support many advanced features that are not available through this library.  Other modules (such as [data-mongo](https://github.com/benpate/data-mongo) and [data-mock](https://github.com/benpate/data-mock)) implement specific database adapters.\n\n### The \"Object\" interface\n\nThe data library works with any object that implements the `Object` interface.  To implement this quickly in existing data models, you can just attach the `journal.Journal` object to your domain objects, and most of your work is already done.\n\n```go\n// Object wraps all of the methods that a Domain Object must provide to Presto\ntype Object interface {\n\n    // ID returns the primary key of the object\n    ID() string\n\n    // IsNew returns TRUE if the object has not yet been saved to the database\n    IsNew() bool\n\n    // SetCreated stamps the CreateDate and UpdateDate of the object, and adds a note to the Journal.\n    SetCreated(comment string)\n\n    // SetUpdated stamps the UpdateDate of the object, and adds a note to the Journal.\n    SetUpdated(comment string)\n\n    // SetDeleted marks the object virtually \"deleted\", and adds a note to the Journal.\n    SetDeleted(comment string)\n}\n```\n\n### Datasource Interface\n\n```go\n\n// Configure your database\nds := mongodb.New(uri, dbname)\n\n// Create a new session, one per server request\nsession := db.Session()\ndefer session.Close()\n\n// Get a reference to the table/collection you're working with\ncollection := session.Collection(\"Person\")\n\n// LOAD from a person object from the database\nerr := collection.Load(criteria, \u0026person)\n\n// INSERT/UPDATE a person object in the database - writing a \"note\" to the journal.\nerr := collection.Save(person, note)\n\n// DELETE a person from the database. This is a \"soft\" delete that marks values as deleted but leaves them in the database.\nerr := collection.Delete(person, note)\n\n// HARD DELETE a person, actually removing the record from the database.\nerr := collection.HardDelete(criteria)\n\n// QUERY many records from the database, by populating a slice of results\nerr := collection.Query(criteria, options...)\n\n// ITERATE over many records, using a more memory-friendly iterator to loop through a very large dataset.\nit, err := collection.Query(criteria, options...)\n\nfor it.Next(\u0026person) {\n    // do stuff with person.\n}\n\n// COUNT the number of records that match a particular criteria\ncount, err := collection.Count(criteria)\n\n```\n\n### Expression Builder\n\nEvery database has its own query language, so this library uses the [exp module](https://github.com/benpate/exp) to represent query expressions in an efficient intermediate format that should be easy to convert into whatever specific language you need to use.\n\n```go\n// build single predicate expressions\nc := exp.Equal(\"name\", \"John Connor\")\n\n// or chain logical expressions together\nc := exp.Equal(\"name\", \"John Connor\").OrEqual(\"name\", \"Sarah Connor\")\n```\n\n### Query Options\n\nThere's a package for managing optional query arguments, such as sorting and pagination.  These options just encapsulate data.  It is the responsibilty of each database adapter to implement each of these in its own query engine.\n\n```go\n\n// get a new iterator.  Sort results by first name.  Return only the first 100 rows.\nit := session.List(collection, criteria, options.SortAsc(\"name\"), options.MaxRows(100))\n```\n\n**`SortAsc(fieldname)`** tells the database to sort by a particular field, in ascending order\n\n**`SortDesc(fieldname)`** tells the database to sort by a particular field, in descending order\n\n**`FirstRow(count)`** tells the database to start returning records at the provided row number\n\n**`MaxRows(count)`** tells the database to limit the number of records to the designated number of rows.\n\n## Pull Requests Welcome\n\nThis library is a work in progress, and will benefit from your experience reports, use cases, and contributions.  If you have an idea for making this library better, send in a pull request.  We're all in this together! 📚\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenpate%2Fdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenpate%2Fdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenpate%2Fdata/lists"}