We can insert multiple records into database using NodeJS. How to Insert Multiple records in Nodejs
Download NodeJs in your system using : https://nodejs.org/en/download/
We will use MySQL for Insert Query and PhpMyAdmin to maintain our Database. In the place of MySQL We can use Mongo DB as well.
var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "root", password: "12345", database: "student" }); con.connect(function(err) { if (err) throw err; console.log("Connected!"); var sql = "INSERT INTO employees (id, name, age, city) VALUES ?"; var values = [ ['2', 'HeyHey Kumar', '25', 'Delhi'], ['3', 'Harsh Patel', '15', ?Daman'], ['4', 'Bishal Kumar', '42', ? Amritsar'] ]; con.query(sql, [values], function (err, result) { if (err) throw err; console.log("Number of records inserted: " + result.affectedRows); }); });
This way we can insert data into the database. This is a very simple example in node js with Insert Code.
Our More tutorials on Node and Laravel