 ### Repository [https://github.com/mihaifm/linq](https://github.com/mihaifm/linq) ### What Will I Learn? - You will learn about linqjs. - You will learn how to install linqjs with your project. - You will learn how to summation values using linqjs. - You will learn how to average values using linqjs. - You will learn how to minimum values using linqjs. - You will learn how to maximum values using linqjs. - You will learn how to select specific column values using linqjs. ### Requirements - Node.JS - Basic knowledge of Javascript - Any suitable code editor ### Difficulty - Basic/Intermediate ### Tutorial Contents #### 1. About linqjs LINQ (Language Integrated Query) is query syntax in C# and VB.NET for saving and retrieving data from different sources. Linqjs is a javascript implementation of the .NET LINQ library. Which allows saving and retrieving data from json or array. It contains all the origial .NET methods with some extra methods. #### 2. Install > npm install linq At the start of the javascript file add this line. > const rlinq = require('linq'); This line will include linqjs package to the script so we can work with it. ### Declare an array which will be used on our following steps of tutorial  We have declared an array of products. which contains products id, name and its price. > var products = [ { "id": 100, "name": "Pendrive", "price": 500 }, { "id": 101, "name": "Ram", "price": 1000 }, { "id": 102, "name": "Motherboard", "price": 5000 }, { "id": 103, "name": "Keyboard", "price": 450 } ] #### 3. Summation Our target is to summation the total price of the products. Our following single line of code using linqjs will summarize the total price of products. > var totalprice = rlinq.from(products).sum("$.price"); Explanation : - <b>rlinq</b> is the references of <b>linqjs</b> - we have passed products list on the parameter of <b>from</b> function - we mentioned <b>price</b> to sum by passing <b>$.price</b>(lambda expression) as a parameter of sum function - this will return the summarize price of products #### 4. Average Our target is to calculate the average price of the products. Our following single line of code using linqjs will return the average price of the products. > var averageprice = rlinq.from(products).average("$.price"); Explanation : - <b>rlinq</b> is the references of <b>linqjs</b> - we have passed products list on the parameter of <b>from</b> function - we mentioned <b>price</b> to calculate average by passing <b>$.price</b>(lambda expression) as a parameter of average function - this will return the average price of products #### 5. Minimum Our target is to find out minimum price of the products. Our following single line of code using linqjs will return the minimum price. > var minimumprice = rlinq.from(products).min("$.price"); Explanation : - <b>rlinq</b> is the references of <b>linqjs</b> - we have passed products list on the parameter of <b>from</b> function - we mentioned <b>price</b> to find minimum by passing <b>$.price</b>(lambda expression) as a parameter of min function - this will return the minimum price of products #### 6. Maximum Our target is to find out maximum price of the products. Our following single line of code using linqjs will return the maximum price. > var maximumprice = rlinq.from(products).max("$.price"); Explanation : - <b>rlinq</b> is the references of <b>linqjs</b> - we have passed products list on the parameter of <b>from</b> function - we mentioned <b>price</b> to find maximum by passing <b>$.price</b>(lambda expression) as a parameter of max function - this will return the maximum price of products #### 7. Select Our target is to select all products name in a array. Our following single line of code using linqjs will return all products name. > var productName = rlinq.from(products).select("$.name").toArray(); Explanation : - <b>rlinq</b> is the references of <b>linqjs</b> - we have passed products list on the parameter of <b>from</b> function - we mentioned <b>name</b> to find maximum by passing <b>$.name</b>(lambda expression) as a parameter of select function - toArray function will make a list of product name from original product list ### Proof of Work Done [Tutorial Code](https://github.com/touhidalam69/linqjsTutorial/blob/master/src/01_lambda_Sum_Avarage_Minimum_Maximum_Select.js) GitHub: [https://github.com/touhidalam69/linqjsTutorial](https://github.com/touhidalam69/linqjsTutorial)
author | touhidalam69 |
---|---|
permlink | linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select |
category | utopian-io |
json_metadata | {"tags":["utopian-io","tutorials","javascript","linqjs","nodejs"],"image":["https://cdn.steemitimages.com/DQmecCSuSwCqMYsfGHVn8Fu8LuRsrPu1EtuDMLqApMnHJa2/linqjs.png","https://cdn.steemitimages.com/DQmYvggfp3uFwhFMcJiyFbYyzRXteUgCe9tE3QmCvGhdaC7/products.png"],"links":["https://github.com/mihaifm/linq","https://github.com/touhidalam69/linqjsTutorial/blob/master/src/01_lambda_Sum_Avarage_Minimum_Maximum_Select.js","https://github.com/touhidalam69/linqjsTutorial"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-06-10 16:32:27 |
last_update | 2018-06-10 16:32:27 |
depth | 0 |
children | 6 |
last_payout | 2018-06-17 16:32:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.125 HBD |
curator_payout_value | 0.016 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,694 |
author_reputation | 2,409,777,621,558 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,163,932 |
net_rshares | 54,043,991,764 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
yuxi | 0 | 2,658,025,353 | 10% | ||
leir | 0 | 703,476,548 | 20% | ||
osm0sis | 0 | 7,000,895,305 | 15% | ||
jaff8 | 0 | 0 | 100% | ||
zapncrap | 0 | 9,613,061,336 | 30% | ||
mvanyi | 0 | 1,728,572,647 | 100% | ||
olivaw | 0 | 9,668,740,453 | 100% | ||
r351574nc3 | 0 | 540,021,841 | 1.25% | ||
curx | 0 | 9,824,010,631 | 30% | ||
esmerallda | 0 | 257,216,930 | 100% | ||
properfraction | 0 | 550,690,924 | 100% | ||
touhidalam69 | 0 | 3,964,906,273 | 100% | ||
shila | 0 | 51,155,303 | 100% | ||
tow-heed | 0 | 0 | 100% | ||
dick.sledge | 0 | 6,289,487,417 | 0.85% | ||
beetlevc | 0 | 478,622,627 | 2% | ||
earnestcar | 0 | 567,245,527 | 100% | ||
drsensor | 0 | 147,862,649 | 10% |
In addition to @portugalcoin's notes, your tutorial does not really capture a proper structure nor content of a tutorial. - Simply stating aggregate functions such as sum/avg, and copy/pasting the same comment over and over does not stand as a proper tutorial - You did not provide any real life useful scenario of utilizing those functions - You did not provide any screenshots to capture your proper work and result of work done. - Your code (github) simply defined variables, you did not even print the result - What does this even mean: "we mentioned name to find maximum by passing $.name(lambda expression) as a parameter of select function" basically a copy paste error from sentence above? Please work on providing better quality tutorials in the future. ---- Need help? Write a ticket on https://support.utopian.io/. Chat with us on [Discord](https://discord.gg/uTyJkNm). [[utopian-moderator]](https://join.utopian.io/)
author | mcfarhat |
---|---|
permlink | re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180611t111356688z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"users":["portugalcoin"],"links":["https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"} |
created | 2018-06-11 11:14:03 |
last_update | 2018-06-11 11:14:03 |
depth | 1 |
children | 1 |
last_payout | 2018-06-18 11:14:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 932 |
author_reputation | 150,651,671,367,256 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,279,241 |
net_rshares | 3,949,492,369 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
touhidalam69 | 0 | 3,949,492,369 | 100% |
Hi @mcfarhat66, Thanks for asking me about my mistakes on this tutorial post. I will be aware in future contribution. Thanks again πππ
author | touhidalam69 |
---|---|
permlink | re-mcfarhat-re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180611t210404995z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"busy","app":"busy/2.4.0"} |
created | 2018-06-11 21:04:09 |
last_update | 2018-06-11 21:04:33 |
depth | 2 |
children | 0 |
last_payout | 2018-06-18 21:04:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 136 |
author_reputation | 2,409,777,621,558 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,352,031 |
net_rshares | 3,576,600,205 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
melooo182 | 0 | 3,576,600,205 | 49% |
Thank you for your contribution. While I liked the content of your contribution, I would still like to extend few advices for your upcoming contributions: - <b>Resources:</b> Put more extra resources. - <b>Structure of the tutorial:</b> Improve the structure of the tutorial. - <b>Avoid repetition:</b>Β Frequent use of words or phrases makes reading the tutorial more annoying. Looking forward to your upcoming tutorials. See in this <a href="https://steemit.com/utopian-io/@espoem/make-your-posts-look-great-in-steemit-and-busy">link</a> an example of a good tutorial. Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category. To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/8/31324323). ---- Need help? Write a ticket on https://support.utopian.io/. Chat with us on [Discord](https://discord.gg/uTyJkNm). [[utopian-moderator]](https://join.utopian.io/)
author | portugalcoin |
---|---|
permlink | re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180610t224322117z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://steemit.com/utopian-io/@espoem/make-your-posts-look-great-in-steemit-and-busy","https://join.utopian.io/guidelines","https://review.utopian.io/result/8/31324323","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"} |
created | 2018-06-10 22:43:21 |
last_update | 2018-06-10 22:43:21 |
depth | 1 |
children | 1 |
last_payout | 2018-06-17 22:43:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,065 |
author_reputation | 599,442,230,817,318 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,205,828 |
net_rshares | 4,033,079,509 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
touhidalam69 | 0 | 4,033,079,509 | 100% |
Hello, @portugalcoin59, Thanks for your nice observation about my tutorial post. Actually this is my first contribution post on this category. I will keep it mind all of your advices on my following contribution. Thanks again βΊβΊβΊ
author | touhidalam69 |
---|---|
permlink | re-portugalcoin-re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180611t205057708z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"busy","app":"busy/2.4.0"} |
created | 2018-06-11 20:51:00 |
last_update | 2018-06-11 20:51:00 |
depth | 2 |
children | 0 |
last_payout | 2018-06-18 20:51:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.029 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 230 |
author_reputation | 2,409,777,621,558 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,350,611 |
net_rshares | 11,817,633,318 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
melbookermusic | 0 | 11,817,633,318 | 24% |
Great tutorial thanks for sharing.
author | steem0 |
---|---|
permlink | re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180610t163504633z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-06-10 16:35:06 |
last_update | 2018-06-10 16:35:06 |
depth | 1 |
children | 1 |
last_payout | 2018-06-17 16:35:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 34 |
author_reputation | 907,702,232,817 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,164,266 |
net_rshares | 1,964,297,792 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
touhidalam69 | 0 | 1,964,297,792 | 50% |
Thanks for your complement
author | touhidalam69 |
---|---|
permlink | re-steem0-re-touhidalam69-linqjs-tutorial-01-nodejs-with-lambda-expression-install-sum-avg-min-max-select-20180611t214627932z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"busy","app":"busy/2.4.0"} |
created | 2018-06-11 21:46:30 |
last_update | 2018-06-11 21:46:30 |
depth | 2 |
children | 0 |
last_payout | 2018-06-18 21:46:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 26 |
author_reputation | 2,409,777,621,558 |
root_title | "Linqjs Tutorial #01 - Nodejs with Lambda Expression (Install, Sum, Avg, Min, Max, Select)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,356,468 |
net_rshares | 0 |