Skip to content

Instantly share code, notes, and snippets.

View Abhinay-g's full-sized avatar
🎯
Focusing

Abhinay Abhinay-g

🎯
Focusing
  • ABB
  • India
View GitHub Profile
@Abhinay-g
Abhinay-g / Angular Artifacts for Forms
Last active April 9, 2019 11:32
Angular Artifacts for Forms
> Why agnular forms :
Angualr form gives key-value object of a form which can be used for multiple purpose .
Agnular also give a metadata related to forms.
In traditional HTML form we have action="somefunction()" and method="get!post" , but when we use it with angular we do not specify
anything to angular, angular itself treat <form> as some kind of directive|compoenent and act on it using formsModule.
> Types of angular forms
Template Driven From : in this template is fixed and form element is accessed on TS {So angular infer form from DOM side}
Reactive Form : in this form configuration is done on TS file Also on TEMPLATE side {form created dynamically and synced with DOM}
@Abhinay-g
Abhinay-g / MongoDB
Last active April 16, 2019 09:12
MongoDB
> intorductioon
mongod is a database server , this should be up and running
mongod --port = PORT will be running mongo server on perticular server
mongo is a mongoDB shell , this is used to do all mongo operation , thought we haave DRIVERS for all kind of platform
Shell command are almost similar as JAVAscript driver for nodejs
show dbs > show databases
use DataBase_name > create a database
db.collectionName.insertOne({JSON_Document}) > create a collection and inserting a document into it
@Abhinay-g
Abhinay-g / MongoDB Schema design
Last active April 18, 2019 05:32
MongoDB Schema design
> Introductions
when working with project we need to find what kind of structure of our data, what will be ralation between our data
We will udnerstand ducuments and other types of data
we a will also look into diffreent type of relation, And we will Validate the Data [Schema validation]
>Schema
Mongo DB supposed to be a schemaless DB but why there is a schema, well MongoDB do not enforce schema as
it is enforced by RELATIONAL database. hance creating a schema is an option and as per developers need
It is totally developer oriented we can follow any approch, we can forefully insert value by assigninign
null to that extra field
@Abhinay-g
Abhinay-g / Mongo DB Create operation
Last active April 18, 2019 07:24
Mongo DB Create operation
> Introduction
This module based on data creating , Data can be crated on mongodb , or it can be imported from other source
We will learn about insert method and different ways of importing data into mongo DB
> Insert methods
ther eare 3 mthods
1 ) insertOne({}) this will take one documetns
2 ) insertMany({}) this tail ltake multiple documents
3 ) insert() It takes both single/ multiple documents
@Abhinay-g
Abhinay-g / MongoDB reading data
Last active April 24, 2019 13:23
MongoDB reading data
>Intorduction
This module will consist of following
1) methods, Filters and Operators for Reading Data
2) query selector
3) Projection operator
>Operators
All command include a db.collectionName.MethodName({-parameter-})
parameter can be key value pair or it could be a Range
db.collectionName.MethodName({key:{$operator:value}})
@Abhinay-g
Abhinay-g / MongoDB updating Data
Last active May 5, 2019 15:05
MongoDB updating Data
>$set Operator
this is used to add update an existing field or add a new field
Sysntax : db.collection.updateOne/updateMany({--findQuery--},{$set:{fieldName:"value"}})
> $inc Operator for Increment and Decrement
this isus ed to increment / decrement the value
Systax : db.collection.updateOne/updateMany({--findQuery--},{$set:{fieldName:"value"} , $inc:{age: INCREMENT_VALUE}})
Note: $inc can be combined with other operator
IMP : You can not put $set and $inc on same field , it will throw an error ie updating and incrementing age will cause an error
@Abhinay-g
Abhinay-g / MongoDB Delete
Created May 5, 2019 15:42
MongoDB Delete
Delete one or many items from collection > db.collection.deleteOne/deleteMany(--findCondition--)
Delete Collection > db.collection.deleteMAny({})
Delete Entire Collection [Admin task] >>>> db.collection.drop()
Delete entire Database [Admin TAsk] >>>> db.deleteDatabase()
@Abhinay-g
Abhinay-g / MongoDB indexes
Last active September 7, 2022 13:33
MongoDB indexes
>Introduction
Indexes are to optimize read, update and delete operation.
Indexes load a extra funcnionality while inserting data into DB, mongoDb update indexes whenever a record in inserted
db.contacts.getIndexes() // to get all the indexes
> Why index are needed
By default MongoDB do COLLECTION lookup while read, update and delete operation which is time consuming in sense that
Thare is unknown number of records that match condition
records position is unknown to mongoDB , HENCE mongoDB iterate over each document looking for matching condition
Solution : we can create an index on the column which is frequently used to access records.
@Abhinay-g
Abhinay-g / MongoD Aggregation framework
Created May 27, 2019 18:43
MongoD Aggregation framework
Introduction:
Aggregation framework is just an alternative for a find method, here there is more controle given to find data in custom format by using
$match, $sort, $group, $project
This is type of data is only gathered for smaller audiance as we design database based on larger audiance
In aggregation we create a pipeline where in data of one operator is passed to other operator
Aggregation method:
for aggregation we use Aggrigate() method which takes multiple parameter in sequence. Note this aggregation method can take advantage of
mongodb indexes.
Note: for this tutorial persons.json is used
@Abhinay-g
Abhinay-g / Javascript: Variable hoisting
Last active July 15, 2019 07:41
Javascript: Variable hoisting
referance : https://scotch.io/tutorials/understanding-hoisting-in-javascript
concept: all the declaration of var , let , const , function declaration, class declaration is moved up in run time.
var: variable hoisted and get (initialized) default value of "undefined" [variable declared without var are added to global scope]
let/ const : variable is hoisted but not assigned to any value
function declaration: function declaration is hoisted to upward.
Note: function and variable with same name then there will be preferance given to variable assignment over but when variable declaration
only then preferance given to function declaration no matter what order they are defined