GithubHelp home page GithubHelp logo

adilfaiz001 / learning-hub Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 1 KB

This repository is to mark daily checkpoint, hurdles faced or any good learning which needs to be noted in all areas of software development, will noted in issue section

learning-hub's People

Contributors

adilfaiz001 avatar

Watchers

 avatar  avatar

learning-hub's Issues

ANGULAR: LIFECYCLE METHODS

14th Dec, 2020

constructor
If this is part of parent and parent loads then irrespective of a child being routed or not, constructor loaded.

onInit
Function loaded on create a view as if parent loaded or not, it doesn't effect child.

MONGO: MULTI-LEVEL POPULATION QUERY WITH SELECTION ON NESTED KEY

When one schema is using reference to other schema and other schema is using nested level of reference, -

QUERY

QUERY EXPLANATION
In above query, KEY company is being populated and KEY company_details is selected and further populated, from which KEY followers is selected, which is array of REF OBJECTID to another schema of users, therefore, its being populated as followers.user

company: {
   company_details: {
      followers: {
            user: [{ref: OBJECTID}]
      }
    }
}

MONGO: QUERY METHODS

USE CASE

New comment to be added to the comments document in an array, so using findByIdAndUpdate with query function $push to add element in the array. This successfully added the comment in the document and return whole comments document with array of comment objects

ISSUE

There is no reference to the comment in an array which comment is added(as of now, its push method on an array, so it is last element) but thinking of issue like in future when multiple user comment on same post, will this query return updated array, example : user_1 commented and query adding and returning it while user_2 at same commented on this and user_1 query return a new updated array, will this array last element be user_1 or user_2 ?

SOLUTION

  1. Using saving id at the time of updating to refer on the event of returning new set on query findAndUpdate
  2. NEED TO FIND : Does findAndUpdate returns the only updating array of anything at the time of querying it, example user_1 update it, so this query returns only upto this user, whats happening to this doc at other user end, wont affect at user_1 end.

MONGO: AGGREGATION NOTES

19th Nov, 2020

Selecting all documents of a collection and grouping them by a key and pushing all document of that particular key into a array, against that key_

mongo_group

RESULT:

[
  {
    company: "ABC",
    product: [
        {product_1},
        {product_2}
    ]
  }
]

NOTE: Use $$ROOT for pushing complete document into array in parallel with a key which is aggregate by group

HTTP

1. Sending Array in HTTP Request

DOING
Sending Array in POST Request and server receives this as string, parsing array using middlewares/parsers and then using it.

STANDARD

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.