{"id":23858731,"url":"https://github.com/legendaryb/go-store","last_synced_at":"2025-09-08T06:31:01.267Z","repository":{"id":125454264,"uuid":"577697973","full_name":"LegendaryB/go-store","owner":"LegendaryB","description":"Lightweight embedded database in pure Go inspired by lowdb","archived":false,"fork":false,"pushed_at":"2022-12-14T10:14:41.000Z","size":18,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-31T10:32:12.272Z","etag":null,"topics":["adapter","database","embedded","embedded-database","extendable","generic","go","golang","json","library","lightweight","local","memory","storage"],"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/LegendaryB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2022-12-13T10:21:31.000Z","updated_at":"2025-01-09T21:46:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8ea21d9-623a-42ae-b180-238518d36ca9","html_url":"https://github.com/LegendaryB/go-store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LegendaryB/go-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2Fgo-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2Fgo-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2Fgo-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2Fgo-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LegendaryB","download_url":"https://codeload.github.com/LegendaryB/go-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegendaryB%2Fgo-store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274145938,"owners_count":25230114,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["adapter","database","embedded","embedded-database","extendable","generic","go","golang","json","library","lightweight","local","memory","storage"],"created_at":"2025-01-03T03:17:16.711Z","updated_at":"2025-09-08T06:31:00.931Z","avatar_url":"https://github.com/LegendaryB.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿\u003cdiv align=\"center\"\u003e\n\n\u003ch1\u003ego-store\u003c/h1\u003e\n\n[![forthebadge](https://forthebadge.com/images/badges/fuck-it-ship-it.svg)](https://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/made-with-go.svg)](https://forthebadge.com)\n\n[![GitHub license](https://img.shields.io/github/license/LegendaryB/go-store.svg?longCache=true\u0026style=flat-square)](https://github.com/LegendaryB/go-store/blob/main/LICENSE.txt)\n\n\u003csub\u003eBuilt with ❤︎ by LegendaryB\u003c/sub\u003e\n\n\u003c/div\u003e\u003cbr\u003e\n\n## 🎯 Features\n\n- Lightweight\n- Pure Golang, no external dependencies\n- Minimalistic\n- Extendable\n\n## 🚀 Install\n\n```\ngo get github.com/LegendaryB/go-store\n```\n\n## 📝 Usage\n\n```go\npackage main\n\nimport (\n\t\"github.com/LegendaryB/go-store\"\n\t\"github.com/LegendaryB/go-store/adapters\"\n)\n\ntype Blog struct {\n\tArticles []Article\n}\n\ntype Article struct {\n\tTitle   string\n\tContent string\n\tAuthor  Author\n}\n\ntype Author struct {\n\tName string\n}\n\nfunc main() {\n        // Configure the options for the JSON Adapter\n\topts := adapters.JSONAdapterOptions{\n\t\tPath:                     \"db.json\",\n\t\tCreateFileWhenNotPresent: true,\n\t\tUsePrettyPrint:           true,\n\t}\n\n        // Create a new instance of the JSON Adapter type\n\tadapter, err := adapters.NewJSONAdapter[Blog](opts)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n        // Create a new instance of the Store type and configure it to use the JSON Adapter type instance\n        // Equal to using: store.NewWithJSONAdapter(opts)\n\tstore := store.New[Blog](adapter)\n\n        // Read the data from disk\n\tif err := store.Read(); err != nil {\n\t\tpanic(err)\n\t}\n\n        // Write the data to disk\n\tdefer store.Write()\n\n        // Use the native Go api to append a new article into the articles array\n\tstore.Data.Articles = append(store.Data.Articles, Article{\n\t\tTitle:   \"Lorem Ipsum\",\n\t\tContent: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam mauris tellus, interdum in neque in, aliquam pharetra tellus. Vivamus mollis facilisis lacinia. In maximus auctor volutpat. Phasellus vel elit justo. Sed mattis elit vitae purus commodo vehicula. Curabitur tristique lacus sed blandit suscipit. Aenean lobortis vitae ligula eget rutrum. Phasellus ut iaculis justo. Praesent molestie aliquam justo, ac pellentesque nisl luctus ut. Maecenas dictum aliquet justo, sollicitudin molestie nisl accumsan blandit. Nunc placerat erat id dui ultricies mollis. Morbi venenatis facilisis sodales. Donec eget risus urna. Maecenas pulvinar felis urna, vitae molestie metus dictum sed. Aenean nec vulputate erat.\",\n\t\tAuthor: Author{\n\t\t\tName: \"N/A\",\n\t\t},\n\t})\n}\n```\n\n## 🔌 Adapters\n\n### JSON adapter\n\nThis adapter is used for reading and writing data to a JSON file. It can be used like this:\n\n```go\nfunc main() {\n        // Configure the options for the JSON Adapter\n\topts := adapters.JSONAdapterOptions{\n\t\tPath:                     \"db.json\",\n\t\tCreateFileWhenNotPresent: true,\n\t\tUsePrettyPrint:           true,\n\t}\n\n        // Create a new instance of the JSON Adapter type\n\tadapter, err := adapters.NewJSONAdapter[Blog](opts)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n        // Use it\n\tstore := store.New[Blog](adapter)\n}\n```\n\nor\n\n```go\nfunc main() {\n        // Configure the options for the JSON Adapter\n\topts := adapters.JSONAdapterOptions{\n\t\tPath:                     \"db.json\",\n\t\tCreateFileWhenNotPresent: true,\n\t\tUsePrettyPrint:           true,\n\t}\n\n        // Use it\n\tstore, err := store.NewWithJSONAdapter[Blog](opts)\n\n        if err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n### In memory adapter\n\nThis adapter can be used for quick testing or unit tests. After the process exits the data is lost. It can be used like this:\n\n```go\nfunc main() {\n        // Create a new instance of the InMemoryAdapter type\n\tadapter, err := adapters.NewInMemoryAdapter[Blog]()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n        // Use it\n\tstore := store.New[Blog](adapter)\n}\n```\n\nor\n\n```go\nfunc main() {\n        // Use it\n\tstore, err := store.NewWithInMemoryAdapter[Blog](opts)\n\n        if err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n### Writing a custom adapter\n\nTo implement a custom provider you only need to implement the `Adapter` interface:\n\n```go\ntype Adapter[T any] interface {\n\tRead() (*T, error)\n\tWrite(data T) error\n}\n```\n\nAfterwards you can use your custom provider like this:\n\n```go\nfunc main() {\n        // Create a new instance of your custom provider type\n\tadapter, err := adapters.NewMyCustomAdapter[Blog]()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n        // Use it\n\tstore := store.New[Blog](adapter)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegendaryb%2Fgo-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flegendaryb%2Fgo-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegendaryb%2Fgo-store/lists"}