mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Skip system collections at mongo-level rather than using reject
Relaxed regexp: skips collections like `<database_name>.$cmd`
This commit is contained in:
parent
0917ac10b8
commit
ecc2951c59
1 changed files with 1 additions and 4 deletions
|
@ -24,12 +24,9 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
if db_version.split('.').first.to_i >= 3
|
||||
session.command(listCollections: 1)['cursor']['firstBatch'].map do |collection|
|
||||
session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection|
|
||||
collection['name']
|
||||
end
|
||||
.reject do |collection_name|
|
||||
collection_name =~ /\.system\.|\$/
|
||||
end
|
||||
else
|
||||
session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
|
||||
_, name = collection['name'].split('.', 2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue