Laravel - Many-to-many relation, product count by product featureDjango - querying objects via many-to-many relationFor each result return by SQL query I want as to give a different nameSQL filter from many-to-many relationshipLaravel count categories joinLaravel Eloquent: how to filter reviews of products by product category and/or product brand?How to count how many articles belongs which category?found error in laravel 5.4,Property [categories] does not exist on this collection instanceCounting Rows based on Identifier - LaravelHow to make filter products on laravel correctly?Laravel Model Count By Relationship

How is it believable that Euron could so easily pull off this ambush?

My large rocket is still flipping over

In the figure, a quarter circle, a semicircle and a circle are mutually tangent inside a square of side length 2. Find the radius of the circle.

Function annotation with two or more return parameters

Drug Testing and Prescribed Medications

Select list elements based on other list

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

How does jetBlue determine its boarding order?

Splitting polygons and dividing attribute value proportionally using ArcGIS Pro?

Convert a huge txt-file into a dataset

Can anyone identify this unknown 1988 PC card from The Palantir Corporation?

Appropriate age to involve kids in life changing decisions

If an attacker targets a creature with the Sanctuary spell cast on them, but fails the Wisdom save, can they choose not to attack anyone else?

How can I finally understand the confusing modal verb "мочь"?

Gift for mentor after his thesis defense?

In a series of books, what happens after the coming of age?

Do the Zhentarim fire members for killing fellow members?

Translation of "invincible independence"

What does the copyright in a dissertation protect exactly?

How could a humanoid creature completely form within the span of 24 hours?

How to increase speed on my hybrid bike with flat handlebars and 700X35C tyres?

My parents are Afghan

Why doesn't increasing the temperature of something like wood or paper set them on fire?

Why is the blank symbol not considered part of the input alphabet of a Turing machine?



Laravel - Many-to-many relation, product count by product feature


Django - querying objects via many-to-many relationFor each result return by SQL query I want as to give a different nameSQL filter from many-to-many relationshipLaravel count categories joinLaravel Eloquent: how to filter reviews of products by product category and/or product brand?How to count how many articles belongs which category?found error in laravel 5.4,Property [categories] does not exist on this collection instanceCounting Rows based on Identifier - LaravelHow to make filter products on laravel correctly?Laravel Model Count By Relationship






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Trying to get the count of products by its features(many-to-many)
For instance,



Product::with([’features’])->where(category_id, $category_id)->get();


Product A->feature1->id



/feature2->id



/feature3->id



Product B->feature3->id



/feature4->id



/feature6->id



.....



how could i get product count from each feature (after filtered by product category)



I am not good at explain in wording, tried my best.



Final result
feature 1 -> 19 products
feature 2 -> 5 products
...










share|improve this question




























    0















    Trying to get the count of products by its features(many-to-many)
    For instance,



    Product::with([’features’])->where(category_id, $category_id)->get();


    Product A->feature1->id



    /feature2->id



    /feature3->id



    Product B->feature3->id



    /feature4->id



    /feature6->id



    .....



    how could i get product count from each feature (after filtered by product category)



    I am not good at explain in wording, tried my best.



    Final result
    feature 1 -> 19 products
    feature 2 -> 5 products
    ...










    share|improve this question
























      0












      0








      0


      0






      Trying to get the count of products by its features(many-to-many)
      For instance,



      Product::with([’features’])->where(category_id, $category_id)->get();


      Product A->feature1->id



      /feature2->id



      /feature3->id



      Product B->feature3->id



      /feature4->id



      /feature6->id



      .....



      how could i get product count from each feature (after filtered by product category)



      I am not good at explain in wording, tried my best.



      Final result
      feature 1 -> 19 products
      feature 2 -> 5 products
      ...










      share|improve this question














      Trying to get the count of products by its features(many-to-many)
      For instance,



      Product::with([’features’])->where(category_id, $category_id)->get();


      Product A->feature1->id



      /feature2->id



      /feature3->id



      Product B->feature3->id



      /feature4->id



      /feature6->id



      .....



      how could i get product count from each feature (after filtered by product category)



      I am not good at explain in wording, tried my best.



      Final result
      feature 1 -> 19 products
      feature 2 -> 5 products
      ...







      php laravel eloquent many-to-many






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 5:49









      Hao PhungHao Phung

      397




      397






















          4 Answers
          4






          active

          oldest

          votes


















          0














          Try this:



          Select product_id from products where category_id = "'.$category_id.'" group by feature_id;





          share|improve this answer























          • This is a good idea, i will try after i got home

            – Hao Phung
            Mar 23 at 6:11











          • How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

            – Hao Phung
            Mar 23 at 11:20











          • $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

            – Hao Phung
            Mar 23 at 16:27











          • I am almost there, but not collection doesn't query the category, it includes everything

            – Hao Phung
            Mar 23 at 16:28


















          0














          You should Define relation within your Product and Feature Model



          class Product extends Model 
          public function features()
          return $this->belongsTo(Feature::class);



          class Feature extends Model
          public function products()
          return $this->hasMany(Product::class);




          I presume each Product has an attribute feature_id which hold the id of the Feature to which it's belongsTo.



          $products = Product::with([’features’])->where(category_id, $category_id)->get(); // This query will return list of product

          foreach($products as $product)
          // You can access $feature of product like this
          $feature = $product->feature;



          Because I have already define the reverse relation between the both Model I can access Product from Feature as well.



          $feature->products(); // This will return a collection of Product and I can perform any sort of query on that too

          // Like count number of Products
          $feature->products()->count();
          $feature->products()->first(); // get the first product
          $feature->products()->last(); // get the last product


          And so on and so fourth






          share|improve this answer























          • They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

            – Hao Phung
            Mar 23 at 11:12


















          0














          Assuming you have products relationship on the Feature model you can try this!



          $features = Feature::withCount(['products' => function($query)
          $query->where('category_id', $category_id);
          ])->get();


          You will have a products_count with each record of the collection.






          share|improve this answer

























          • The category_id belongs to products, not from feature, so where clause doesn't work

            – Hao Phung
            Mar 23 at 16:48











          • @HaoPhung i have updated my answer please try it!

            – Haider Ali
            Mar 23 at 17:17


















          0














          This will do the trick



           with(['products' => function($q) use($category_id)
          $q->where('category_id',18);
          ])

          ->find($feature_ids)

          ->groupBy('feature_type_id');





          share|improve this answer























          • Please mark the answer as accepted. This shows other users that the issue is resolved.

            – Jonas Staudenmeir
            Mar 29 at 22:05











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311014%2flaravel-many-to-many-relation-product-count-by-product-feature%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try this:



          Select product_id from products where category_id = "'.$category_id.'" group by feature_id;





          share|improve this answer























          • This is a good idea, i will try after i got home

            – Hao Phung
            Mar 23 at 6:11











          • How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

            – Hao Phung
            Mar 23 at 11:20











          • $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

            – Hao Phung
            Mar 23 at 16:27











          • I am almost there, but not collection doesn't query the category, it includes everything

            – Hao Phung
            Mar 23 at 16:28















          0














          Try this:



          Select product_id from products where category_id = "'.$category_id.'" group by feature_id;





          share|improve this answer























          • This is a good idea, i will try after i got home

            – Hao Phung
            Mar 23 at 6:11











          • How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

            – Hao Phung
            Mar 23 at 11:20











          • $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

            – Hao Phung
            Mar 23 at 16:27











          • I am almost there, but not collection doesn't query the category, it includes everything

            – Hao Phung
            Mar 23 at 16:28













          0












          0








          0







          Try this:



          Select product_id from products where category_id = "'.$category_id.'" group by feature_id;





          share|improve this answer













          Try this:



          Select product_id from products where category_id = "'.$category_id.'" group by feature_id;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 5:57









          Korat PrakashKorat Prakash

          1315




          1315












          • This is a good idea, i will try after i got home

            – Hao Phung
            Mar 23 at 6:11











          • How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

            – Hao Phung
            Mar 23 at 11:20











          • $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

            – Hao Phung
            Mar 23 at 16:27











          • I am almost there, but not collection doesn't query the category, it includes everything

            – Hao Phung
            Mar 23 at 16:28

















          • This is a good idea, i will try after i got home

            – Hao Phung
            Mar 23 at 6:11











          • How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

            – Hao Phung
            Mar 23 at 11:20











          • $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

            – Hao Phung
            Mar 23 at 16:27











          • I am almost there, but not collection doesn't query the category, it includes everything

            – Hao Phung
            Mar 23 at 16:28
















          This is a good idea, i will try after i got home

          – Hao Phung
          Mar 23 at 6:11





          This is a good idea, i will try after i got home

          – Hao Phung
          Mar 23 at 6:11













          How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

          – Hao Phung
          Mar 23 at 11:20





          How could I groupBy feature->id? in product collection each product might have couple feature collections, so product->features->feature1->id, product->features->feature2->id, product->features->feature3->id

          – Hao Phung
          Mar 23 at 11:20













          $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

          – Hao Phung
          Mar 23 at 16:27





          $product_features_with_count = Feature:: with(['products']) // ->where('products.category_id', $id) ->whereHas('products', function($q) use($id) return $q->where('products.category_id', $id); ) ->find($feature_ids) ->groupBy('feature_type_id');

          – Hao Phung
          Mar 23 at 16:27













          I am almost there, but not collection doesn't query the category, it includes everything

          – Hao Phung
          Mar 23 at 16:28





          I am almost there, but not collection doesn't query the category, it includes everything

          – Hao Phung
          Mar 23 at 16:28













          0














          You should Define relation within your Product and Feature Model



          class Product extends Model 
          public function features()
          return $this->belongsTo(Feature::class);



          class Feature extends Model
          public function products()
          return $this->hasMany(Product::class);




          I presume each Product has an attribute feature_id which hold the id of the Feature to which it's belongsTo.



          $products = Product::with([’features’])->where(category_id, $category_id)->get(); // This query will return list of product

          foreach($products as $product)
          // You can access $feature of product like this
          $feature = $product->feature;



          Because I have already define the reverse relation between the both Model I can access Product from Feature as well.



          $feature->products(); // This will return a collection of Product and I can perform any sort of query on that too

          // Like count number of Products
          $feature->products()->count();
          $feature->products()->first(); // get the first product
          $feature->products()->last(); // get the last product


          And so on and so fourth






          share|improve this answer























          • They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

            – Hao Phung
            Mar 23 at 11:12















          0














          You should Define relation within your Product and Feature Model



          class Product extends Model 
          public function features()
          return $this->belongsTo(Feature::class);



          class Feature extends Model
          public function products()
          return $this->hasMany(Product::class);




          I presume each Product has an attribute feature_id which hold the id of the Feature to which it's belongsTo.



          $products = Product::with([’features’])->where(category_id, $category_id)->get(); // This query will return list of product

          foreach($products as $product)
          // You can access $feature of product like this
          $feature = $product->feature;



          Because I have already define the reverse relation between the both Model I can access Product from Feature as well.



          $feature->products(); // This will return a collection of Product and I can perform any sort of query on that too

          // Like count number of Products
          $feature->products()->count();
          $feature->products()->first(); // get the first product
          $feature->products()->last(); // get the last product


          And so on and so fourth






          share|improve this answer























          • They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

            – Hao Phung
            Mar 23 at 11:12













          0












          0








          0







          You should Define relation within your Product and Feature Model



          class Product extends Model 
          public function features()
          return $this->belongsTo(Feature::class);



          class Feature extends Model
          public function products()
          return $this->hasMany(Product::class);




          I presume each Product has an attribute feature_id which hold the id of the Feature to which it's belongsTo.



          $products = Product::with([’features’])->where(category_id, $category_id)->get(); // This query will return list of product

          foreach($products as $product)
          // You can access $feature of product like this
          $feature = $product->feature;



          Because I have already define the reverse relation between the both Model I can access Product from Feature as well.



          $feature->products(); // This will return a collection of Product and I can perform any sort of query on that too

          // Like count number of Products
          $feature->products()->count();
          $feature->products()->first(); // get the first product
          $feature->products()->last(); // get the last product


          And so on and so fourth






          share|improve this answer













          You should Define relation within your Product and Feature Model



          class Product extends Model 
          public function features()
          return $this->belongsTo(Feature::class);



          class Feature extends Model
          public function products()
          return $this->hasMany(Product::class);




          I presume each Product has an attribute feature_id which hold the id of the Feature to which it's belongsTo.



          $products = Product::with([’features’])->where(category_id, $category_id)->get(); // This query will return list of product

          foreach($products as $product)
          // You can access $feature of product like this
          $feature = $product->feature;



          Because I have already define the reverse relation between the both Model I can access Product from Feature as well.



          $feature->products(); // This will return a collection of Product and I can perform any sort of query on that too

          // Like count number of Products
          $feature->products()->count();
          $feature->products()->first(); // get the first product
          $feature->products()->last(); // get the last product


          And so on and so fourth







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 6:38









          Yves KipondoYves Kipondo

          1,563715




          1,563715












          • They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

            – Hao Phung
            Mar 23 at 11:12

















          • They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

            – Hao Phung
            Mar 23 at 11:12
















          They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

          – Hao Phung
          Mar 23 at 11:12





          They have been defined, and i also have productFeature model. the collection of products has been filtered by category and also some features too, so the productFeature model seems doesn't help

          – Hao Phung
          Mar 23 at 11:12











          0














          Assuming you have products relationship on the Feature model you can try this!



          $features = Feature::withCount(['products' => function($query)
          $query->where('category_id', $category_id);
          ])->get();


          You will have a products_count with each record of the collection.






          share|improve this answer

























          • The category_id belongs to products, not from feature, so where clause doesn't work

            – Hao Phung
            Mar 23 at 16:48











          • @HaoPhung i have updated my answer please try it!

            – Haider Ali
            Mar 23 at 17:17















          0














          Assuming you have products relationship on the Feature model you can try this!



          $features = Feature::withCount(['products' => function($query)
          $query->where('category_id', $category_id);
          ])->get();


          You will have a products_count with each record of the collection.






          share|improve this answer

























          • The category_id belongs to products, not from feature, so where clause doesn't work

            – Hao Phung
            Mar 23 at 16:48











          • @HaoPhung i have updated my answer please try it!

            – Haider Ali
            Mar 23 at 17:17













          0












          0








          0







          Assuming you have products relationship on the Feature model you can try this!



          $features = Feature::withCount(['products' => function($query)
          $query->where('category_id', $category_id);
          ])->get();


          You will have a products_count with each record of the collection.






          share|improve this answer















          Assuming you have products relationship on the Feature model you can try this!



          $features = Feature::withCount(['products' => function($query)
          $query->where('category_id', $category_id);
          ])->get();


          You will have a products_count with each record of the collection.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 23 at 17:17

























          answered Mar 23 at 6:58









          Haider AliHaider Ali

          681618




          681618












          • The category_id belongs to products, not from feature, so where clause doesn't work

            – Hao Phung
            Mar 23 at 16:48











          • @HaoPhung i have updated my answer please try it!

            – Haider Ali
            Mar 23 at 17:17

















          • The category_id belongs to products, not from feature, so where clause doesn't work

            – Hao Phung
            Mar 23 at 16:48











          • @HaoPhung i have updated my answer please try it!

            – Haider Ali
            Mar 23 at 17:17
















          The category_id belongs to products, not from feature, so where clause doesn't work

          – Hao Phung
          Mar 23 at 16:48





          The category_id belongs to products, not from feature, so where clause doesn't work

          – Hao Phung
          Mar 23 at 16:48













          @HaoPhung i have updated my answer please try it!

          – Haider Ali
          Mar 23 at 17:17





          @HaoPhung i have updated my answer please try it!

          – Haider Ali
          Mar 23 at 17:17











          0














          This will do the trick



           with(['products' => function($q) use($category_id)
          $q->where('category_id',18);
          ])

          ->find($feature_ids)

          ->groupBy('feature_type_id');





          share|improve this answer























          • Please mark the answer as accepted. This shows other users that the issue is resolved.

            – Jonas Staudenmeir
            Mar 29 at 22:05















          0














          This will do the trick



           with(['products' => function($q) use($category_id)
          $q->where('category_id',18);
          ])

          ->find($feature_ids)

          ->groupBy('feature_type_id');





          share|improve this answer























          • Please mark the answer as accepted. This shows other users that the issue is resolved.

            – Jonas Staudenmeir
            Mar 29 at 22:05













          0












          0








          0







          This will do the trick



           with(['products' => function($q) use($category_id)
          $q->where('category_id',18);
          ])

          ->find($feature_ids)

          ->groupBy('feature_type_id');





          share|improve this answer













          This will do the trick



           with(['products' => function($q) use($category_id)
          $q->where('category_id',18);
          ])

          ->find($feature_ids)

          ->groupBy('feature_type_id');






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 18:06









          Hao PhungHao Phung

          397




          397












          • Please mark the answer as accepted. This shows other users that the issue is resolved.

            – Jonas Staudenmeir
            Mar 29 at 22:05

















          • Please mark the answer as accepted. This shows other users that the issue is resolved.

            – Jonas Staudenmeir
            Mar 29 at 22:05
















          Please mark the answer as accepted. This shows other users that the issue is resolved.

          – Jonas Staudenmeir
          Mar 29 at 22:05





          Please mark the answer as accepted. This shows other users that the issue is resolved.

          – Jonas Staudenmeir
          Mar 29 at 22:05

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311014%2flaravel-many-to-many-relation-product-count-by-product-feature%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript