Skip to content

Instantly share code, notes, and snippets.

@mshanemc
Created November 30, 2017 20:57
Show Gist options
  • Save mshanemc/f275b3440840fd41278b368e76b4955b to your computer and use it in GitHub Desktop.
Save mshanemc/f275b3440840fd41278b368e76b4955b to your computer and use it in GitHub Desktop.
Moving data around in sfdx
# query the data like this gives you a json file
sfdx force:data:tree:export -q "select Bikes_Sold__c, Region__c from Dealer__c" -u cg1 -d data
# Problem: there's no query to CSV for bulk api upsert use. So we have to parse/convert that json.
# uses npm packages jq and json2csv
# convert to csv for bulk API
cat data/Dealer__c.json | jq .records | jq 'map(del(.attributes))' | json2csv -o data/Dealer__c.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment