{"id":18273238,"url":"https://github.com/spacetab-io/mpath-go","last_synced_at":"2025-07-16T10:35:37.932Z","repository":{"id":57519017,"uuid":"232835218","full_name":"spacetab-io/mpath-go","owner":"spacetab-io","description":"Golang package for MPTT (Modified Preorder Tree Traversal) - materialized path realisation.","archived":false,"fork":false,"pushed_at":"2020-01-13T06:49:07.000Z","size":10,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T21:19:26.088Z","etag":null,"topics":["database","go","golang","materialized-path","mpath","mptt","tree","tree-structure"],"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/spacetab-io.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}},"created_at":"2020-01-09T15:04:45.000Z","updated_at":"2023-09-28T07:48:10.000Z","dependencies_parsed_at":"2022-09-26T18:00:52.129Z","dependency_job_id":null,"html_url":"https://github.com/spacetab-io/mpath-go","commit_stats":null,"previous_names":["spacetab-io/mpath"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fmpath-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fmpath-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fmpath-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spacetab-io%2Fmpath-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spacetab-io","download_url":"https://codeload.github.com/spacetab-io/mpath-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247279399,"owners_count":20912877,"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":["database","go","golang","materialized-path","mpath","mptt","tree","tree-structure"],"created_at":"2024-11-05T12:05:44.329Z","updated_at":"2025-04-05T02:31:13.180Z","avatar_url":"https://github.com/spacetab-io.png","language":"Go","funding_links":[],"categories":["Database","数据库","数据库  `go语言实现的数据库`","Uncategorized"],"sub_categories":["Advanced Console UIs","SQL 查询语句构建库","SQL查询生成器"],"readme":"# mpath-go\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/spacetab-io/mpath-go)](https://goreportcard.com/report/github.com/spacetab-io/mpath-go) \n[![CircleCI](https://circleci.com/gh/spacetab-io/mpath-go.svg?style=shield)](https://circleci.com/gh/spacetab-io/mpath-go)\n[![codecov](https://codecov.io/gh/spacetab-io/mpath-go.svg/graph/badge.svg)](https://codecov.io/gh/spacetab-io/mpath-go)\n\nGolang realisation of MPTT (or modified preorder tree traversal) in materialized path way.\n\n## About\n\nIt provides interfaces which yor database object should implement.\n\nYour database object should store:\n* `path` property as slice of uint64 IDs of materialized path to this object in traversal tree;\n* `position` property as integer for determine the order of leafs in tree \n\n## Usage\n\nImplementation example and tests are in [test file](/mpath_test.go).\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/spacetab-io/mpath\"\n)\n\ntype TestItems []*TestItem\n\ntype TestItem struct {\n    ID       uint64\n    Path     []uint64\n    Position int\n    Siblings TestItems\n    Name     string\n}\n\n// Leaf interface implementation for TestItem\n// ...\n// Leafs interface implementation for TestItems\n// ...\n\nfunc main() {\n    flatItemsSlice := getTestItems()\n\n    var parent = TestItem{}\n    if err := mpath.InitTree(\u0026parent, flatItemsSlice); err != nil {\n        panic(\"error tree init\")\n    }\n    \n    fmt.Print(parent)\n}\n\nfunc getTestItems() *TestItems {\n    return \u0026TestItems{\n        {ID: 1, Position: 0, Name: \"item 1\", Path: []uint64{1}},\n        {ID: 2, Position: 0, Name: \"item 2\", Path: []uint64{1, 2}},\n        {ID: 3, Position: 1, Name: \"item 3\", Path: []uint64{1, 3}},\n        {ID: 4, Position: 0, Name: \"item 4\", Path: []uint64{1, 2, 4}},\n        {ID: 5, Position: 1, Name: \"item 5\", Path: []uint64{1, 2, 5}},\n        {ID: 6, Position: 0, Name: \"item 6\", Path: []uint64{1, 3, 6}},\n    }\n}\n```\n\n## Tests\n\n    go test ./... -v -race\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacetab-io%2Fmpath-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspacetab-io%2Fmpath-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspacetab-io%2Fmpath-go/lists"}