Friday, June 2, 2017

Mongo db Install

💥 How to install Mongodb

      💢 Start MongoDB


                     👀 sudo service mongodb start

       💢 Stop MongoDB


                    👀 sudo service mongodb stop

          💢 Restart MongoDB


                     👀 sudo service mongodb restart
 
  💥 To use MongoDB run the following command.


                       👀 mongo
 
 
  💥How to create database

            💧If you want to create a database with name <mydb>, then use database statement would be as follows 


>use mydb
switched to db mydb
 
           💧To check your currently selected database, use the command db


>db
mydb
 
            💧If you want to check your databases list, use the command show dbs.


>show dbs
local     0.78125GB
test      0.23012GB
 
           💧Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it.


>db.student.insert({"name":"Abi"})
>show dbs
local      0.78125GB
mydb       0.23012GB
test       0.23012GB
 
      
  💥 How to drop Database
 
 
Basic syntax of dropDatabase() command is as follows −
💥db.dropDatabase() 

          💧This will delete the selected database. If you have not selected any database, then it will delete default 'test' database.


     👉First, check the list of available databases by using the command, show dbs.

      💧>show dbs
 local 0.78125GB 
mydb 0.23012GB 
 test 0.23012GB 
 
      👉If you want to delete new database <mydb>, then dropDatabase() command would be as follows 

    💧>use mydb switched to db mydb  
     > db.dropDatabase() 
     >{ "dropped" : "mydb", "ok" : 1 } >
 
       👉Now check list of databases.

>show dbs 
 local 0.78125GB 
test 0.23012GB >

MongoDB



            💥 MongoDB is an open-source document database and leading NoSQL database

            💥 MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.


💥 Advantages of MongoDB over RDBMS

  • Schema less − MongoDB is a document database in which one collection holds different documents. Number of fields, content and size of the document can differ from one document to another.
  • Structure of a single object is clear.
  • No complex joins.
  • Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL.
  • Tuning.
  • Ease of scale-out − MongoDB is easy to scale.
  • Conversion/mapping of application objects to database objects not needed.
  • Uses internal memory for storing the (windowed) working set, enabling faster access of data.


    💥 Why Use MongoDB?

  • Document Oriented Storage − Data is stored in the form of JSON style documents.
  • Index on any attribute
  • Replication and high availability
  • Auto-sharding
  • Rich queries
  • Fast in-place updates
  • Professional support by MongoDB

 ðŸ’¥ Where to Use MongoDB?

  • Big Data

  • Content Management and Delivery

  • Mobile and Social Infrastructure

  • User Data Management

  • Data Hub



Thursday, June 1, 2017

jQuery Event


   💥 All the different visitor's actions that a web page can respond to are called events.

  💥  An event represents the precise moment when something happens.
Examples:
  • moving a mouse over an element
            💧<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
            $(this).css("background-color", "lightgray");
        }, 
        mouseleave: function(){
            $(this).css("background-color", "lightblue");
        },
        click: function(){
            $(this).css("background-color", "yellow");
        } 
    });
});
</script>

  • selecting a radio button
           💧<script>
$(document).ready(function(){
    $("input").keypress(function(){
        $(this).hide();
    });
});
</script>

  • clicking on an element

  •        💧<script>
    $(document).ready(function(){
        $("p").on("click", function(){
            $(this).hide();
        });
    });
    </script>

jQuery




💥 jQuery is a JavaScript Library.

💥  jQuery greatly simplifies JavaScript programming.  
💥 The purpose of jQuery is to make it much easier to use JavaScript on your website.

💦 jQuery Syntax

Basic syntax is: $(selector).action()
  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)
 
 

💦 jQuery Selectors

      👦The element Selector

              You can select all <p> elements on a page like this:
$("p") 
 
 
    👦The  #id selector

      An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
$("#test") 
 
     👦 The . class selector

     To find elements with a specific class, write a period character, followed by the name of the class:
$(".test") 
 
 

 



  

Friday, May 26, 2017

JavaScript Function,Object

💥A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ()

The code to be executed, by the function, is placed inside curly brackets: {}

👊function name(parameter1, parameter2, parameter3) {
    code to be executed
}


💥 We can use function different ways

 ðŸ‘Š<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "Hello World!";
}
myFunction();


 ðŸ‘Š<script>
function myFunction(name) {
    return "Hello " + name;
}
document.getElementById("demo").innerHTML = myFunction("John");
</script>


💥OBJECT


👊 <script>
var person = {
    firstName : "John",
    lastName  : "Doe",
    age       : 50,
    eyeColor  : "blue"
};

document.getElementById("demo").innerHTML =
person.firstName + " is " + person.age + " years old.";
</script>

 
output  John is 50 years old

 ðŸ‘Š<script>
var person = {
    firstName: "John",
    lastName : "Doe",
    id       : 5566,
    fullName : function() {
       return this.firstName + " " + this.lastName;
    }
};

document.getElementById("demo").innerHTML = person.fullName();
</script>


output  John Doe

Java Script Data Type

 ðŸ’¥JavaScript variables can hold many data types: 

  • numbers 
var length = 16;
  • strings
 var lastName = "Johnson";    
  • objects  
 var x = {firstName:"John", lastName:"Doe"};
  • boolean
<script>
document.getElementById("demo").innerHTML =
typeof true + "<br>" +
typeof false;
</script>

  • null
 <script>
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
var person = null;
document.getElementById("demo").innerHTML = typeof person;
</script>


out put object

  • undefined 
 <script>
var person;
document.getElementById("demo").innerHTML =
person + "<br>" + typeof person;
</script>
 
  💥JavaScript evaluates expressions from left to right. Different sequences can produce different results


  👊<script>
var x = "Volvo" + 16 + 4;
document.getElementById("demo").innerHTML = x;
</script>



 output  volvo164


 ðŸ‘Š <script>
var x = 16 + 4 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>


output 20Volvo

  💥We can use single or double invert comma  for string &  use quotes inside a string
 
 ðŸ‘Š<script>
var carName1 = "Volvo XC60";
var carName2 = 'Volvo XC60';
var answer1 = "It's alright";
var answer2 = "He is called 'Johnny'";
var answer3 = 'He is called "Johnny"';

document.getElementById("demo").innerHTML =
carName1 + "<br>" +
carName2 + "<br>" +
answer1 + "<br>" +
answer2 + "<br>" +
answer3;
</script>


output  

Volvo XC60
Volvo XC60
It's alright
He is called 'Johnny'
He is called "Johnny"

             

JavaScript Arithmetic


 ðŸ’¥The addition operator (+) adds numbers

👊<script>
var x = 10;
var y = 2;
var z = x + y;
document.getElementById("demo").innerHTML = z;
</script>


output 12 

 ðŸ’¥The subtraction operator (-) subtracts numbers

 ðŸ‘Š<script>
var x = 5;
var y = 2;
var z = x - y;
document.getElementById("demo").innerHTML = z
</script>


output 3

  💥The multiplication operator (*) multiplies numbers

  👊<script>
var x = 5;
var y = 6;
var z = x * y;
document.getElementById("demo").innerHTML = z; 

</script>
                                  OR
 output 30<script>
var x = 10;
x *= 5;
document.getElementById("demo").innerHTML = x;
</script>

output 50


  💥The modular operator (%) returns the division remainder.

👊 <script>
var x = 5;
var y = 2;
var z = x % y;
document.getElementById("demo").innerHTML = z;
</script>

                                      
output 1

                                    OR
<script>
var x = 10;
x %= 5;
document.getElementById("demo").innerHTML = x;
</script>

output 0


💥The increment operator (++) increments numbers

  👊<script>
var x = 5;
x++;
var z = x;
document.getElementById("demo").innerHTML = z;
</script>


output 6

  💥Operator precedence describes the order in which operations are performed in an arithmetic expression.

  👊<script>
document.getElementById("demo").innerHTML = 100 + 50 * 3;
</script>


output  250


👊 <script>
document.getElementById("demo").innerHTML = (100 + 50) * 3;
</script>


output 450