I\'m new to NodeJS. I have seen there are separate asynchronous and synchronous functions for the same task (ex: {fs.writeFile,fs.writeFileSync
} , {fs.read, f
In reference to node.js fs.writeFile doc, it asynchronously writes data to a file. This means if you have following code:
1. some db operation
2. some non-related db operation
In such case, the 1st operation will not block 2nd operation. 2nd operation execute immediately after 1st(without waiting to finish)
However, there are some scenarios like:
1. some db operation
2. some related db operations(which you can't put in callbacks) and forcefully want to be after 1st operation.
Then use fs.writeFileSync.