Created
January 23, 2018 07:30
-
-
Save wiyoe/fe6a25ac3db960462ca46124c6d07ed2 to your computer and use it in GitHub Desktop.
Loadash groupBy Count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dd = [ | |
| {"classroom_fk":9,"classroom_name":"9. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":10,"classroom_name":"10. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":10,"classroom_name":"10. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":9,"classroom_name":"9. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true} | |
| ] | |
| var result = _(dd) | |
| .groupBy('classroom_fk') | |
| .map(function(items, classroom_fk) { | |
| return { classroom_fk: classroom_fk, count: items.length }; | |
| }).value(); | |
| console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment