The code I pasted below represents a simplified version of a reoccurring issue I am having with jsforce. I would like to find a record based on a specific field, and then delete that specific record. However, As the below code and results demonstrate, conn.sobject("Contact").find() seems to me to run asynchronously, so the print function to print the discovered salesforce id is run before the salesforce id is even found.
How would you suggest fixing this, because for my purposes I need to perform this one record at a time, finding the record then deleting it. I tried putting the destroy function under find.execute, hoping that the destroy function would just run after the find function completed, but the record still wasn't deleted.