Tuesday, December 26, 2017

Mongo Database - Day 33

CURD operation is one of the main operation used in Database.
C -Create
U - Update
R - Read
D - D 

The basic syntax of update() method is as follows >db.COLLECTION_NAME.update(SELECTION_CRITERIA, UPDATED_DATA)
Following example will set the new title 'Parathan' of the documents whose title is 'Jaffna'.

>db.mycol.update({'title':'Jaffna'},{$set:{'title':'Parathan'}})

Monday, December 25, 2017

Mongo DB Database - Day 32

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.

MongoDB - Advantages

• 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
To create Database
use database_name

To create Collection
db.createCollection("collection_name")

Insert Document Syntax
To insert a document into a Collection. We use
>db.COLLECTION_NAME.insert(document)

To insert multiple documents in a single query
>db.COLLECTION_NAME.insert([
{
document
},
{
document
},
{
document
}
])

Saas - Function & Operations - Day 29

 Functions in Sass allow for an easier way to style pages, work with colors, and iterate on DOM elements.

Mixins: Mixins are a powerful tool that allow you to keep your code DRY. Their ability to take in arguments, assign default values to those arguments, and accept said arguments in whatever format is most readable and convenient for you makes the mixin Sass's most popular directive.
Mixins should only be used if they take in an argument, otherwise, you should extend the selector's rules, whether it be a class, id, or placeholder.

The & selector* is a Sass construct that allows for expressive flexibility by referencing the parent selector when working with CSS psuedo elements and classes.

String interpolation is the glue that allows you to insert a string in the middle of another when it is in a variable format. Its applications vary, but the ability to interpolate is especially useful for passing in file names.

Sustainability is key in Sass, planning out the structure of your files and sticking to naming conventions for both variables, mixins, and selectors can reduce complexity.

Understanding CSS output is also essential to writing sustainable SCSS. In order to make the best choices about what functions and directives to use, it is important to first understand how this will translate in CSS.

Saas - Day 28

 SAAS (Syntactically Awesome Style Sheet) is a kind of CSS creator which reduces the repetition of CSS coding. That means it create CSS code in a readable manner. [ Easy, Structured & Maintainability high ]

Its coded in Ruby to create CSS files.

Why to Use SASS?

❖ It is a pre-processing language which provides indented syntax (its
own syntax) for CSS.
❖ It provides some features, which are used for creating stylesheets that
allows writing code more efficiently and is easy to maintain.
❖ It is a super set of CSS, which means it contains all the features of
CSS and is an open source pre-processor, coded in Ruby.
❖ It provides the document style in a good, structured format than
flat CSS. It uses re-usable methods, logic statements and some of the
built-in functions such as color manipulation, mathematics and
parameter lists.

Features of SASS

❖ It is more stable, powerful, and compatible with versions of CSS.
❖ It is a super set of CSS and is based on JavaScript.
❖It is known as syntactic sugar for CSS, which means it makes
easier way for user to read or express the things more clearly.
❖ It uses its own syntax and compiles to readable CSS.
❖ You can easily write CSS in less code within less time.
❖ It is an open source pre-processor, which is interpreted into CSS.

Advantages of SASS

❖ It allows writing clean CSS in a programming construct.
❖ It helps in writing CSS quickly.
❖ It is a superset of CSS, which helps designers and developers
work more efficiently and quickly.
❖ As Sass is compatible with all versions of CSS, we can use any
available CSS libraries.
❖ It is possible to use nested syntax and useful functions such as
color manipulation, mathematics and other values.

Disadvantages of SASS

❖ It takes time for a developer to learn new features present in this
pre-processor.
❖ If many people are working on the same site, then should use the
same preprocessor. Some people use Sass and some people use CSS
to edit the files directly. Therefore, it becomes difficult to work on
the site.
❖ There are chances of losing benefits of browser's built-in element
inspector

Sass - Syntax

❖ SASS supports two syntaxes namely SCSS and Indented syntax.
❖ The SCSS (Sassy CSS) is an extension of CSS syntax. This means
every valid CSS is a valid SCSS as well. SCSS makes much
easier to maintain large stylesheets and can recognize vendor
specific syntax, Many CSS and SCSS files use the extension .scss.
❖ Indented − This is older syntax and sometimes just called as
SASS. Using this form of syntax, CSS can be written concisely.
SASS files use the extension .sass.

jQuery - Day 27


jQuery is a JavaScript library. As like Bootstrap for CSS. Many lines of code in JavaScript is replaced by less amount of jQuery code.

jQuery can be used by downloading as package or online CDN.

<script src="jquery-3.2.1.min.js"></script>  

Features of jQuery Library
  1. HTML / DOM Manipulation
  2. CSS Manipulation
  3. HTML event methods
  4. Effects & Methods
  5. AJAX
  6. Utilities

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)

Examples:

$(this).hide() - hides the current element.

$("p").hide() - hides all <p> elements.

$(".test").hide() - hides all elements with class="test".

$("#test").hide() - hides the element with id="test".


 $(document).ready(function(){

   // jQuery methods go here...

}); 


 The code inside document. ready(function) will prevent the code from loading before the page loads fully. This will make a good site.

JSON - Day 26

JSON stands for JavaScript Object Notation. JSON objects are used for transferring data between server and client, XML serves the same purpose. However JSON objects have several advantages over XML  These are in text style.

Features of JSON:
  • It is light-weight
  • It is language independent
  • Easy to read and write
  • Text based, human readable data exchange format
Sending Data to Server

var person ={ "name":"Parathan", "age": 19, "place" :"Jaffna"};
var myJSON= JSON.stringify(person);

Receiving Data from Server

var myJSON= { "name":"Parathan", "age": 19, "place" :"Jaffna"};
var person = JSON.parse(myJSON);

Storing Data

var person ={ "name":"Parathan", "age": 19, "place" :"Jaffna"};
var myJSON= JSON.stringify(person);
localStorage.setItem("textJSON", myJSON);

Retrieving Data

text= localStorage.getItem("testJSON")
obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;


Why use JSON?
Standard Structure: As we have seen so far that JSON objects are having a standard structure that makes developers job easy to read and write code, because they know what to expect from JSON.

Light weight: When working with AJAX, it is important to load the data quickly and asynchronously without requesting the page re-load. Since JSON is light weighted, it becomes easier to get and load the requested data quickly.

Scalable: JSON is language independent, which means it can work well with most of the modern programming language. Let’s say if we need to change the server side language, in that case it would be easier for us to go ahead with that change as JSON structure is same for all the languages.

JSON data structure types and how to read them:
  • JSON objects
  • JSON objects in array
  • Nesting of JSON objects

JSON & JavaScript:
JSON is considered as a subset of JavaScript but that does not mean that JSON cannot be used with other languages. In fact it works well with PHP, Perl, Python, Ruby, Java, Ajax and many more.

Just to demonstrate how JSON can be used along with JavaScript, here is an example:
If you have gone though the above tutorial, you are familiar with the JSON structures. A JSON file type is .json

Saturday, December 23, 2017

JavaScript - If, Else,Else if , Switch Conditions - Day 21

Conditions are used to do particular conditions several times.

Following are some conditions used in JavaScript

if condition will execute a block of code.., if is used when statement is whether true or false.
else condition used when a block of statement is false
else if condition used to check more & more statements whether they are true
switch to specify many alternative blocks of code to be executed

If condition

if (condition) {
    block of code to be executed if the condition is true}

if should be in lower case... if is in uppercase then JavaScript will show error.

<p id="demo"></p>

<script>
if (5 == 5) {
    document.getElementById("demo").innerHTML = "True";
}
</script>

Output : True

Else Condition

<p id="demo"></p>

<script>
if (5 == 7) {
    document.getElementById("demo").innerHTML = "True";
}else {
    document.getElementById("demo").innerHTML = "False";
}
</script>

Output: False

Else if Statement

if (condition1) {
   statement
} else if (condition2) {
   statement
} else {
   statement
}

Switch Statement

switch(expression) {
    case n:
        code
        break;
    case n:
        code
        break;
    default:
     code
}

Break Keyword : When execution reached Break keyword the program will run out of Switch statement. If we don't use Break all codes will be read by device. 

Default Keyword : The default keyword specifies the code to run if there is no case match