Skip to content

Instantly share code, notes, and snippets.

@mrjones-plip
Last active May 29, 2024 19:42
Show Gist options
  • Save mrjones-plip/12db2e5593fa7bd22e2c8d86a1e36ac6 to your computer and use it in GitHub Desktop.
Save mrjones-plip/12db2e5593fa7bd22e2c8d86a1e36ac6 to your computer and use it in GitHub Desktop.
Upload JSON document to CouchDB 10x per Y seconds
#!/bin/bash
server="192-168-68-26.local-ip.medicmobile.org:10443"
database="medic"
login="medic"
password="password"
sleep=59
createRecord(){
json='{
"parent": {
"_id": "ee003566-3e7d-4426-85ef-8aef76e5bb28"
},
"type": "person",
"name": "test2",
"short_name": "",
"date_of_birth": "2002-03-29",
"date_of_birth_method": "approx",
"ephemeral_dob": {
"age_label": "",
"age_years": "22",
"age_months": "2",
"dob_method": "approx",
"dob_approx": "2002-03-29T00:00:00.000-08:00",
"dob_raw": "2002-03-29T00:00:00.000-08:00",
"dob_iso": "2002-03-29"
},
"sex": "female",
"phone": "",
"phone_alternate": "",
"role": "patient",
"external_id": "",
"notes": "",
"user_for_contact": {
"create": "false"
},
"meta": {
"created_by": "medic",
"created_by_person_uuid": "",
"created_by_place_uuid": ""
},
"reported_date": 1717008582883,
"patient_id": "83252"
}'
result=$(curl -qs -H 'Content-Type: application/json' -X POST https://${login}:${password}@${server}/${database} -d "$json")
id=$(echo "$result" | jq -j .id)
echo "Created https://${server}/_utils/#/database/${database}/${id}"
}
while true
do
for run in {1..10}
do
createRecord
done
echo "Sleeping for ${sleep} seconds"
sleep ${sleep}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment