{"id":23456672,"url":"https://github.com/nemuba/mongo_api","last_synced_at":"2025-04-11T06:49:34.800Z","repository":{"id":186430208,"uuid":"675170159","full_name":"nemuba/mongo_api","owner":"nemuba","description":"There are a lot of options for connecting to  MongoDB Atlas  as an application developer. One of the newest options is the  MongoDB Atlas Data API . The Atlas Data API provides a lightweight way to connect to MongoDB Atlas that can be thought of as similar to a REST API","archived":false,"fork":false,"pushed_at":"2023-10-12T02:12:53.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T07:05:30.249Z","etag":null,"topics":["api-rest","mongodb-atlas","ruby","service-client"],"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/nemuba.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-08-06T02:53:10.000Z","updated_at":"2023-08-06T12:54:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"40413215-c8d5-45fd-86ec-72941ca9024e","html_url":"https://github.com/nemuba/mongo_api","commit_stats":null,"previous_names":["nemuba/mongo_api"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemuba%2Fmongo_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemuba%2Fmongo_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemuba%2Fmongo_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemuba%2Fmongo_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nemuba","download_url":"https://codeload.github.com/nemuba/mongo_api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248358549,"owners_count":21090401,"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":["api-rest","mongodb-atlas","ruby","service-client"],"created_at":"2024-12-24T04:33:12.020Z","updated_at":"2025-04-11T06:49:34.789Z","avatar_url":"https://github.com/nemuba.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoApi\n\nThe gem 'mongo_api' is a simple wrapper around the MongoDb Atlas Data API to make it easier to use in Ruby applications to access data in MongoDb Atlas.\n\nWelcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mongo_api`. To experiment with that code, run `bin/console` for an interactive prompt.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add mongo_api\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install mongo_api\n\n## Usage\n\nThe gem is a simple wrapper around the MongoDb Atlas Data API to make it easier to use in Ruby applications to access data in MongoDb Atlas.\n\nSet environment variables for the MongoDb Atlas API URL, API Key, Database Name, Collection Name and Data Source Name:\n\n```env\nMONGO_ATLAS_API_URL=https://cloud.mongodb.com/api/atlas/v1.0\nMONGO_ATLAS_API_KEY=1234567890\nMONGO_DATABASE_NAME=sample_mflix\nMONGO_DATASOURCE_NAME=sample_mflix\n```\n\n### Example\n\n```ruby\nrequire 'mongo_api'\n\nclass Users \u003c MongoApi::Base\n  base_url ENV['MONGO_ATLAS_API_URL']\n  default_headers 'Content-Type': 'application/json',\n                  'api-key': ENV['MONGO_ATLAS_API_KEY'],\n                  'Access-Control-Request-Headers': '*'\nend\n\n# Get all users\n# @param [Hash] filter: The query predicate.\n# @param [Hash] sort: The order in which to return matching documents.\nusers = Users.all(limit: 10, sort: { _id: 1 }) # =\u003e [ { \"_id\" =\u003e \"5f9a9a9a9a9a9a9a9a9a9a9a\", \"name\" =\u003e \"John Doe\" }, ... ]\n\n# Insert a new user\n# @param [Hash] document: The document to insert.\nuser = Users.insert({ name: 'Jane Doe' }) # =\u003e {\"insertedId\"=\u003e\"64cf1065f549de65c4908375\"}\n\n# Find a user by name\n# @param [Hash] filter: The query predicate.\n# @param [Hash] projection: The fields to return in the matching document.\n# @param [Hash] sort: The order in which to return matching documents.\n# @param [Integer] limit: The maximum number of documents to return.\nuser = Users.find(filter: { name: 'Jane Doe' }) # =\u003e [ { \"_id\" =\u003e \"5f9a9a9a9a9a9a9a9a9a9a9a\", \"name\" =\u003e \"Jane Doe\" } ]\n\n# Update a user\n# @param [Hash] where: The query predicate.\n# @param [Hash] set: The fields to update in the matching document.\nuser = Users.update(where: { name: 'Jane Doe' }, set: { name: 'Jane Smith' }) # =\u003e {\"matchedCount\"=\u003e1, \"modifiedCount\"=\u003e1}\n\n# Update All users\n# @param [Hash] where: The query predicate.\n# @param [Hash] set: The fields to update in the matching document.\nuser = Users.update_all(where: { name: 'Jane Smith' }, set: { name: 'Jane Doe' }) # =\u003e {\"matchedCount\"=\u003e1, \"modifiedCount\"=\u003e1}\n\n# Destroy a user\n# @param [Hash] where: The query predicate.\nuser = Users.destroy(where: { name: 'Jane Smith' }) # =\u003e {\"deletedCount\"=\u003e1}\n\n# Destroy All users\n# @param [Hash] where: The query predicate.\nuser = Users.destroy_all(where: { name: 'Jane Smith' }) # =\u003e {\"deletedCount\"=\u003e1}    \n\n# Count users\nuser = Users.count # =\u003e 10\n\n# Others methods\nUsers.find_one(filter: {}, :projection: {})\nUsers.insert_one({})\nUsers.insert_many([{}, {}])\nUsers.update_one(filter: {}, :update: {}, upsert: false)\nUsers.update_many(filter: {}, :update: {}, upsert: false)\nUsers.delete_one(filter: {})\nUsers.delete_many(filter: {})\nUsers.replace_one(filter: {}, replacement: {}, upsert: false)\nUsers.aggregate(pipeline: [])\nUsers.count\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mongo_api.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemuba%2Fmongo_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemuba%2Fmongo_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemuba%2Fmongo_api/lists"}