{"id":28693308,"url":"https://github.com/dal-go/dalgo","last_synced_at":"2025-06-14T08:13:01.892Z","repository":{"id":39260523,"uuid":"111734973","full_name":"dal-go/dalgo","owner":"dal-go","description":"Database Abstraction Layer (DAL) in Go language","archived":false,"fork":false,"pushed_at":"2025-05-20T12:35:32.000Z","size":411,"stargazers_count":24,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-20T13:44:48.247Z","etag":null,"topics":["api-wrapper","dal","dalgo","database","go","golang","golang-library","nosql","sql"],"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/dal-go.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2017-11-22T21:39:28.000Z","updated_at":"2025-05-20T12:34:49.000Z","dependencies_parsed_at":"2023-07-14T02:08:43.538Z","dependency_job_id":"b1eb13cc-238f-4d22-ad18-99e34a2d776a","html_url":"https://github.com/dal-go/dalgo","commit_stats":null,"previous_names":["strongo/dalgo","strongo/db"],"tags_count":91,"template":false,"template_full_name":null,"purl":"pkg:github/dal-go/dalgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dal-go%2Fdalgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dal-go%2Fdalgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dal-go%2Fdalgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dal-go%2Fdalgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dal-go","download_url":"https://codeload.github.com/dal-go/dalgo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dal-go%2Fdalgo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259783086,"owners_count":22910304,"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":["api-wrapper","dal","dalgo","database","go","golang","golang-library","nosql","sql"],"created_at":"2025-06-14T08:12:57.640Z","updated_at":"2025-06-14T08:13:01.882Z","avatar_url":"https://github.com/dal-go.png","language":"Go","readme":"# DALgo - Database Abstraction Layer (DAL) in Go\n\n**To use**: `go get `[`github.com/dal-go/dalgo`](https://github.com/dal-go/dalgo)\n\n## Status\n[![Build, Test, Vet, Lint](https://github.com/dal-go/dalgo/actions/workflows/ci.yml/badge.svg)](https://github.com/dal-go/dalgo/actions/workflows/ci.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dal-go/dalgo)](https://goreportcard.com/report/github.com/dal-go/dalgo)\n[![Coverage Status](https://coveralls.io/repos/github/dal-go/dalgo/badge.svg?branch=main\u0026kill-cache=2)](https://coveralls.io/github/dal-go/dalgo?branch=main)\n[![Version](https://img.shields.io/github/v/tag/dal-go/dalgo?filter=v*.*.*\u0026logo=Go)](https://github.com/dal-go/dalgo/tags)\n[![GoDoc](https://godoc.org/github.com/dal-go/dalgo?status.svg)](https://godoc.org/github.com/dal-go/dalgo)\n[![Sourcegraph](https://sourcegraph.com/github.com/dal-go/dalgo/-/badge.svg)](https://sourcegraph.com/github.com/dal-go/dalgo?badge)\n\n\n## Summary\n\nUsing this module allows you:\n\n1. To abstract work with data storage so underlying API can be swapped.\n\n2. Write less code. Write more readable code.\n\n3. Easily add logging \u0026 hooks for all DB operations.\n\n4. Write unit tests for your business logic without dependency on specific API.\n\n## Quality Assurance\n- [Build pipeline](https://github.com/dal-go/dalgo/actions/workflows/ci.yml)\n  - 100% test [code coverage](https://coveralls.io/github/dal-go/dalgo?branch=main)!\n  - Go vet\n  - golangci-lint\n- Same [end-2-end tests](https://github.com/dal-go/dalgo-end2end-tests) are used for all DB adapters \n\n## Overview generated by ChatGPT-4\n\nThe `github.com/dal-go/dalgo` package provides a consistent and flexible API for working with different types of\ndatabases in Go. By providing a single interface for different types of databases, dalgo allows developers to write code\nthat is agnostic to the underlying data store. This can help reduce development time and improve code maintainability,\nwhile also providing the flexibility to choose the data store that best suits their needs. The package includes an\neasy-to-use API for querying, inserting, updating, and deleting records, as well as features for handling errors and\nlogging. It also supports transactions.\n\nCurrently, the dalgo package supports a variety of different databases, including relational databases such as MS SQL\nServer, MySQL and PostgreSQL, as well as key-value stores like Redis and Memcached. It can also be used with cloud-based\ndata stores like Google Firestore and Datastore.\n\nIt comes with a set of end-to-end tests that are run against different DB clients. By running these tests against\nmultiple database clients, dalgo can ensure that it is compatible with a wide range of database systems and that it can\nhandle scenarios such as concurrent access, complex queries, and schema changes.\n\nDalgo will include a code generation tool that can generate Go code for interacting with the database based on the\ndatabase schema. This feature can be especially useful when working with large databases with complex schemas.\n\nOverall, the dalgo package provides a consistent, flexible \u0026 agnostic API for working with different types of databases\nin Go. By allowing developers to write database-agnostic code, it provides a powerful tool for reducing development time\nand improving code maintainability, while also offering the flexibility to choose the data store that best suits their\nneeds.\n\n## Packages\n\n- [`dal`](dal) - Database Abstraction Layer\n- [`orm`](orm) - Object–relational mapping\n- [`record`](record) - helpers to simplify working with dalgo records in strongly typed way.\n\n## DAL implementations for specific APIs\n\nDALgo defines abstract interfaces and helpers methods to work with databases in abstract manner.\n\nHere is modules that bridge DALgo to specific APIs:\n\n- ### [**dalgo2sql**](https://github.com/dal-go/dalgo2sql)\n  for [database/sql](https://pkg.go.dev/database/sql) - a generic interface around SQL (or SQL-like) databases.\n\n- ### [**dalgo2firestore**](https://github.com/dal-go/dalgo2firestore)\n  for [Firestore](https://pkg.go.dev/cloud.google.com/go/firestore) -\n  a NoSQL document database that lets you easily\n  store, sync, and query data for your mobile and web apps - at global scale.\n\n- ### [**dalgo2datastore**](https://github.com/dal-go/dalgo2datastore)\n  for [Google Cloud Datastore](https://pkg.go.dev/cloud.google.com/go/datastore) -\n  Highly scalable NoSQL database - is a predecessor for Firestore.\n\n- ### [**dalgo2buntdb**](https://github.com/dal-go/dalgo2buntdb)\n  for [BuntDB](https://github.com/tidwall/buntdb) - an embeddable, in-memory key/value database for Go with custom\n  indexing and geospatial support.\n\n- ### [**dalgo2badger**](https://github.com/dal-go/dalgo2badger)\n  for [BadgerDB](https://github.com/dal-go/dalgo) - an embeddable, persistent and fast key-value (KV) database written\n  in pure Go.\n\n## Test coverage\n\nThe CI process for this package and for officially supported bridges runs unit tests\nand [end-to-end](https://github.com/dal-go/dalgo-end2end-tests) integration tests.\n\n## DALgo interfaces\n\n**Package**: `github.com/dal-go/dalgo/dal`\n\nThe main abstraction is though `dalgo.Record` interface :\n\n```go\npackage dal\n\ntype Record interface {\n\tKey() *Key          // defines `table` name of the entity\n\tData() any          // value to be stored/retrieved (without ID)\n\tError() error       // holds error for the record\n\tSetError(err error) // sets error relevant to specific record\n\tExists() bool       // indicates if the record exists in DB\n}\n```\n\nAll methods are working with the `Record` and use `context.Context`.\n\nThe [`Database`](./dal/database.go) interface defines an interface to a storage that should be implemented by a specific\ndriver. Contributions for client bridges are very welcome!\nIf the db driver does not support some operations it must return `dalgo.ErrNotSupported`.\n\n```go\npackage dal\n\ntype Database interface {\n\tTransactionCoordinator\n\tReadonlySession\n}\n\n// TransactionCoordinator provides methods to work with transactions\ntype TransactionCoordinator interface {\n\n\t// RunReadonlyTransaction starts readonly transaction\n\tRunReadonlyTransaction(ctx context.Context, f ROTxWorker, options ...TransactionOption) error\n\n\t// RunReadwriteTransaction starts read-write transaction\n\tRunReadwriteTransaction(ctx context.Context, f RWTxWorker, options ...TransactionOption) error\n}\n\n// ReadonlySession defines methods that do not modify database\ntype ReadonlySession interface {\n\n\t// Get gets a single record from database by key\n\tGet(ctx context.Context, record Record) error\n\n\t// GetMulti gets multiples records from database by keys\n\tGetMulti(ctx context.Context, records []Record) error\n\n\t// Select executes a data retrieval query\n\tSelect(ctx context.Context, query Select) (Reader, error)\n}\n\n// ReadwriteSession defines methods that can modify database\ntype ReadwriteSession interface {\n\tReadonlySession\n\twriteOnlySession\n}\n\ntype writeOnlySession interface {\n\n\t// Insert inserts a single record in database\n\tInsert(c context.Context, record Record, opts ...InsertOption) error\n\n\t// Set sets a single record in database by key\n\tSet(ctx context.Context, record Record) error\n\n\t// SetMulti sets multiples records in database by keys\n\tSetMulti(ctx context.Context, records []Record) error\n\n\t// Update updates a single record in database by key\n\tUpdate(ctx context.Context, key *Key, updates []Update, preconditions ...Precondition) error\n\n\t// UpdateMulti updates multiples records in database by keys\n\tUpdateMulti(c context.Context, keys []*Key, updates []Update, preconditions ...Precondition) error\n\n\t// Delete deletes a single record from database by key\n\tDelete(ctx context.Context, key *Key) error\n\n\t// DeleteMulti deletes multiple records from database by keys\n\tDeleteMulti(ctx context.Context, keys []*Key) error\n}\n```\n\nNote that getters are populating records in place using target instance obtained via `Record.GetData()`.\n\nOriginally developed to support work with Google AppEngine Datastore and Firebase Firestore it takes into account its\nspecifics. This works well with other key-value storages as well. Also `dalgo` supports SQL databases.\n\n## Projects \u0026 modules that use DALgo\n\n* \u003ca href=\"https://github.com/strongo/bots-framework\"\u003e`strongo/bots-framework`\u003c/a\u003e - framework to build chatbots\n  in Go language.\n\n[More dependants](https://sourcegraph.com/search?q=context%3Aglobal+github.com%2Fdal-go%2Fdalgo\u0026patternType=standard\u0026sm=1\u0026groupBy=repo) can be found using SourceGraph search. \n\n## [Contributing](CONTRIBUTING.md)\n\nContributions are welcome but should follow the [contribution guidelines](CONTRIBUTING.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdal-go%2Fdalgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdal-go%2Fdalgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdal-go%2Fdalgo/lists"}