Posts

Showing posts from September, 2015

Basic Data structurs in JSON

Basically, there are only two types of data structures in JSON 1. Arrays : list of things e.g: ["a","b","c"] 2. Dictionaries  : Associative maps or key value pair e.g: {"a"=>"2","b"=>"4","c"=>"43"...} So, in JSON, we mainly have these types arrays , dictionaries, and combination of arrays & dictionaries  So some of the common JSON examples may be : : {} :  ["a","b","c"]   (arrays) : {"a":"2","b":"4","c":"43"} (dictionaries) : ["a","b","c":{"name":"rroxy","age":"23"}] (combn of arrays & dictionaries) : {"a":"2","b":"4","c":["2","4","6"]}   (combn of arrays & dictionaries)   &  so on ....

What is NODE js & Install NODE js on linux using terminal

Image
NODE js : Node.js is an open source, cross-platform runtime environment built on Chrome's V8 JavaScript engine for server-side and networking applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js applications are written in JavaScript. Basic two ways to install node on linux -- 1.  Run the command  Step 1: curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash - Step 2: sudo apt-get install --y nodejs 2. By using nvm : => RUN the command : curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash nvm will be installed. and you will ask to close and reopen your terminal to start using NVM or you can acheived so by using this command : source ~/.profile And now you can use, nvm ls-remote. If you have error, -bash: nvm: command not found, then install git by using  apt-get install git The nvm ls-remote will show all the versions of node, to install any l

How to define model in MongoDb

Here, we are going to make a model in Express using MongoDb //First of all, require a mongoose module var mongoose = require("mongoose"); // then create schema instance using mongoose var schema = mongoose.Schema; // finally create a schema using schema instance and  in defining model, we defines the fields and their type for our model/collections. var userSchema = new schema({             name:'String',             email:'String',             age:'String'  }); // And at last, export the model by giving it a suitable name, for using it outside this file/module (If we are using collections UERERS, then provide a name like USER) module.exports = mongoose.model("User",userSchema);

Connect to MongoDb using mongoose in NODE js

Here is the way, to connect mongodb in NODE js using mongoose module // first of all require mongoose NODE module var mongoose = require('mongoose'); // then connect to local mongodb database var db = mongoose.connect('mongodb://127.0.0.1:27017/test'); //And finally attach a listener to connected event if want to check status/ other mongoose.connection.once('connected', function() { console.log("Database  Connected ") });

What is Mongodb & its terms documents, collection, bson

Image
MongoDB is a document database (one of the type of Document oriented NOSQL database ) that provides high performance, high availability, and easy scalability.MongoDB stores data in the form of documents, which are JSON-like field and value pairs. Documents : Documents are analogous to structures in programming languages that associate keys with values (e.g. dictionaries, hashes, maps, and associative arrays). Formally, MongoDB documents are BSON documents. Or if we compared to mysql, documents are like rows/ records. Collections : A collection is a group of related documents that have a set of shared common indexes. MongoDB stores all documents in collections. Collections are analogous to a table in relational databases. Or if we compared to mysql, Collections are like to tables. BSON : BSON is a binary representation of JSON with additional type information. In the documents, the value of a field can be any of the BSON data types, including other documents, arrays, and

Install MongoDb on Ubuntu

Step 1 — Importing the Public Key To do so, execute: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 Step 2 — Creating a List File Issue the following command to create a list file for MongoDB. echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list Step 3 — Installing and Verifying MongoDB Now we can install the MongoDB package itself. sudo apt-get install -y mongodb-org After package installation MongoDB will be automatically started. You can check this by running the following command. service mongod status To start server at any time, issue command  mongod To open server shell at any time, issue command   mongo * If server is unable to connect to their path & having path error :  make directory data/db in root & set the path by this command :  mongod --dbpath path_root

What is mean stack ?

The term MEAN stack refers to a collection of JavaScript based technologies used to develop web applications. MEAN is an acronym for MongoDB, ExpressJS, AngularJS and Node.js. MEAN is a full stack JavaScript from client to server to database MEAN Stands for : M for MONGODB :- MongoDB is the leading NoSQL database, empowering businesses to be more agile and scalable. E for EXPRESS :- Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications. A for ANGULAR :- AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop. N for NODEJS :- Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.