Revision 353733643036 () - Diff

Link to this snippet: https://friendpaste.com/1Z1pBlZ8x4GemalOxBvYQq
Embed:
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
#!/bin/sh

if [ -z "$port" ]; then
echo "Need \$port"
exit 1
fi

couch="http://localhost:$port"
URL="$couch/db1"

curl -XPUT "$couch/_config/couchdb/file_compression" -d '"none"'
curl -s -X DELETE $URL > /dev/null
curl -s -X PUT $URL > /dev/null

echo "Filling db."
prefix='['
( echo '{"docs":'
for COUNT in {0..50000}; do
echo "$prefix {\"number\":$COUNT}"
prefix=','
done
echo ']}'
) | curl -s -Hcontent-type:application/json -d @- "$URL/_bulk_docs" > /dev/null

echo "done"
curl -i "$URL"

curl -s $URL/_design/foo -X PUT -d '{"views":{"bar":{"map":"function(doc) {emit(doc.number, doc.number);}"}}}' > /dev/null

echo "Building view."
time curl -s "$URL/_design/foo/_view/bar?limit=1" > /dev/null
echo "done"