{"id":15679608,"url":"https://github.com/jnunemaker/adapter-mongo","last_synced_at":"2026-03-06T04:36:23.422Z","repository":{"id":1372435,"uuid":"1324289","full_name":"jnunemaker/adapter-mongo","owner":"jnunemaker","description":"Adapter for mongo","archived":false,"fork":false,"pushed_at":"2015-12-30T22:32:08.000Z","size":42,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T10:06:14.112Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/jnunemaker.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":"2011-02-03T14:36:48.000Z","updated_at":"2023-11-30T02:04:44.000Z","dependencies_parsed_at":"2022-07-07T06:32:50.116Z","dependency_job_id":null,"html_url":"https://github.com/jnunemaker/adapter-mongo","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/jnunemaker/adapter-mongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fadapter-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fadapter-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fadapter-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fadapter-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jnunemaker","download_url":"https://codeload.github.com/jnunemaker/adapter-mongo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fadapter-mongo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30161886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T04:22:03.816Z","status":"ssl_error","status_checked_at":"2026-03-06T04:22:00.183Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-03T16:33:33.823Z","updated_at":"2026-03-06T04:36:23.388Z","avatar_url":"https://github.com/jnunemaker.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adapter-mongo\n\nMongo adapter for adapter gem.\n\n```ruby\nrequire 'adapter/mongo'\n\nkey     = BSON::ObjectId.new\nclient  = Mongo::MongoClient.new.db('adapter')['testing']\nadapter = Adapter[:mongo].new(client)\nadapter.clear\n\nadapter.write(key, {'some' =\u003e 'thing'})\nputs 'Should be {\"some\" =\u003e \"thing\"}: ' + adapter.read(key).inspect\n\nadapter.delete(key)\nputs 'Should be nil: ' + adapter.read(key).inspect\n\nadapter.write(key, {'some' =\u003e 'thing'})\nadapter.clear\nputs 'Should be nil: ' + adapter.read(key).inspect\n\nputs 'Should be {\"some\" =\u003e \"thing\"}: ' + adapter.fetch(key, {'some' =\u003e 'thing'}).inspect\n```\n\n## Flavors\n\nThere are two adapters included with this gem -- `:mongo` and `:mongo_atomic`. `:mongo` assumes that you are writing the full document each time. `:mongo_atomic` allows for partially updating documents. The difference is best shown with a bit of code.\n\n```ruby\nrequire 'adapter/mongo_atomic'\n\nkey            = BSON::ObjectId.new\nfull_doc       = {'a' =\u003e 'c', 'b' =\u003e 'd'}\npartial_doc    = {'a' =\u003e 'z'}\nclient         = Mongo::MongoClient.new.db('adapter')['testing']\nadapter        = Adapter[:mongo].new(client)\natomic_adapter = Adapter[:mongo_atomic].new(client)\n\nadapter.clear\natomic_adapter.clear\n\nadapter.write(key, full_doc)\nadapter.write(key, partial_doc)\n\ndoc = adapter.read(key)\ndoc.delete('_id')\n\n# full doc must always be written with :mongo adapter\nputs 'Should be {\"a\"=\u003e\"z\"}: ' + doc.inspect\n\natomic_adapter.write(key, full_doc)\natomic_adapter.write(key, partial_doc)\n\ndoc = atomic_adapter.read(key)\ndoc.delete('_id')\n\n# partial updates can be written with atomic adapter as $set is used\nputs 'Should be {\"a\"=\u003e\"z\", \"b\"=\u003e\"d\"}: ' + doc.inspect\n```\n\nSee examples/ or specs/ for more usage.\n\n## Contributing\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so we don't break it in a future version unintentionally.\n* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine, but bump version in a commit by itself so we can ignore when we pull)\n* Send us a pull request. Bonus points for topic branches.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnunemaker%2Fadapter-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnunemaker%2Fadapter-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnunemaker%2Fadapter-mongo/lists"}