mongogems 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/compass2mongosh +29 -0
- data/lib/savedPipeline.rb +31 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e52d3b09b0c7415673e2fb1ee195a179299157132d571ff13c992379018de51f
|
4
|
+
data.tar.gz: 57811b85a6d413440b726e8cab1e574b9834d45cfa76fc1b30bfeca9f0f0f0c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b887419212f6a2f6b9343d8e46771d12d4d854e10d8ec9cf8c5c1fbb2fe2cca856be3def29fd507eaac184a79d642689a195b7e569c798a37403d3019557ab6
|
7
|
+
data.tar.gz: dfd7d7c251d96ca5dbf3313682bd97193112d6cb83dd6140ff5c66cff5ddfe0634cd2ac98ff9b83cdfce96d7d9ca0a09f3add292955eaf1e25f8ea83bab1c1dc
|
data/bin/compass2mongosh
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require_relative '../lib/savedPipeline'
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = 'Usage: compass2mongosh [options]'
|
9
|
+
|
10
|
+
opts.on('-i', '--input=INFILE', 'Input file from compass') do |val|
|
11
|
+
options[:input] = val
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on('-o', '--output=OUTFILE', 'Output file to write to') do |val|
|
15
|
+
options[:output] = val
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('-h', '--help', 'Help') do |val|
|
19
|
+
puts opts
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end.parse!
|
23
|
+
|
24
|
+
if options[:input].nil?
|
25
|
+
puts 'Missing arguments. Execute with -h for help'
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
pipeline_to_mongosh_script options[:input], options[:output]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# filename = '/Users/nitin/Downloads/Zaloni-DQ-A/607d7460cb21963a143d1d0f.json'
|
4
|
+
|
5
|
+
def pipeline_to_mongosh_script(infile, outfile)
|
6
|
+
txt = File.read(infile)
|
7
|
+
data = JSON.parse(txt)
|
8
|
+
|
9
|
+
ns_split = data['namespace'].split '.', 2
|
10
|
+
dbname = ns_split[0]
|
11
|
+
collname = ns_split[1]
|
12
|
+
|
13
|
+
the_pipeline = []
|
14
|
+
data['pipeline'].each do |pstage|
|
15
|
+
the_pipeline.push pstage['executor']
|
16
|
+
end
|
17
|
+
|
18
|
+
mongosh_script_out =
|
19
|
+
"
|
20
|
+
//Query name: #{data['name']}
|
21
|
+
use #{dbname};
|
22
|
+
db.#{collname}.aggregate(
|
23
|
+
#{JSON.generate the_pipeline}
|
24
|
+
, {allowDiskUse: true}
|
25
|
+
);
|
26
|
+
"
|
27
|
+
|
28
|
+
File.write(outfile, mongosh_script_out)
|
29
|
+
end
|
30
|
+
|
31
|
+
# pipeline_to_mongosh_script filename, '/dev/null'
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongogems
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Katkam Nitin Reddy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables:
|
16
|
+
- compass2mongosh
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/compass2mongosh
|
21
|
+
- lib/savedPipeline.rb
|
22
|
+
homepage:
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.2.12
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: MongoDB Utilities
|
44
|
+
test_files: []
|