{"id":26872421,"url":"https://github.com/go-generalize/volcago","last_synced_at":"2025-10-12T19:06:02.011Z","repository":{"id":37855171,"uuid":"434480196","full_name":"go-generalize/volcago","owner":"go-generalize","description":"Model Generator for Firestore","archived":false,"fork":false,"pushed_at":"2025-06-16T05:40:06.000Z","size":716,"stargazers_count":15,"open_issues_count":24,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-12T19:05:47.107Z","etag":null,"topics":["code-generation","firebase","firestore","firestore-database","generator","go","golang","n-grams","ngrams"],"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/go-generalize.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":"2021-12-03T05:43:22.000Z","updated_at":"2025-08-28T13:39:11.000Z","dependencies_parsed_at":"2025-10-12T19:05:50.022Z","dependency_job_id":null,"html_url":"https://github.com/go-generalize/volcago","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/go-generalize/volcago","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-generalize%2Fvolcago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-generalize%2Fvolcago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-generalize%2Fvolcago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-generalize%2Fvolcago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-generalize","download_url":"https://codeload.github.com/go-generalize/volcago/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-generalize%2Fvolcago/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012641,"owners_count":26085158,"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-10-12T02:00:06.719Z","response_time":53,"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":["code-generation","firebase","firestore","firestore-database","generator","go","golang","n-grams","ngrams"],"created_at":"2025-03-31T08:31:51.972Z","updated_at":"2025-10-12T19:06:01.992Z","avatar_url":"https://github.com/go-generalize.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# volcago\n\nAutomatically generate code used by Cloud Firestore.  \n\n[日本語ドキュメント](./docs/ja.md)\n\n# Installation\nRecommend that you drop the binary from the release and use it.  \nAlso, possible with `go install` ↓\n```console\n$ go install github.com/go-generalize/volcago/cmd/volcago@latest\n```\n\n# Usage\n\n```go\npackage task\n\nimport (\n\t\"time\"\n)\n\n//go:generate volcago Task\n\ntype Task struct {\n\tID      string          `firestore:\"-\"           firestore_key:\"\"`\n\tDesc    string          `firestore:\"description\" indexer:\"suffix,like\" unique:\"\"`\n\tDone    bool            `firestore:\"done\"        indexer:\"equal\"`\n\tCount   int             `firestore:\"count\"`\n\tCreated time.Time       `firestore:\"created\"`\n\tIndexes map[string]bool `firestore:\"indexes\"`\n}\n```\nBy writing a line starting with `go:generate`, the model for firestore will be automatically generated.  \n\nWhen used in SubCollection, add the argument `-sub-collection`.  \n\nIf you want to use Meta information (such as CreatedAt and Version used in optimistic exclusive lock) together,\nyou can invalidate it by removing the argument `-disable-meta`.  \n\nThe format of the Meta structure is as follows.\n```go\ntype Meta struct {\n\tCreatedAt time.Time\n\tCreatedBy string\n\tUpdatedAt time.Time\n\tUpdatedBy string\n\tDeletedAt *time.Time\n\tDeletedBy string\n\tVersion   int\n}\n```\n\nAlso, one element in the struct must have an element with `firestore_key:\"\"`.  \nThe type of this element must be `string`.  \nID is automatically generated by setting `firestore_key:\"auto\"`.  \n\nIf you execute `go generate` in this state, the model will be generated in a file with the suffix` _gen.go`.  \n```commandline\n$ go generate\n```\n\n## Unique constraint\nIf there is a tag called `unique`, a document for unique constraints will be generated in another collection called Unique.  \nUse when you do not want to allow duplicates such as phone numbers and email addresses.  \nThe type of this element must be `string`.\n\n## Search diversity\nThe existence of a field called `Indexes` (`map[string]bool` type) enables n-gram search using _**[xim](https://github.com/go-utils/xim)**_.  \nCorresponding search is prefix/suffix/partial/exact match. (tag: prefix/suffix/like/equal)  \nSince _**xim**_ uses only Unigram Bigram, it is prone to noise (eg, when `東京都` searches in `京都`, it hits).\n\n### Search query\nTask.Desc = \"Hello, World!\".\n- Partial match search\n```go\nparam := \u0026model.TaskSearchParam{\n\tDesc: model.NewQueryChainer().Filters(\"o, Wor\", model.FilterTypeAddBiunigrams),\n}\n\ntasks, err := taskRepo.Search(ctx, param, nil)\nif err != nil {\n\t// error handling\n}\n```\n\n- Prefix match search\n```go\nparam := \u0026model.TaskSearchParam{\n\tDesc: model.NewQueryChainer().Filters(\"Hell\", model.FilterTypeAddPrefix),\n}\n\ntasks, err := taskRepo.Search(ctx, param, nil)\nif err != nil {\n\t// error handling\n}\n```\n\n- Suffix match search\n```go\nparam := \u0026model.TaskSearchParam{\n\tDesc: model.NewQueryChainer().Filters(\"orld!\", model.FilterTypeAddSuffix),\n}\n\ntasks, err := taskRepo.Search(ctx, param, nil)\nif err != nil {\n\t// error handling\n}\n```\n\n- Exact match search\n```go\nchainer := model.NewQueryChainer\nparam := \u0026model.TaskSearchParam{\n\tDesc: chainer().Filters(\"Hello, World!\", model.FilterTypeAdd),\n\tDone: chainer().Filters(true, model.FilterTypeAddSomething), // Use Add Something when it is not a string.\n}\n\ntasks, err := taskRepo.Search(ctx, param, nil)\nif err != nil {\n\t// error handling\n}\n```\n\n- Paging search\n```go\nparam := \u0026model.TaskSearchParam{\n\tDone:        model.NewQueryChainer().Equal(true),\n\tCursorLimit: 5,\n\t// CursorKey: \"document id\",\n}\n\ntasks, pagingResult, err := taskRepo.SearchByParam(ctx, param)\nif err != nil {\n\t// error handling\n}\n// pagingResult.NextPagingKey = \"next document id\"\n```\n\n### Query builder\nThe code for the query builder called `query_builder_gen.go` is generated.  \n\n```go\nqb := model.NewQueryBuilder(taskRepo.GetCollection())\nqb.GreaterThan(\"count\", 3)\nqb.LessThan(\"count\", 8)\n\ntasks, err := taskRepo.Search(ctx, nil, qb.Query())\nif err != nil {\n\t// error handling\n}\n```\n\n### Strict update\nUse a function called `StrictUpdate`.  \nBy using this, firestore.Increment etc. can also be used.  \nUniquely constrained fields are not available.\n\n```go\nparam := \u0026model.TaskUpdateParam{\n\tDone:    false,\n\tCreated: firestore.ServerTimestamp,\n\tCount:   firestore.Increment(1),\n}\nif err = taskRepo.StrictUpdate(ctx, id, param); err != nil {\n\t// error handling\n}\n```\n\n## Examples\n[Generated code example.](./examples)\n\n## License\n- Under the [MIT License](./LICENSE)\n- Copyright (C) 2021 go-generalize\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-generalize%2Fvolcago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-generalize%2Fvolcago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-generalize%2Fvolcago/lists"}