In this seventh part of the salesforce DX series, I am going to show how to use salesforce DX data commands to migrate the sample data from the scratch org to sandbox for testing or you can create data into the scratch org from the CLI.
Use force:data:soql:query command to Executes a SOQL query as shoe below.This Command will help if you wanted to retrieve data into CLI from scratch org without login. Use -t for tooling API
sfdx force:data:soql:query -q "Select id , Name ,Passenger_Code__c,Reg_Number__c ,Vehicle_Id__c from Vehicle__c"
sfdx force:data:soql:query -q "SELECT Name FROM ApexTrigger" -t
Exports data from an org into the sObject tree format as shown below
sfdx force:data:tree:export -q "select Id,Name, Passenger_Code__c, Reg_Number__c, Vehicle_Id__c,(Select Id,Name,Office_Id__c,Violations_Id__c from Violations__r) from Vehicle__c " -x export-demo -d /force-app/data
Above Command Inserts or updates records from a CSV file with one or more batch based on the CSV, file size and Returns a job ID and a batch ID. Use these IDs to check job status with data:bulk: status as shown below.
sfdx force:data:bulk:status -i 750xx000000005sAAA
Below are some of the useful reference about salesforce DX