{"id":19156629,"url":"https://github.com/kkdai/favdb","last_synced_at":"2025-07-14T11:07:19.779Z","repository":{"id":170874325,"uuid":"647129152","full_name":"kkdai/favdb","owner":"kkdai","description":"User Favorite DB handle in go (memory, GitHub issue, and PostgreSQL)","archived":false,"fork":false,"pushed_at":"2024-05-01T13:24:28.000Z","size":36,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T20:17:18.012Z","etag":null,"topics":["github","golang","postgressql"],"latest_commit_sha":null,"homepage":"https://www.evanlin.com/go-github-issue/","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/kkdai.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}},"created_at":"2023-05-30T05:58:31.000Z","updated_at":"2023-06-22T17:41:24.000Z","dependencies_parsed_at":"2024-01-22T12:16:17.220Z","dependency_job_id":"1058d97a-a95b-4894-86a3-a3d54e89681c","html_url":"https://github.com/kkdai/favdb","commit_stats":null,"previous_names":["kkdai/favdb"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkdai%2Ffavdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkdai%2Ffavdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkdai%2Ffavdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kkdai%2Ffavdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kkdai","download_url":"https://codeload.github.com/kkdai/favdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252838649,"owners_count":21812080,"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":["github","golang","postgressql"],"created_at":"2024-11-09T08:35:17.325Z","updated_at":"2025-05-07T07:46:13.328Z","avatar_url":"https://github.com/kkdai.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"favdb: User Favorite DB handle in go (memory, GitHub issue, and PostgreSQL)\n======================\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/kkdai/favdb/master/LICENSE) [![GoDoc](https://godoc.org/github.com/kkdai/favdb?status.svg)](https://godoc.org/github.com/kkdai/favdb)[![Go](https://github.com/kkdai/favdb/actions/workflows/go.yml/badge.svg)](https://github.com/kkdai/favdb/actions/workflows/go.yml)\n\nfav is a package to help you setup a single entry fo MemoryDB, Github Issue, PostgresSQL DB with user favorite.\n\nThe database must be simple and ease to use.\n\n```\nUser1 -\u003e Fav1, Fav2 ...\nUser2 -\u003e Fav3\n```\n\nInstall\n--------------\n\n    go get github.com/kkdai/favdb\n\nUsage\n---------------------\n\nrefer `example/github-issue`for more detail.\n`GITHUB_URL` is a string combine with \"USE/REPO/GITHU_TOKEN\".\n\n```go\nvar DB favdb.UserFavData\n\nfunc main() {\n    // PostgresSQL connect string\n    url := os.Getenv(\"DATABASE_URL\")\n    // `GITHUB_URL` is a string combine with \"USE/REPO/GITHU_TOKEN\".\n    gitUrl := os.Getenv(\"GITHUB_URL\")\n    if url != \"\" {\n        // Use PostgresSQL as DB.\n        DB = favdb.NewPGSql(url)\n    } else if gitUrl != \"\" {\n        // Use Github Issue as DB.\n        DB = favdb.NewGithubDB(gitUrl)\n    } else {\n        //Use memory as DB\n        DB = favdb.NewMemDB()\n    }\n\n    addBookmarkArticle(\"title1\", \"Fav1\")\n    addBookmarkArticle(\"title1\", \"Fav2\")\n}\n\nfunc addBookmarkArticle(user, fav string) {\n    newFavoriteArticle := fav\n    newUser := favdb.UserFavorite{\n        UserId:    user,\n        Favorites: []string{newFavoriteArticle},\n    }\n    if record, err := DB.Get(user); err != nil {\n        //User data is not created, create a new one\n        DB.Add(newUser)\n    } else {\n        //Record found, update it\n        oldRecords := record.Favorites\n        if exist, idx := favdb.InArray(newFavoriteArticle, oldRecords); exist == true {\n            oldRecords = favdb.RemoveStringItem(oldRecords, idx)\n        } else {\n            oldRecords = append(oldRecords, newFavoriteArticle)\n        }\n        record.Favorites = oldRecords\n        DB.Update(record)\n    }\n}\n```\n\nIf you want to run it directly, just run\n\n### Github Issue\n\n```\n    go install github.com/kkdai/photomgr/example/github_issue\n```\n\nContribute\n---------------\n\nPlease open up an issue on GitHub before you put a lot efforts on pull request.\nThe code submitting to PR must be filtered with `gofmt`\n\nLicense\n---------------\n\nThis package is licensed under MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkdai%2Ffavdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkkdai%2Ffavdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkdai%2Ffavdb/lists"}