Node.js2 minutes to read

How do I run a one-time Node.js data import and check the result?

Use a one-off deployment for a finite import. Separate starting the runner from running a batch and build a repeatable check for duplicate records.

Choose a job with a clear finish

Use Bothosting’s One-off Node.js script profile for an import that should read a file, update records and exit. Start the deployment to bring the runner online. Open Runs and choose Run now to execute a batch. The runner stays available for later use. Run a finite Node.js script.

Try the report example first. It writes a line of JSON with the job name node-report and a finish time. Check the run result and the timestamp. This separates runner setup from the behavior of your import code.

Give imported rows a stable identity

Suppose you receive a contacts file with columns for customer ID and display name. A row number changes if someone sorts the file again. Use the customer ID as the destination key and give the import file a batch identifier so you can trace it later.

Test with three customer IDs in a disposable destination. The first run should produce three records. Change one customer’s name in the file and run again. If the total grows to six, the script is inserting a new row for every entry. Change the write to update an existing customer by ID or insert a new one, depending on the intended import behavior.

Check run status and the destination

Have the script report rows read, rows applied and rows rejected. Return a failing exit status for an incomplete batch. Look up the customer whose name you changed to verify the stored result. A successful exit only establishes that the process reported success.

For a long file, save progress after committed writes and test the script’s behavior on a restart before processing real data. If it exceeds the run timeout, reduce the batch size or adjust JOB_TIMEOUT_SECONDS within the limit displayed for the deployment.