Skip to content

Commit

Permalink
Add Index for CVEs
Browse files Browse the repository at this point in the history
  • Loading branch information
AgoraSecurity authored and jtozo committed Aug 7, 2020
1 parent bfced02 commit 670adc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/seed
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ Dir.glob(files).sort.each do |infile|
CVEServer::Cve.bulk_create(@doc.all_cve)
end
puts "Reducing the cpe list"
CVEServer::Cve.reduce_cpes
CVEServer::Cve.reduce_cpes
puts 'Creating CVE collection Index'
CVEServer::Cve.create_index(:cve)
4 changes: 4 additions & 0 deletions lib/cve_server/db/mongo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def bulk_create(data)
db[@collection].bulk_write(inserts, ordered: true)
end

def create_index(param)
db[@collection].indexes.create_one( { param => 1 } )
end

def drop_all
db[@collection].drop
end
Expand Down

0 comments on commit 670adc3

Please sign in to comment.