https://github.com/databasecleaner/database_cleaner-mongoid
https://github.com/databasecleaner/database_cleaner-mongoid
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/databasecleaner/database_cleaner-mongoid
- Owner: DatabaseCleaner
- License: mit
- Created: 2016-05-16T01:51:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T03:09:24.000Z (over 2 years ago)
- Last Synced: 2025-04-21T11:59:11.895Z (2 months ago)
- Language: Ruby
- Size: 1.07 MB
- Stars: 9
- Watchers: 6
- Forks: 8
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Database Cleaner Adapter for Mongoid
[](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongoid)
[](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongoid)
[](https://codecov.io/gh/DatabaseCleaner/database_cleaner-mongoid)Clean your Mongoid databases with Database Cleaner.
See https://github.com/DatabaseCleaner/database_cleaner for more information.
## Installation
```ruby
# Gemfile
group :test do
gem 'database_cleaner-mongoid'
end
```## Supported Strategies
The mongoid adapter only has one strategy: the deletion strategy.
## Strategy configuration options
`:only` and `:except` may take a list of collection names:
```ruby
# Only delete the "users" collection.
DatabaseCleaner[:mongoid].strategy = [:deletion, only: ["users"]]# Delete all collections except the "users" collection.
DatabaseCleaner[:mongoid].strategy = [:deletion, except: ["users"]]
```## Adapter configuration options
`#db` defaults to the default Mongoid database, but can be specified manually in a few ways:
```ruby
# Redis URI string:
DatabaseCleaner[:mongoid].db = :logs# Back to default:
DatabaseCleaner[:mongoid].db = :default# Multiple Mongoid databases can be specified:
DatabaseCleaner[:mongoid, db: :default]
DatabaseCleaner[:mongoid, db: :shard_1]
DatabaseCleaner[:mongoid, db: :shard_2]
```## COPYRIGHT
See [LICENSE](LICENSE) for details.