- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 254 Articles for Node.js
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
609 Views
Introduction to set()This function can be used to set the value of the name argument passed with the new value passed. If multiple name-value pair exists, only one name-value pair will be set and all the remaining pairs will be removed as shown in the example below.SyntaxURLSearchParams.set(name, value);ParametersThe inputs are name and a value. The name is used to find the value that needs to be updated with the new value given in the argument. New value is not set if the name paramter does not exist in the URL.Example// Defining the URL as a constant const params = new ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
192 Views
Introduction to has()This function returns true or false based upon the query argument. The function will return true if name-value pair exists for the argument.Syntaxvar bool = URLSearchParams.has(name);It will return TRUE if name is present, else FALSE.ParametersThe input parameter is a name that needs to be searched in the URL.Example // Defining the URL as a constant const myURL = new URL( 'https://example.org/?firstName=John'); // Printing whether the argument exists or not console.log(myURL.searchParams.get('firstName'));OutputtrueExample// Defining the URL as a constant const myURL = new URL( 'https://example.org/?firstName=John'); // Printing whether the argument exists or not console.log(myURL.searchParams.get('lastName'));OutputfalseIntroduction to delete()It will delete/remove ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
376 Views
Introduction to entries() −This function returns an iterator that allows us to iterate all over the entry set that are present in the object. It basically gives us a tool to iterate over the complete entry set of the param object.SyntaxURLSearchParams.entries();It will return an ES6 type iterator with all the name-value pair values.Example// Defining the parameters as a variable var params = new URLSearchParams('key1=value1&key2=value2&key3=value3'); // Iterating over the values of params for(var entry of params.entries()) { console.log(entry[0] + ' -> ' + entry[1]); }Outputkey1 -> value1 key2 -> value2 key3 -> value3Example// Defining the URL as a constant ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
305 Views
Introduction to fs-extraBefore proceeding with fs-extra, one must have a basic knowledge of the fs file system. The fs-extra is an extension of the fs file system and has more methods than it. It adds some file method systems that are not there in the naive fs modules. Fs-extra adds the promise support to the fs methods and therefore better than fs.Installationnpm install fs-extraSyntaxfs-extra is a replacement for the native fs file system. All methods that are in fs are attached to fs-extra as well. Therefore, you don't need to include fs again.const fs = require('fs-extra');Most methods provided by fs-extra ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
1K+ Views
Introduction to Sync copyThis method copies files or directories from one location to another location in a sync process. The directory can have sub-directories and files.SyntaxcopySync(src, dest[, options])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.Optionsoverwrite – If set to true, existing files or directories ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
3K+ Views
In this article, we will create a simple user sign-up form having some parameters. On clicking SAVE, all the user details will be saved in the MongoDB database.InstallationBefore proceeding to create the sign-up form, the following dependencies must be succesfully installed on your system.Check and install express by using the following command. Express is used to set middlewares to respond to HTTP requestsnpm install express --saveSetup the "body-parser" node module for reading the HTTP POST data.npm install body-parser --saveSetup "mongoose", as it sits on top of Node's MongoDB driver.npm install mongoose --saveExample 1Create the following files and copy paste the ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
464 Views
readJson() method reads a JSON object and then parses it into an object.SyntaxreadJson(file [, options] [, callback])Parametersfile – String parameter which will contain name and location of the file holding the JSON.options – The 'outputFile' function supports the following options −encoding – Default 'null'.flag – Default 'r'. The flag 'r' opens a file for reading and an exception will occur if file does not exist.signal – allows aborting an ongoing output file functioncallback – 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 ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
149 Views
In this article, we will see how to select or query the data from a database based on different table fields and columns.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 in the project folder.Select Data from Table Using NodeCreate a new file with the following name – app.jsCopy and Paste the following code snippet in this file.Now, run the following command to check the output of the above program.>> node app.jsExample// Checking the MySQL dependency – if exists var mysql = ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
272 Views
Introduction to Async pathExists()This method will test whether the given path exists or not by checking with the file system. It will throw error in callback if the path does not exist.SyntaxpathExists(file[, callback])Parametersfile – This is the path of the file that needs to be checked in all the file systems.callback – This function will give a callback if any error occurs.ExampleCheck 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 pathExists.js and copy-paste the following code snippet into that file.Now, run the ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
294 Views
Introduction to Async outputFile()This method is similar to write file of 'fs'. The only difference is it will create the parent directories, if not present. The argument passed should always be a file path, not a buffer or a file descriptor.SyntaxoutputFile(file, data[, options] [, callback])Parametersfile – String parameter which will contain name and location of the file.data – The data can hold a string data, buffer stream or a Unit8 string array that is to be stored.options – The 'outputFile' function supports the following options −encoding – Default 'utf8'.mode – Default 0o666signal – allown aborting an ongoing output file functioncallback ... Read More