Beginners guide to installing and setting up MongoDB and GUI for MongoDB in Windows Machine
databases , MongoDB , Uncategorized / September 26, 2019

This is a step by step tutorial for installing MongoDB and setting up a GUI for MongoDB on Windows OS   Step – 1 Check whether MongoDB is already installed in the system To check whether MongoDB is already installed in the system, and the PATH variable is configured, use the following command. This will output the version of MongoDB .

The following command will output the Mongo shell version

If installed and configured, the output will be something like db version v3.4.14 –          mongod -version MongoDB shell version v3.4.14 –           mongo -version If not, the output will be like     Step – 2 Download and install  MongoDB and the mongo shell on Windows machine Go to the MongoDB official site and download the setup file for Mongo and install it on the machine. The default installation folder will be inside program files in your C drive

You can customize your installation and also choose whether to install or not install the MongoDB Compass which is an intuitive GUI by MongoDB Inc. Navigating to the bin folder and running the commands in Step 1 will give you the versions…

Web Storage – A comparative study of Local Storage,Session Storage,Cookies,IndexedDB and WebSQL
databases , Javascript , Uncategorized / July 10, 2019

Storages in browsers – Web Storage Web Storage is the storage mechanism that allows Web applications to store data in Web Browsers. The various storage types include Local Storage, Session Storage, Cookies, IndexedDB, Web SQL. These storages are supported by most of the modern-day web browsers and are standardized by the World Wide Web Consortium. Web Storage lets a web application to store data which in turn helps in the effective end to end functionality of the application. Upon inspecting and navigating to the storage in the browser console, we can see what are the various storage mechanisms supported by the browser and data stored in them. FireFox       Chrome Local Storage Local storage is a key-value store that stores values as string. The data stored in local storage does not have an Expiration date and will stay in the browser forever until we clear the browser data using settings or using Javascript. Up to 10MB of data can be stored in most of the browsers and it is 10MB for Local Storage and Session Storage combined in chrome.IE has 10 MB each. Local Storage follows the same-origin policy. The same-origin means that the Protocol(Http/Https), port and the host…

Write Cloud Functions on Cloud Firestore and deploy – Introduction
databases , firestore , Node.js / May 16, 2019

Contents > What is Cloud Firestore >What are Cloud functions >Writing and Deploying Cloud Functions to write data to Cloud Firestore Collection What is Cloud Firestore It’s a NoSQL document database that lets you store data for your Mobile Application, web Application, APIs… It is Cloud-based, highly scalable and flexible. To see your Firestore database dashboard visit the below URL https://console.firebase.google.com/project/YOURPROJECTNAME/overview Firestore has the following Datatypes string number boolean map array null timestamp geopoint reference Firestore is a Document database.We can save data as collections -> documents  ->  subcollections in a nested structure. Here we can see that the created date is a timestamp ,reciever_data is a map and reciever_id is a string data. What are Cloud functions Cloud Functions help to achieve serverless execution by providing access to Firebase and Cloud events .Operations can be done in response to these events. For example, you can do CRUD operations on the Firestore / Realtime database using Cloud Functions. You can deploy the Cloud function and hit them to perform these CRUD operations. The event handler for an HTTP request to the Cloud Functions listens for the onRequest event Writing and Deploying Cloud Functions to add data to Cloud Firestore Collection step 1…

Redis Tutorial Part 4– Redis Data structures setting expiration time for key with Node.js ioredis
databases , linux , redis / April 24, 2019

Setting  expiration time for a data in Redis Consider an object which contains name and type. We store this data in Redis using the Redis hashes data structure.

We store this data into a key called listdb using the following code

hset is used to set a key and corresponding value in the hash.   Now we set the expiration time for  key listdb using expire

In this code 60 represent the expiration time in seconds. You can change this value as you want On running this code to get the value after the 60s will give empty data

hgetall will get all the values  for key listdb Running this code before 60 s will give a result like this

   

Redis Tutorial Part 3 – Redis Data structures and working with Node.js ioredis

Redis Data structures Key-value stores mostly support string keys and string data but Redis does a lot more than that. Redis is not just a simple key-value string store It supports complex kinds of data structures, not just string. We will look more into this property of Redis in this tutorial and see how to utilize this using Node.js and ioredis module. Get the ioredis module installed on your app from https://www.npmjs.com/package/@types/ioredis   1 String – Basic kind of string. Lets us say the name of a person. We will see how we can store this value using ioredis We set value bar into key foo using set and get the value using get.

2 Binary Safe String – Can contain any type of data represented as a string: PNG images or serialized objects, for example. Here we have a base64 encoded data of an image.We store this data in redis.Remember a value can’t be bigger than 512 MB. base64 of png – iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gUfFBM7nAl7igAAAPVJREFUWMNj1G/R/88wSAATwyACLMgcYzljojXefHmT4cvPLwzU1A93TJRpFEOZWxnRhj37+IzBa4oXA7n6b7y8wRAxJwK7Y3g5eBkYGBgYNl7ayPD843O8BmXYZjBI8UuhiMH0Ews0xDXwRxMDAwPDpoubGM4+OkvQMcM+AY86ZtQxo46hSXXAwMDA4Kfvx2AibzKwjvn84zMDAwMDg7+eP9HVATKA6SelOkEHjMhNCFJC5NmHZxgGUqqfcbQ9M9qeobQ9QyzA1Z4htj1EVHuGUkBJe2i0Ohh1zKhjRkZ7hlJASXuIhVrtEUrbQ6PtmdHcRA4AAAq6hb9r4YF9AAAAAElFTkSuQmCC

We can store buffer data as well in redis..

3 Lists – Collections of elements ordered according to the order of insertion

    4 Sets – Sets of data. Here we have a…

Redis Tutorial Part 2 – Redis Sentinel and master/slave usage with Node.js ioredis

Redis Sentinel  System designed to help manage Redis instances. As we discussed earlier, one Redis instance can be master and other instances can be slaves. The slaves can have exact data copies of the master server. The master will have replication ID. The biggest advantage of this architecture is that the slave can act as a master if the master fails. Redis Sentinel is the system that helps to make Redis instances with High Availability (HA) by managing failovers. Redis Sentinel Does the following jobs Monitoring – Checking if your master and slave instances are working as expected. Notification – Notifying something went wrong. May be via an API. Automatic failover – If a master is not working as expected, Sentinel can start a failover process where a slave is promoted to master     The configuration file for sentinel is sentinel.conf  redis-server /path/to/sentinel.conf –sentinel   In the sentinel.conf file, there is a line like sentinel monitor mymaster 127.0.0.1 6379 2 quorum – 2 This line determines which master the sentinel is going to monitor. The number 2 is called quorum. The number determines how many sentinels need to agree that the master is having a Failover so that the slave…

Redis Tutorial Part 1 – Introduction

Redis – Remote Dictionary Server Redis (Remote Dictionary Server) is an opensource key-value store. It can be used as a database, cache and message broker. Redis is an in-memory store which means that it primarily relies on main memory/primary memory for data storage in comparison to other database storages like Mysql that relies on disk storage.   Redis is written in C language and it supports cross-platform. In-memory databases like Redis are faster compared to disk storage databases like Mysql. Redis is a key-value store. Which means that data is stored like name=’John’ The value john an be accessed using the key name. Key value is a string. Redis is single-threaded(One operation at a time) fast and scalable. The speed allows redis to be used as cache memory. Install Redis on Linux sudo apt-get update sudo apt-get install redis-server For Redis server redis-server For Redis Command Line Interface redis-cli To get configuration for redis goto redis-cli.type CONFIG type of configuration to get configuration values in redis.conf.   There are two processes in Redis architecture. REDIS-CLIENT – Manages client interaction REDIS-SERVER – Manages data storage in the memory and forms the major part of the Redis architecture. Single Redis instance can manage multiple redis…

Batch add to Google Cloud Firestore database collection : Node.js and Express
databases , Express.js , Node.js / 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 Create the  reference to the collection in which you are going to add the batch data

STEP 3 Post batch data as an array to the Express server you have created.

STEP 4 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

 

Share this page in social media platforms