Batch add to Google Cloud Firestore database collection : Node.js and Express
Node.js , Express.js , databases / March 17, 2019

STEP 1 – InitializeFirestore App To initializeFirestore, get the key file from your Google cloud console and save it in a folder. Install the Firebase admin module

Now to initialize app, use the following code

STEP 2 Post batch data as an array to the Express server you have created. The JSON sent to the server has the following structure with key ‘user’ having an array of users.

STEP 3 Loop over the req.body using forEach and set each data to be added into the collection using the set method

Commit the data and save the data to the collection using the commit method and on success, send a success response. The full code is as follows


Starting off Node.js web developement in ubuntu/Linux Mint 18 – (ExpressJS,Mysql)

Node.js is an open source server environment which lets us write server side code in javascript. Node.js is asynchronous,single threaded and non-blocking .Node.js has very high memory efficiency which makes it very popular in server side  developement for web/mobile app.In this article we take a look at how to start of web developement in Node.js with Mysql as database. To install Node.js in your linux run the following command in the terminal

After installation run the following command to verify the installation and check the version of Node.js you are having.

  npm(node package manager) is a Node.js package manager that is bundled along with Node.js. npm help us manage Node.js packages efficiently. To initialize our project run the following command in the folder  you want to create the project.

You need to provide a few details like name of your project,version etc which can be skipped.The command will create a package.json file in which you can add the packages you want to  your project. The package.json file will look like this.

Express is a web developement framework for node js.To install Express run the following command in terminal

–save option add the dependency to…

Share this page in social media platforms