Articles on Trending Technologies

Technical articles with clear explanations and examples

Introduction to Sync emptyDir() in NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 428 Views

This method is used to empty a directory whether it is empty or not with a sync process. If the directory is not empty, it will remove all its contents and empty it. A new empty directory is created if the directory does not exist.SyntaxemptyDirSync(dir)Parametersdir – This is a string paramter which will hold the location of the directory structure.Example 1Check that fs-extra is installed before proceeding; if not, install fs-exra.You can use the following command to check whether fs-extra is installed or not.npm ls fs-extraCreate a syncEmptyDir.js and copy-paste the following code snippet into that file.Now, run the following ...

Read More

EmptyDir() function in fs-extra - NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 486 Views

Introduction to Async emptyDir()This method is used to empty a directory whether it is empty or not. If the directory is not empty it will remove all its contents and empty it. A new empty directory is created if the directory does not exist.SyntaxemptyDir(dir, [, callbacks])Parametersdir – This is a string paramter which will hold the location of the directory structure.callback – This function will give a callback if any error occurs.Example 1Check that fs-extra is installed before proceeding; if not, install fs-exra.You can use the following command to check whether fs-extra is installed or not.npm ls fs-extraCreate a asyncEmptyDir.js ...

Read More

Dropping a MySQL Table using NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 766 Views

You can delete an existing table from MySql Database using the "DROP TABLE" statement in Node. Sometimes, we need to delete the whole table, though in corporates it is always advised to archive the tables which are not in used instead of deleting them.While deleting a table, we have two scenarios −Deleting a table if it exists, else throw an errorDeleting the table whether it exists or not.We will discuss both the scenarios here.Before proceeding, please check the following steps are already executed −mkdir mysql-testcd mysql-testnpm init -ynpm install mysqlThe above steps are for installing the Node - mysql dependecy ...

Read More

Difference between process.cwd & _ _dirname in NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 692 Views

NodeJS is a JavaScript runtime environment that was built on top of Chrome's V8 engine. The traditional use of JavaScript is to be executed in browsers, but with Node.JS we can execute JavaScript other than browsers like servers, hardware devices, etc.process.cwd()The process object lies under the global object known as 'global'. This method provides information about the current process of Node.js. It also provides control over the same. cwd refers to the current working directory of the same. Therefore, process.cwd returns the working directory on which execution is taking place currently.__dirnameThis is a local module that will return the directory ...

Read More

Difference between console.log and process.stdout.write in NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 1K+ Views

Both the methods – console.log and process.stdout.write have a basic definition to write or print the statements on the console. But, there is a slight difference in the way they execute these tasks. Internally, console.log implements process.stdout.write which itself is a buffer stream that will be used to directly print statements on your console.process.stdout.writeconsole.logIt continuously prints information as retrieved from the stream without adding any new line.It first prints the information being retrieved and then adds a new line. Then it will go to retrieve the second set of statements to print.The process.stdout.write method takes only string as paramter. Other ...

Read More

Creating a MySQL Table in NodeJS using Sequelize

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 2K+ Views

Introduction to SequelizeSequealize follows the promise-based Node.js ORM for different servers like – Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server.Following are some of the main features of NodeJS sequelize −Transaction SupportRelationsEager and Lazy LoadingRead Replication and more...Connecting to MySQL using SequelizeWe need to establish a connection between MySQL and Node.js using Sequelize.After creating a successful connection with sequelize, we would require the following three files for configuration. Please carefully create the following files in their respective folders only.SequelizeDemo > application.jsThis will be our root file which will hold the actual logic.SequelizeDemo>utils>database.jsThis will hold all the connection details to MySQL.SequelizeDemo>models>user.jsThis ...

Read More

Async Copy in fs-extra - NodeJS

Mayank Agarwal
Mayank Agarwal
Updated on 27-Apr-2021 989 Views

Introduction to Async copyThis method copies files or directories from one location to another location. The directory can have sub-directories and files.Syntaxcopy(src, dest[, options][, callback])Parameterssrc – This is a string paramter which will hold the source location of the file or directory that needs to be copies. If the location is a directory, it will copy everything inside of the directory instead of whole directory.dest – This will hold the destination location where the files/directories will be copies. If src is a files, dest cannot be a directory.options −overwrite – If set to true, existing files or directories will be ...

Read More

What is Spike Testing? Learn With Example

Vineet Nanda
Vineet Nanda
Updated on 27-Apr-2021 1K+ Views

Spike testing is a type of performance testing used to determine an application's behavior when exposed to extreme traffic variations. In spike tests, the app is revealed to sudden decrease and increase in load. The results are then analyzed based on factors like −Does the app crash?Does the app slow down?How long it takes the app to switch back to normal?Accumulating test results, the developers determine when and where the application fails and then take necessary actions for performance improvement.Example of Spike TestingLet's say X University is all set to upload the results on its official site at 1 −30 ...

Read More

What is Soak Testing? Definition, Meaning, Examples

Vineet Nanda
Vineet Nanda
Updated on 27-Apr-2021 1K+ Views

Soak testing is a non-functional performance testing under which an application is exposed to a continuous load for a pre-determined period. It is also known as Longevity testing and Endurance testing.The term 'soak' itself explained the test's purpose. Let's consider yourself pulling a rope on one end while your friend pulls it on the other end. Now, if you pull it for one hour, it won't affect the rope much. However, if both of you continue to pull it for days, the rope might eventually break.The same rules apply to software as well. When software faces a high load, it may ...

Read More

What is Response Time Testing?

Vineet Nanda
Vineet Nanda
Updated on 27-Apr-2021 2K+ Views

A tester measures an app or site performance by collecting various data during a load or stress test. However, every test starts with sending a request to an application. Once a request is sent, the tester calculates the app's response time by estimating how much time it takes to respond to the specific request. Let's understand response time with real-life examples −Offline exampleLet's assume you are standing at the checkout counter of a grocery store. The cashier takes three minutes to process the products. Now, if you have a lot of customers waiting in front of you, that means you will ...

Read More
Showing 49781–49790 of 61,299 articles
Advertisements