{"id":15372970,"url":"https://github.com/rs/rest-layer-mongo","last_synced_at":"2025-04-15T12:31:33.316Z","repository":{"id":46580722,"uuid":"40513848","full_name":"rs/rest-layer-mongo","owner":"rs","description":"REST Layer MongoDB resource storage handler","archived":false,"fork":false,"pushed_at":"2021-10-04T21:23:47.000Z","size":53,"stargazers_count":18,"open_issues_count":1,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T21:11:29.225Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rs.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":"2015-08-11T01:04:37.000Z","updated_at":"2021-10-04T21:23:50.000Z","dependencies_parsed_at":"2022-09-16T07:00:19.854Z","dependency_job_id":null,"html_url":"https://github.com/rs/rest-layer-mongo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2Frest-layer-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2Frest-layer-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2Frest-layer-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rs%2Frest-layer-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rs","download_url":"https://codeload.github.com/rs/rest-layer-mongo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072233,"owners_count":21208141,"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":[],"created_at":"2024-10-01T13:53:51.030Z","updated_at":"2025-04-15T12:31:33.066Z","avatar_url":"https://github.com/rs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST Layer MongoDB Backend\n\n[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/rs/rest-layer-mongo) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/rest-layer-mongo/master/LICENSE) [![build](https://img.shields.io/travis/rs/rest-layer-mongo.svg?style=flat)](https://travis-ci.org/rs/rest-layer-mongo)\n\nThis [REST Layer](https://github.com/rs/rest-layer) resource storage backend stores data in a MongoDB cluster using [mgo](https://godoc.org/labix.org/v2/mgo).\n\n## Usage\n\n```go\nimport \"github.com/rs/rest-layer-mongo\"\n```\n\nCreate a mgo master session:\n\n```go\nsession, err := mgo.Dial(url)\n```\n\nCreate a resource storage handler with a given DB/collection:\n\n```go\ns := mongo.NewHandler(session, \"the_db\", \"the_collection\")\n```\n\nUse this handler with a resource:\n\n```go\nindex.Bind(\"foo\", foo, s, resource.DefaultConf)\n```\n\nYou may want to create a many mongo handlers as you have resources as long as you want each resources in a different collection. You can share the same `mgo` session across all you handlers.\n\n### Object ID\n\nThis package also provides a REST Layer [schema.Validator](https://godoc.org/github.com/rs/rest-layer/schema#Validator) for MongoDB ObjectIDs. This validator ensures proper binary serialization of the Object ID in the database for space efficiency.\n\nYou may reference this validator using [mongo.ObjectID](https://godoc.org/github.com/rs/rest-layer-mongo#ObjectID) as [schema.Field](https://godoc.org/github.com/rs/rest-layer/schema#Field).\n\nA `mongo.NewObjectID` field hook and `mongo.ObjectIDField` helper are also provided.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frs%2Frest-layer-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frs%2Frest-layer-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frs%2Frest-layer-mongo/lists"}