{"id":26197275,"url":"https://github.com/mongoid/mongoid-shell","last_synced_at":"2025-04-15T03:55:41.347Z","repository":{"id":6613161,"uuid":"7856610","full_name":"mongoid/mongoid-shell","owner":"mongoid","description":"Derive shell commands from Mongoid sessions and configuration options.","archived":false,"fork":false,"pushed_at":"2017-12-21T23:07:11.000Z","size":106,"stargazers_count":14,"open_issues_count":2,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T03:55:35.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mongoid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-27T19:11:30.000Z","updated_at":"2019-08-13T15:15:13.000Z","dependencies_parsed_at":"2022-08-20T23:40:33.394Z","dependency_job_id":null,"html_url":"https://github.com/mongoid/mongoid-shell","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoid","download_url":"https://codeload.github.com/mongoid/mongoid-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003952,"owners_count":21196794,"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":"2025-03-12T02:25:18.182Z","updated_at":"2025-04-15T03:55:41.332Z","avatar_url":"https://github.com/mongoid.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mongoid::Shell\n==============\n\n[![Gem Version](https://badge.fury.io/rb/mongoid-shell.svg)](https://badge.fury.io/rb/mongoid-shell)\n[![Build Status](https://travis-ci.org/mongoid/mongoid-shell.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-shell)\n[![Dependency Status](https://gemnasium.com/mongoid/mongoid-shell.svg)](https://gemnasium.com/mongoid/mongoid-shell)\n[![Code Climate](https://codeclimate.com/github/mongoid/mongoid-shell.svg)](https://codeclimate.com/github/mongoid/mongoid-shell)\n\nCreate mongo command-lines from Mongoid configuration.\n\nFor example, connect to your production database without having to remember the entire command line using a `db:production:shell` Rake task.\n\n``` ruby\nnamespace :db\n  namespace :production\n    task :shell\n      Mongoid.load! File.join(Rails.root, \"config/mongoid.yml\"), :production\n      system Mongoid::Shell::Commands::Mongo.new.to_s\n    end\n  end\nend\n```\n\nCommands can be created for the current default session or you can pass a session as an argument to a new command.\n\n``` ruby\nMongoid::Shell::Commands::Mongodump.new # will use Mongoid.default_session\nMongoid::Shell::Commands::Mongodump.new(session: Moped::Session.new([ \"127.0.0.1:27017\" ]))\n```\n\nCommands accept parameters.\n\n``` ruby\nout = File.join(Dir.tmpdir, 'db_backup')\nmongodump = Mongoid::Shell::Commands::Mongodump.new(db: 'another_database', out: out)\nsystem mongodump.to_s # mongodump --db another_database --out /tmp/db_backup\n```\n\nTo specify parameters multiple times, set them to arrays.\n\n``` ruby\nmongodump = Mongoid::Shell::Commands::Mongodump.new(excludeCollection: %w(users products))\nsystem mongodump.to_s # mongodump --excludeCollection users --excludeCollection products\n```\n\nTo use output in logs, pass the `mask_sensitive` option to `to_s`.\n\n``` ruby\n\u003e Mongoid::Shell::Commands::Mongo.new.to_s(mask_sensitive: true)\n =\u003e \"mongo 59.1.22.1:27017/mongoid --username user --password ********\"\n\n\u003e Mongoid::Shell::Commands::Mongo.new.to_s(mask_sensitive: '(masked)')\n =\u003e \"mongo 59.1.22.1:27017/mongoid --username user --password (masked)\"\n```\n\nCompatibility\n-------------\n\nThis gem supports Mongoid 3, 4, 5 and 6.\n\nSupported Commands\n------------------\n\n### Mongo\n\nThe mongo shell is an interactive JavaScript shell for MongoDB. The `Mongoid::Shell::Commands::Mongo` class generates a command line to connect to MongoDB. A particularly useful feature is that it will always yield the address of the master node of a MongoDB replica set.\n\n``` ruby\nMongoid::Shell::Commands::Mongo.new.to_s\n```\n\nSupports `--username`, `--password`, `--eval`, `--nodb`, `--norc`, `--quiet`, `--ipv6`, `--ssl` and `--authenticationDatabase`.\n\n### Mongodump\n\nMongodump is a utility for creating a binary export of the contents of a database.\n\n``` ruby\nmongodump = Mongoid::Shell::Commands::Mongodump.new(collection: 'test')\nmongodump.to_s # mongodump --db test --collection test\n```\n\nThe `Mongoid::Shell::Commands::Mongodump` class supports `--db`, `--host`, `--username`, `--password`, `--query`, `--out`, `--collection`, `--excludeCollection`, `--excludeCollectionsWithPrefix`, `--directoryperdb`, `--journal`, `--oplog`, `--repair`, `--forceTableScan`, `--dbpath`, `--ipv6`, `--ssl` and `--authenticationDatabase`\n\n### Mongorestore\n\nThe mongorestore tool imports content from binary database dump, created by mongodump into a specific database.\n\n``` ruby\nmongorestore = Mongoid::Shell::Commands::Mongorestore.new(collection: 'test', restore: '/tmp/db_backup')\nmongorestore.to_s # mongorestore --db test --collection test /tmp/db_backup\n```\n\nThe `Mongoid::Shell::Commands::Mongorestore` class supports `--db`, `--host`, `--username`, `--password`, `--collection`, `--ipv6`, `--dbpath`, `--directoryperdb`, `--journal`, `--objcheck`, `--filter`, `--drop`, `--oplogReplay`, `--keepIndexVersion`, `--noIndexRestore`, `--ssl` and `--authenticationDatabase`\n\n### Mongoexport\n\nThe mongoexport tool produces a JSON or CSV export of data stored in a MongoDB instance.\n\n``` ruby\nmongoexport = Mongoid::Shell::Commands::Mongoexport.new(collection: 'traffic', out: 'traffic.json')\nmongoexport.to_s # mongoexport --db test --collection traffic --out traffic.json\n```\n\nThe `Mongoid::Shell::Commands::Mongoexport` class supports `--verbose`, `--quiet`, `--version`, `--port`, `--ipv6`, `--ssl`, `--sslCAFile`, `--sslPEMKeyFile`, `--sslPEMKeyPassword`, `--sslCRLFile`, `--sslAllowInvalidCertificates`, `--sslAllowInvalidHostnames`, `--sslFIPSMode`, `--authenticationDatabase`, `--authenticationMechanism`, `--gssapiServiceName`, `--gssapiHostName`, `--collection`, `--fields`, `--fieldFile`, `--query`, `--csv`, `--type`, `--out`, `--jsonArray`, `--pretty`, `--slaveOk`, `--forceTableScan`, `--skip`, `--limit`, `--sort`, `--directoryperdb`, `--journal`, `--dbpath`.\n\n### Mongoimport\n\nThe mongoimport tool imports content from an Extended JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool.\n\n\n``` ruby\nmongoimport = Mongoid::Shell::Commands::Mongoimport.new(collection: 'contacts', file: 'contacts.json')\nmongoimport.to_s # mongoimport --db test --collection contacts --file contacts.json\n```\n\nThe `Mongoid::Shell::Commands::Mongoimport` class supports `--verbose`, `--quiet`, `--version`, `--host`, `--username`, `--password`, `--port`, `--ipv6`, `--ssl`, `--sslCAFile`, `--sslPEMKeyFile`, `--sslPEMKeyPassword`, `--sslCRLFile`, `--sslAllowInvalidCertificates`, `--sslAllowInvalidHostnames`, `--sslFIPSMode`, `--authenticationDatabase`, `--authenticationMechanism`, `--gssapiServiceName`, `--gssapiHostName`, `--db`, `--collection`, `--fields`, `--directoryperdb`, `--journal`, `--dbpath`, `--fieldFile`, `--ignoreBlanks`, `--type`, `--file`, `--drop`, `--headerline`, `--upsert`, `--upsertFields`, `--stopOnError`, `--jsonArray`, `--maintainInsertionOrder`, `--numInsertionWorkers`, `--writeConcern`.\n\n### Mongostat\n\nThe mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance.\n\nThe `Mongoid::Shell::Commands::Mongostat` class supports `--host`, `--username`, `--password`, `--rowcount`, `--discover`, `--noheaders`, `--http`, `--all`, `--ssl` and `--authenticationDatabase`.\n\nContributing\n------------\n\nFork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.\n\nCopyright and License\n---------------------\n\nMIT License, see [LICENSE](http://github.com/mongoid/mongoid-shell/raw/master/LICENSE.md) for details.\n\n(c) 2013-2016 [Daniel Doubrovkine](http://github.com/dblock), [Artsy Inc.](http://artsy.net)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoid%2Fmongoid-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoid%2Fmongoid-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoid%2Fmongoid-shell/lists"}