Skip to content

Commit 6faa5f4

Browse files
authored
Merge pull request #19 from couchbase-examples/devadv-2050
Devadv 2050
2 parents 028ea1f + 326980f commit 6faa5f4

File tree

105 files changed

+5189
-1234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+5189
-1234
lines changed

assets/atlanta.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/austin.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/bangalore.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/bloomington.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/charleston.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/coloradosprings.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/createBeerItems.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#
3+
# Directions:
4+
#
5+
# must create the database first using something like this
6+
# ./mac/cblite --create startingWarehouses.cblite2
7+
#
8+
# next must run script to create items
9+
# python3 item_gen.py
10+
#
11+
# note taking this script can take a while to create 100,000 records
12+
#
13+
14+
filename="beer_items.json" #data file
15+
dbFileName='startingWarehouses.cblite2' #database file
16+
17+
length=3000 # only get 3000 items to put in the database
18+
19+
#loop through child array to get values out and save as seperate documents
20+
for ((count=0;count<$length;count++))
21+
do
22+
itemIndex=".[$count]" #get the json index for the current element in the array
23+
idIndex=".itemId" #get the field that we want to use the name the file
24+
25+
26+
json=$(cat $filename | jq $itemIndex) #get the full json of an item
27+
id=$(echo $json | jq $idIndex) #get the value of the itemId field
28+
29+
# add to the database (if you are on a different platform
30+
# change the folder location of cblite)
31+
./mac/cblite put --create $dbFileName $id "$json"
32+
done
33+
34+
# you can check by listing the files in the database
35+
# $cblite ls -l --limit 10 $dbFileName

assets/createWarehouses.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# must create the database first using something like this
3+
# ./mac/cblite --create startingWarehouses.cblite2
4+
#define filename
5+
filename="warehouse.json"
6+
dbFileName='startingWarehouses.cblite2'
7+
8+
#get amount of records to get out of file and split into new files
9+
length=`cat $filename | jq -r '. | length'`
10+
11+
#loop through child array to get values out and save as seperate documents
12+
for ((count=0;count<$length;count++))
13+
do
14+
#get the json index for the current element in the array
15+
itemIndex=".[$count]"
16+
17+
#get the field that we want to use the name the file
18+
idIndex=".warehouseId"
19+
20+
#get the json
21+
json=$(cat $filename | jq $itemIndex)
22+
id=$(echo $json | jq $idIndex)
23+
./mac/cblite put --create $dbFileName $id "$json"
24+
done
25+
26+
# you can check by listing the files in the database
27+
# $cblite ls -l --limit 10 $dbFileName

assets/create_db.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

assets/denver.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)