forked from Clever/ARCHIVED-mongo-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_examples.sh
executable file
·68 lines (62 loc) · 2.05 KB
/
gen_examples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
rm links.txt
# generates README images. "gem install cloudapp"
# 1
mongo test-db --quiet --eval 'db.foo.remove(); db.foo.insert([
{
"_id" : ObjectId("000000000000000000000001"),
"other_foo" : ObjectId("000000000000000000000002")
},
{
"_id" : ObjectId("000000000000000000000002"),
"other_foo" : ObjectId("000000000000000000000001")
}])'
mongoexport --db test-db --collection foo | ./cli.js | dot -Tpng -o out.png
cloudapp -d out.png >> temp.txt
# 2
mongo test-db --quiet --eval 'db.foo.remove(); db.foo.insert([
{
"_id" : ObjectId("000000000000000000000001"),
"bar" : ObjectId("000000000000000000000003")
},
{
"_id" : ObjectId("000000000000000000000002"),
"bar" : ObjectId("000000000000000000000004")
}])'
mongo test-db --quiet --eval 'db.bar.remove(); db.bar.insert([
{
"_id" : ObjectId("000000000000000000000003"),
},
{
"_id" : ObjectId("000000000000000000000004"),
}])'
mongoexport --jsonArray --db test-db --collection foo | json -e 'this.__collection="foo"' > foo.in
mongoexport --jsonArray --db test-db --collection bar | json -e 'this.__collection="bar"' > bar.in
cat foo.in bar.in | ./cli.js | dot -Tpng -o out.png
cloudapp -d out.png >> temp.txt
# 3
mongo test-db --quiet --eval 'db.foo.remove(); db.foo.insert([
{
"_id" : ObjectId("000000000000000000000001"),
"bar" : ObjectId("000000000000000000000003"),
"human_readable": "1"
},
{
"_id" : ObjectId("000000000000000000000002"),
"bar" : ObjectId("000000000000000000000004"),
"human_readable": "2"
}])'
mongo test-db --quiet --eval 'db.bar.remove(); db.bar.insert([
{
"_id" : ObjectId("000000000000000000000003"),
"human_readable": "3"
},
{
"_id" : ObjectId("000000000000000000000004"),
"human_readable": "4"
}])'
mongoexport --jsonArray --db test-db --collection foo | json -e 'this.__collection="foo"; this.__label=this.human_readable' > foo.in
mongoexport --jsonArray --db test-db --collection bar | json -e 'this.__collection="bar"; this.__label=this.human_readable' > bar.in
cat foo.in bar.in | ./cli.js | dot -Tpng -o out.png
cloudapp -d out.png >> temp.txt
cat temp.txt