<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>angular.js &#8211; The SIGMA</title>
	<atom:link href="https://danushka96.github.io/sigma/index.php/tag/angular-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://danushka96.github.io/sigma/</link>
	<description>&#60;For Those Who Code/&#62;</description>
	<lastBuildDate>
	Sat, 02 Mar 2019 16:57:34 +0000	</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1.1</generator>
	<item>
		<title>MEAN Stack වලින් Sample Application එකක් Design කරගමු. (PART 03)</title>
		<link>https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/#respond</comments>
				<pubDate>Wed, 20 Feb 2019 16:28:44 +0000</pubDate>
		<dc:creator><![CDATA[Danushka Herath]]></dc:creator>
				<category><![CDATA[angular.js]]></category>
		<category><![CDATA[mean stack]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[back-end]]></category>
		<category><![CDATA[front-end]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=1906</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span> අපි කලින් ලිපි 2න් කතා කලා fontend එක සහ backend එක Design කරගන්න විදිය. මේ ලිපියෙන් කතා කරන්නේ මේ වෙන වෙනම හදා ගත්ත fontend එකයි Backend එකයි එකට Connect කරගන්නේ කොහොමද කියලා. කලින් ලිපි 2 බැලුවේ නැත්නම් මෙතනින් බලන්න Part 01part 02 මුලින්ම frontend කියන folder එක ඇතුලට ගිහින් එතනින්<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/">MEAN Stack වලින් Sample Application එකක් Design කරගමු. (PART 03)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span>
<p>අපි කලින් ලිපි 2න් කතා කලා fontend එක සහ backend එක Design කරගන්න විදිය. මේ ලිපියෙන් කතා කරන්නේ මේ වෙන වෙනම හදා ගත්ත fontend එකයි Backend එකයි එකට Connect කරගන්නේ කොහොමද කියලා. කලින් ලිපි 2 බැලුවේ නැත්නම් මෙතනින් බලන්න</p>



<p><a href="https://danushka96.github.io/sigma/index.php/2019/02/19/mean-stack-sample-application-1/">Part 01</a><br><a href="https://danushka96.github.io/sigma/index.php/2019/02/19/mean-stack-sample-application-design-part-02/">part 02</a></p>



<p>මුලින්ම frontend කියන folder එක ඇතුලට ගිහින් එතනින් command prompt එකක් open කරන්න. දැන් අපි කරන්න හදන්නේ font එකේ පොඩි වෙනස්කම් කිහිපයක් කරන්න.</p>



<pre class="wp-block-preformatted">cd frontend</pre>



<p>දැන් අපි අලුතින් Issue Service එකක් හදා ගන්න ඕන. ඒ service එක හරහා තමයි අපි Backend එකෙන් අපිට ඕන Data ගන්න සහ දාන්න යන්නේ. මුලින්ම ඒක මේ විදියට Generate කරගමු.</p>



<pre class="wp-block-preformatted">ng g s services/Issue</pre>



<p>මේ විදියට issue service එක generate කරගත්තාම services කියලා folder එකක් ඇතුලේ issue.service.ts කියන file එක generate වෙනවා. දැන් අපි මේ issue service එක app.module.ts එකට import කරගන්න ඕන.</p>



<pre class="wp-block-preformatted"> import { IssueService } from './services/issue.service'; <br></pre>



<p>ඒ වගේම providers array එක ඇතුලටත් මේක දාගන්න. </p>



<pre class="wp-block-preformatted">providers: [IssueService]</pre>



<p>මේකෙත් මේ issue Service එක අපේ components ඇතුලේ use කරන්න පුළුවන් වෙනවා.</p>



<h3 id="9ff5">Implementing IssueService</h3>



<p>කලින් කිවුවා වගේ මේ issue Service එකේ අරමුණ තමයි backend එකත් එක්ක ගනුදෙනු කිරීම. ඒකට අපි http requests යොදා ගන්නවා. ඒක නිසා මේ විදියට මුලින්ම issue.service.ts file එකට httpClient එක import කරගන්න. </p>



<pre class="wp-block-preformatted">import { HttpClient } from '@angular/common/http';</pre>



<p>ඒ වගේම Constructor එකට මේ http service එක inject කරගන්න මේ විදියට</p>



<pre class="wp-block-preformatted">constructor(private http: HttpClient) {}</pre>



<h3 id="def9">Retrieving Issues</h3>



<p>අපි දැන් බලමු කොහොමද Database එකේ save වෙලා තියෙන issue එකක් හෝ කිහිපයක් Backend එක හරහා Retrieve කරන්නේ කොහොමද කියලා.</p>



<p>මේකෙ වර්ග 2ක් තියෙනවා. ඒ කියන්නේ අපි issue ID එකක් දුන්නාම අදාල issue එක ගන්න එකයි තියෙන ඔක්කොම Issues ටික ගන්න එකයි. මේ method 2 හදා ගන්න විදිය බලමු. </p>



<pre class="wp-block-preformatted"> import { Injectable } from '@angular/core';<br> import { HttpClient } from '@angular/common/http';<br><br> @Injectable({<br>   providedIn: 'root'<br> })<br><br> export class IssueService {<br>   uri = 'http://localhost:4000/';<br>   constructor(private http: HttpClient) {<br>   }<br>   getIssues() {<br>     return this.http.get(<code>${this.uri}/issues</code>);<br>   }<br>   getIssueById(id) {<br>     return this.http.get(<code>${this.uri}/issues/${id}</code>);<br>   }<br> }</pre>



<p>මේකෙදි අපි කරන්නේ http://localhost:4000/issues කියන backend එක response කරන url එකට get request එකක් යවලා json object එකක් විදියට result එකක් ගන්නවා. getIssueById method එකෙන් කරන්නෙත් ඒ වගේම issue id එක දුන්නම අදාල issue එක josn object එකක් විදියට එළියට ගන්නවා.</p>



<h3 id="04da">Adding Issues</h3>



<p>මේකෙදි අපි post request එකක් විදියට අපිට add කරන්න ඕන issue එකේ Data ටික යවන්න ඕන. ඒක කරන්නේ මේ විදියට..</p>



<pre class="wp-block-preformatted">   addIssue(title, responsible, description, severity) {<br>     const issue = {<br>       title: title,<br>       responsible: responsible,<br>       description: description,<br>       severity: severity<br>     };<br>     return this.http.post(<code>${this.uri}/issues/add</code>, issue);<br>   }</pre>



<p>ඔයාලට පේනවා ඇති මෙතනදි අපි post request එකත් එක්ක issue කියලා අපි අලුතින් හදා ගත්ත object එකත් යවනවා. මේ request එක යැවුවට පස්සේ එතනින් එහාට Backend එක තමයි Database operations handle කරගන්නේ. මතක ඇති අපි කලින් මේ methods ටික backend එකේ implement කලා. </p>



<h3 id="9b4b">Updating Issues</h3>



<p>කලින් කරපු addIssue එක වගේම post request එකක් යවනවා මේකෙත් Update වෙන්න ඕන dataත් එක්ක.</p>



<pre class="wp-block-preformatted">updateIssue(id, title, responsible, description, severity, status) {<br>     const issue = {<br>       title: title,<br>       responsible: responsible,<br>       description: description,<br>       severity: severity,<br>       status: status<br>     };<br>     return this.http.post(<code>${this.uri}/issues/update/${id}</code>, issue);<br>   }</pre>



<h3 id="a9b4">Deleting Issues</h3>



<p>මේකෙදි අපි කරන්නේ අපිට Delete කරන්න ඕන issue එකේ id එක get request එකක් විදියට යනවනවා backend එකට</p>



<pre class="wp-block-preformatted">deleteIssue(id) {<br>   return this.http.get(<code>${this.uri}/issues/delete/${id}</code>);<br>}</pre>



<p>මේ පහලින් තියෙන්නේ සම්පූර්ණ issue service file එකේ තියෙන code එක.</p>



<pre class="wp-block-preformatted"> import { Injectable } from '@angular/core';<br> import { HttpClient } from '@angular/common/http';<br><br> @Injectable({<br>   providedIn: 'root'<br> })<br><br> export class IssueService {<br>   uri = 'http://localhost:4000/';<br>   constructor(private http: HttpClient) {<br>   }<br>   addIssue(title, responsible, description, severity) {<br>     const issue = {<br>       title: title,<br>       responsible: responsible,<br>       description: description,<br>       severity: severity<br>     };<br>     return this.http.post(<code>${this.uri}/issues/add</code>, issue);<br>   }<br>   getIssues() {<br>     return this.http.get(<code>${this.uri}/issues</code>);<br>   }<br>   getIssueById(id) {<br>     return this.http.get(<code>${this.uri}/issues/${id}</code>);<br>   }<br>   updateIssue(id, title, responsible, description, severity, status) {<br>     const issue = {<br>       title: title,<br>       responsible: responsible,<br>       description: description,<br>       severity: severity,<br>       status: status<br>     };<br>     return this.http.post(<code>${this.uri}/issues/update/${id}</code>, issue);<br>   }<br>   deleteIssue(id) {<br>     return this.http.get(<code>${this.uri}/issues/delete/${id}</code>);<br>   }<br> }</pre>



<h3 id="e28c">Injecting The&nbsp;Service</h3>



<p>දැන් කරන්න තියෙන්නේ අපි හදපු issue Service එක inject කරගන්න එක. ඒකට අපි හදපු හැම component එකේම (list.component.ts, edit.component.ts and create.component.ts)  මේ විදියට දාගෙන යන්න.</p>



<pre class="wp-block-preformatted">import { IssueService } from '../../services/issue.service';</pre>



<p>ඒ වගේම මේ විදියට dependency injection එකක් කරන්නත් ඕන</p>



<pre class="wp-block-preformatted"> constructor(private issueService: IssueService, private router: Router) { }</pre>



<p>හැම component එකේම මේ විදියට හදා ගත්තාම අපේ components Design කරගන්න එකේ මූලික පියවර ඉවරයි.</p>



<p>අපි මේ ලිපියෙදි ඉගෙන ගත්තේ angular service එකක් හරහා backend එකත් එක්ක fontend එක connect කරන්නේ කොහොමද කියලා. ඊළඟ ලිපියෙන් අපි කතා කරමු front-end එක complete කරගන්නේ කොහොමද කියලා. මේ දක්වා මොනවා හරි අවුලක් තිබුණොත් comment එකක් දාන්න.</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/">MEAN Stack වලින් Sample Application එකක් Design කරගමු. (PART 03)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2019/02/20/mean-stack-sample-application-design-part-03/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
		<item>
		<title>MEAN Part 2 (Mongo DB)</title>
		<link>https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/#comments</comments>
				<pubDate>Mon, 24 Sep 2018 17:42:48 +0000</pubDate>
		<dc:creator><![CDATA[Sandun Prasanganath]]></dc:creator>
				<category><![CDATA[mean stack]]></category>
		<category><![CDATA[angular.js]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[mongo DB]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=1369</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">4</span> <span class="rt-label rt-postfix">minutes</span></span> හැමෝටම ආයුබෝවන්!!පසුගිය ලිපියෙන් මම mongo DB  install කරගෙන ඒකෙ mongo server එක​ on කරගන්න විදිය කියල දුන්නා.ඉතින් මේ ලිපියේදී මම ඒ on කරගත්ත server එකේ වැඩ කරන්නේ කොහොමද කියල කියල දෙන්නම්.කව්‍ රුහරි අද අපිත් එක්ක මුලින්ම​ එකතු වෙනවනම් මෙතනින් ගිහින් ඒ ලිපිය බලන්න පුලුවන්. Database Commands ඉතින් මෙහෙම mongo DB server<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/">MEAN Part 2 (Mongo DB)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">4</span> <span class="rt-label rt-postfix">minutes</span></span>හැමෝටම ආයුබෝවන්!!පසුගිය ලිපියෙන් මම mongo DB  install කරගෙන ඒකෙ mongo server එක​ on කරගන්න විදිය කියල දුන්නා.ඉතින් මේ ලිපියේදී මම ඒ on කරගත්ත server එකේ වැඩ කරන්නේ කොහොමද කියල කියල දෙන්නම්.කව්‍ රුහරි අද අපිත් එක්ක මුලින්ම​ එකතු වෙනවනම් <a href="https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/">මෙතනින්</a> ගිහින් ඒ ලිපිය බලන්න පුලුවන්.</p>
<h3><strong>Database Commands</strong></h3>
<p>ඉතින් මෙහෙම mongo DB server එක on කරගත්තට පස්සේ අලුත් console එකක් open කරගෙන <strong>mongo</strong> කියල type කරන්න එතකොට ඔයාට ඔයගේ තියෙන mongo DB version එක මොකක්ද කියල  බලාගන්න පුලුවන්,ඒ console එකේ තමයි අපි command කරන්නේ.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p1.png" alt="" width="699" height="183" class=" wp-image-1373 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p1.png 977w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p1-300x79.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p1-768x201.png 768w" sizes="(max-width: 699px) 100vw, 699px" /></p>
<p>දැනට තියෙන database මොනවද කියලා බලාගන්නා ඕනිනම් <strong>show dbs</strong> කියලා type කරන්න​.එතකොට දැනට තියෙන database ටික මෙන්න මේ විදියට පෙන්නනවා.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p2.png" alt="" width="704" height="164" class="wp-image-1375 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p2.png 959w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p2-300x70.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p2-768x179.png 768w" sizes="(max-width: 704px) 100vw, 704px" /></p>
<p>config කියල තියෙන්නෙ මම හදපු database එකක්.අපි බලමු mongo DB වල අලුතින් database එකක් හදාගන්නේ කොහොමද කියලා.mysql වල නම් create database ගැහුවම database එක හැදෙනවා,හැබැයි ඒ database එක ඇතුලට යන්න අපිට ආයිමත් use databse කියල type කරන්න වෙනවා,mongo වල එහෙම ඕනි වෙන්නේ නැ,use කියල ගහලා database එකේ නම ගැහුවහම database එක create වෙලා auto ම switch වෙනවා.</p>
<p>දැන් මම customer කියලා database එකක් හදන හැටි පෙන්වන්නම්.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p4.png" alt="" width="553" height="284" class="size-full wp-image-1378 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p4.png 553w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p4-300x154.png 300w" sizes="(max-width: 553px) 100vw, 553px" /></p>
<p>මම හිතනවා දැන් ඔයලට පැහැදිලි වෙන්න ඇති කියලා.දැන් මම කියලා දෙන්නම් mongo වල data save වෙන්නේ කොහොමද කියලා,මම කලින් ලිපියේ කිව්වා document එහෙම නැත්තම් json syntax (java script object) විදියට තමයි මේ data save වෙන්නේ කියලා.මම පෙන්වන්නම් කොහොමද ඒක කරන්නේ කියලා.</p>
<p><strong>1.අපිට පුලුවන් key එකයි value එකයි විදියට data insert කරන්න​.</strong></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p9.png" alt="" width="550" height="144" class="size-full wp-image-1381 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p9.png 550w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p9-300x79.png 300w" sizes="(max-width: 550px) 100vw, 550px" /></p>
<p>&nbsp;</p>
<p><strong>2.Array එකක් විදියට insert කරන්න </strong></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p10.png" alt="" width="563" height="142" class="size-full wp-image-1380 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p10.png 563w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p10-300x76.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></p>
<p>&nbsp;</p>
<p><strong>3.object එකක් විදියට insert කරන්න</strong></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p12.png" alt="" width="571" height="140" class="size-full wp-image-1382 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p12.png 571w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p12-300x74.png 300w" sizes="(max-width: 571px) 100vw, 571px" /></p>
<p>&nbsp;</p>
<p><strong>4.Array object එකක් විදියට insert කරන්න</strong></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p13.png" alt="" width="573" height="148" class="size-full wp-image-1383 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p13.png 573w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/p13-300x77.png 300w" sizes="(max-width: 573px) 100vw, 573px" /></p>
<p>ඉතින් මම මේ ඔයාලට පැහැදිලි කලේ mongo  වල​ data insert කරන්න පුලුවන් විදි නැත්තම් ආකාර​ ගැනයි.</p>
<p>දැන් අපි බලමු අපි හදාගත්ත customer database එක ඇතුලේ table එකක්  හදාගෙන ඒකට data <strong>insert</strong> කරන්නේ කොහොමද කියලා,table එක හදගන්න කලින් බලන්න database එක හරියට switch වෙලා තියෙනවද කියලා.එකේ error එකක් නැතිනම් මෙන්න මේ <strong>db.createCollection(&#8216;table name&#8217;)</strong>  command  එක type  කරලා අලුතින් table එකක් ඒ කියන්නේ collection එකක් හදාගන්න.</p>
<p><em>(මේ හැම දේකදිම mongo  server එක on වෙලා mongo shell  එකක් open වෙලා තියෙන්න ඕනි)​</em></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5-1.png" alt="" width="420" height="315" class=" wp-image-1389 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5-1.png 572w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5-1-300x225.png 300w" sizes="(max-width: 420px) 100vw, 420px" /></p>
<p>ඉතින් මේ collection එක හරියට generate වුනාද කියලා <strong>show collections</strong> command එක type කරලා ඔයාලට බලන්න පුලුවන්.<img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a6.png" alt="" width="446" height="316" class="wp-image-1390 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a6.png 597w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a6-300x213.png 300w" sizes="(max-width: 446px) 100vw, 446px" /></p>
<p>දැන් ඔයාලට පේනවා ඇති table එක හැදිලා තියෙනවා.දැන් table එකට data insert කරමු.</p>
<p>මුලින්ම <strong>db.user.insert({first:&#8221;kamal&#8221;,last:&#8221;silva&#8221;})</strong> type කරන්න​.ඊට පස්සේ ඔයාට හරියට insert වුනාද කියලා බලාගන්න ඕනිනම් <strong>db.user.find()</strong> command එක type කරන්න​.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/ar.png" alt="" width="541" height="237" class="wp-image-1391 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/ar.png 774w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/ar-300x131.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/ar-768x336.png 768w" sizes="(max-width: 541px) 100vw, 541px" /></p>
<p>මොකක්ද මේ <em><strong>ObjectId</strong></em> එක කියන්නේ,my sql වල නම්  table එකක් හදනකොට අපි id කියලා field එකක් හදලා ඒක Auto Increment දෙනවා අපේ primary key එක විදියට​,mongo වල එහෙම ඕනි වෙන්නෙ නැ,එයාම Auto Id එකක් හදගන්නවා,මම ඒක කරලම පෙන්වන්නම්.ඒකට මම තව data set එකක් enter කරන්නම්.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aq.png" alt="" width="644" height="266" class=" wp-image-1392 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aq.png 870w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aq-300x124.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aq-768x317.png 768w" sizes="(max-width: 644px) 100vw, 644px" /></p>
<p>දැන් ඔයලට පේනවා ඇති ObjectId එක auto  හදාගන්නවා කියල.මේකෙදි මම තව දෙයක් කලා.ඒ තමයි table එකට තව feild එකක් add කරපු එක,මේකට තමයි scaling කියලා කියන්නේ,ඒ කියන්නේ අතරමැදදී අපේ table එකට අලුතින් feilds add කරගන්න පුලුවන් කියන එකයි.ඒකත් මේ mongo DB වල විශේශ දෙයක්.</p>
<p><strong>db.user.find().pretty()</strong> command එක type කරල බලන්නකෝ,එතකොට insert කරපු data ටික වඩා පැහැදිලිව බලාගන්න පුලුවන්.</p>
<p>insert කරන එක දැනට නවත්තලා table එකක් <strong>update</strong> කරන්නෙ කොහොමද කියලා දැන් බලමු.</p>
<p>මේකට මම කලින් insert කරපු data set එකම යොදා ගන්නම්.<strong>db.user.update({match},{update data set}) </strong>මේක තමයි command එක,​</p>
<p>මෙහෙම කිව්වට සමහරවිට ඔයාලට තේරුනේ නැතිව ඇති,මම ඒක පැහැදිලි කරන්නම්.මම පලවෙනිපාර insert කරපු data set එකේ town කියලා feild එකක් තිබ්බේ නැ,මම ඒක අලුතින් update කරලා පෙන්වන්නම්.</p>
<p><strong>db.user.update({first:&#8221;kamal&#8221;},{first:&#8221;kamal&#8221;,last:&#8221;silva&#8221;,town:&#8221;gampaha&#8221;})  </strong>command එක​ type කරලා enter<strong> කරන්න​.ඊට පස්සෙ db.user.find().pretty()</strong> type කරන්න​.දැන් ඔයාලට පේනවා පලවෙනියට insert කරපු  data set එක update වෙලා කියලා.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aqw.png" alt="" width="622" height="355" class="wp-image-1396 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aqw.png 843w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aqw-300x171.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/aqw-768x438.png 768w" sizes="(max-width: 622px) 100vw, 622px" /></p>
<p>දැන් අපි බලමු<strong> delete</strong> function එක වැඩ​ කරන්නේ කොහොමද කියලා.<strong>db.user.remove({first:&#8221;kamal&#8221;}) </strong>මෙන්න මේ command එකෙන් first name එක &#8220;kamal&#8221; වෙන සියලුම data remove වෙලා යනවා.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-1.png" alt="" width="672" height="232" class=" wp-image-1397 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-1.png 825w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-1-300x104.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-1-768x265.png 768w" sizes="(max-width: 672px) 100vw, 672px" /></p>
<p>&nbsp;</p>
<p><em>ඉතින් අද අපි කතා කලේ මේ insert,delete,update function වලට අදාලවන මූලිකම කරුණු ටිකක්, මගේ ඊලග ලිපියෙන් මේ function කෙටියෙන් කරන්නේ කොහොමද​, ඒ වගේම එක සමාන data set එකක් තිබුනහම මේ function වැඩ කරන්නේ කොහොමද කියලා පැහැදිලි කරන්නම්.</em></p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/">MEAN Part 2 (Mongo DB)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2018/09/24/mean-part-2-mongo-db/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
							</item>
		<item>
		<title>MEAN Part 1 (Mongo DB)</title>
		<link>https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/</link>
				<comments>https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/#comments</comments>
				<pubDate>Sat, 22 Sep 2018 11:33:09 +0000</pubDate>
		<dc:creator><![CDATA[Sandun Prasanganath]]></dc:creator>
				<category><![CDATA[mean stack]]></category>
		<category><![CDATA[angular.js]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[mongo DB]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">https://danushka96.github.io/sigma/?p=1334</guid>
				<description><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span> web development වලට අදාලව එන platform 4 ක් එකට​ එකතු උන තැනක් තමයි මේ MEAN කියලා කියන්නේ.ඉතින් මෙම ලිපියේ සිට ඉදිරියට MEAN web development කියන්නේ මොකක්ද​,එකෙන් කරන්න පුලුවන් මොනාද කියල මම පැහැදිලි කරන්නම්. &#160; &#160; web development application එකක​ front end එක ඒ කියන්නේ client side කොටස​ වගේම backend එක  ඒ කියන්නේ server side කොටස<a class="moretag" href="https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/"> Read more&#8230;</a></p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/">MEAN Part 1 (Mongo DB)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></description>
								<content:encoded><![CDATA[<p><span class="rt-reading-time" style="display: block;"><span class="rt-label">Reading Time: </span> <span class="rt-time">3</span> <span class="rt-label rt-postfix">minutes</span></span>web development වලට අදාලව එන platform 4 ක් එකට​ එකතු උන තැනක් තමයි මේ <strong>MEAN</strong> කියලා කියන්නේ.ඉතින් මෙම ලිපියේ සිට ඉදිරියට MEAN web development කියන්නේ මොකක්ද​,එකෙන් කරන්න පුලුවන් මොනාද කියල මම පැහැදිලි කරන්නම්.</p>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/Benefits-Of-Using-Mean-Stack-For-Application-Development-300x190.jpg" alt="" width="375" height="238" class=" wp-image-1336 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/Benefits-Of-Using-Mean-Stack-For-Application-Development-300x190.jpg 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/Benefits-Of-Using-Mean-Stack-For-Application-Development-768x487.jpg 768w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/Benefits-Of-Using-Mean-Stack-For-Application-Development.jpg 846w" sizes="(max-width: 375px) 100vw, 375px" /></p>
<p>&nbsp;</p>
<p>web development application එකක​ front end එක ඒ කියන්නේ client side කොටස​ වගේම backend එක  ඒ කියන්නේ server side කොටස නිර්මණය කිරීමට විවිධ platform තියෙනවා. ඉතින් Mean වල,</p>
<p>&nbsp;</p>
<p><strong>data base system-&gt;<em>M</em>ongo DB</strong></p>
<p><strong>back end web framework-&gt;<em>E</em>xpress</strong></p>
<p><strong>front end framework-&gt;<em>A</em>njular.js</strong></p>
<p><strong>back end run time environment-&gt;<em>N</em>ode.js</strong></p>
<p>ඉතින් මොනාද මේ platform ඒවයින් කොහොමද වැඩ කරන්නේ කියල මම මෙතැන් සිට ඉදිරියට පැහැදිලි කරන්නම්.</p>
<p>මුලින්ම මම MEAN STACK වලට අදාලව database system එක  වන <strong>Mongo DB</strong> ගැන පැහැදිලි කරන්නම්.</p>
<h3><strong>Mongo DB</strong></h3>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-300x150.png" alt="" width="322" height="161" class=" wp-image-1340 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we-300x150.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/we.png 318w" sizes="(max-width: 322px) 100vw, 322px" /></p>
<p>මෙහිදී මම කොහොමද Mongo DB අපේ computer එකට​ install කරගන්නේ,කොහොමද Mongo DB වලින් insert,delete,update වගේ Fundamental කරන්නේ වගේම mongoose ගැනත් පොඩ්ඩක් කතාකරන්න බලපොරොත්තු වෙනවා.</p>
<p>Mongo DB කියල කියන්නේ No Sql ගනයට වැටෙන database එකක්.ඉතින් එතනම අදහස පැහැදිලි වෙනවනෙ.අපි සාමාන්‍යයන් පාවිච්චි කරන්නේ Relational Database,  මේවට​ හොදම උදහරණයක් නෙ My Sql කියල කියන්නේ.ඉතින් මේ Relational Database වලට වඩා advance data base එකක් තමයි no sql database කියල කියන්නේ.</p>
<p>Mongo DB වල තියෙන විශේෂත්වය තමයි document නැත්තම් json syntax විදියට තමයි data store කරගන්නේ.</p>
<p><em>(මේ json syntax කියන්නේ මොකක්ද කියල මම ඉදිරියට පැහැදිලි කරන්නම්)</em></p>
<p>Relational Data Base එකක අපිට මුලු database එකම map කරන්න වෙනවා.ඒ කියන්නේ අපි database එකක් හදනකොට අපිට එකේ fields,data types,tables ඔක්කොම හදන්න වෙනවා.කොටින්ම කිව්වොත් structure එකක් තියගන්න වෙනවා.හැබැයි mongo DB වල එහෙම ඕනි වෙන්නේ නැ.අපිට කෙලින්ම scale එකක් තියගන්න පුලුවන්.එක මේ no sql වල තියෙන ප්‍රධාන වාසියක්.</p>
<p>ඉතින් අපි data විශාල ප්‍රමාණයක් handle කරනවනම් වඩා හොද database system එක තමයි Mongo DB ,මේ data base වල තියෙන තව වාසියක් තමයි speed එක  Relational Database වලට වඩා වැඩි වීම​.</p>
<p>ඉතින් මම හිතනවා mongo DB ගැන පොඩි අදහසක් ගන්න ඇති කියල මේ පැහැදිලි කිරීමත් එක්ක​,</p>
<p>අපි ඊලගට බලමු කොහොමද මේ Mongo DB, computer එකට install කරගන්නේ කොහොමද​ කියලා.</p>
<p>mongo DB site<a href="http://www.mongodb.com/"><strong>(www.mongodb.com)</strong></a> එකට ගිහින් download කරන ආකාරය මම පියවර අකාරයෙන් දක්වන්නම්.</p>
<p>&nbsp;</p>
<h5><strong>පියවර 1:</strong></h5>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/12-1.png" alt="" width="796" height="555" class="alignnone size-full wp-image-1347" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/12-1.png 796w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/12-1-300x209.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/12-1-768x535.png 768w" sizes="(max-width: 796px) 100vw, 796px" /></p>
<p>&nbsp;</p>
<h5><strong>පියවර 2:</strong></h5>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/15.png" alt="" width="793" height="531" class="alignnone size-full wp-image-1349" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/15.png 793w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/15-300x201.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/15-768x514.png 768w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/15-360x240.png 360w" sizes="(max-width: 793px) 100vw, 793px" /></p>
<h5><strong>පියවර​ 3:</strong></h5>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/14.png" alt="" width="789" height="460" class="alignnone size-full wp-image-1350" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/14.png 789w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/14-300x175.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/14-768x448.png 768w" sizes="(max-width: 789px) 100vw, 789px" /></p>
<p>ඉතින් මම​ හිතනවා මම පැහැදිලි කරනවට වඩා මේ පියවර ටික බලලා ඔයලා තේරුම් ගන්න ඇති කියල කොහොමද mongo DB install කරන්නේ කියලා.</p>
<p>3 වෙනි පියවරේ platform එකට අදාලව​ msi file එක download කලාට පස්සේ ඒක open කරලා install කරන්න.mongo DB run කරන්න computer එකේ නිකන්ම install විතරක් කරල මදි,ඒකට variable path එක හදගන්න ඕනි.මම පැහැදිලි කරන්නම් කොහොමද ඒක කරන්නේ කියලා.</p>
<p>mongo DB install කරලා තියෙන තැන (සාමාන්‍යයෙන් c drive එකේ) open කරන්න​.ඊලගට ඒකේ තියෙන බින් file එකේ path එක copy කරගෙන​ Advanced System Setting යටතේ Environment variable වල User Variable එකේ​ path එක set කරගන්න​.</p>
<p><em>(මෙහෙම මම කිව්වට ඔයලට සමහරවිට තේරුණේ නැතිව ඇති,මම පෙන්වන්නම් කොහොමද path එක set කරගන්නේ කියලා)</em></p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a1.png" alt="" width="409" height="265" class="wp-image-1353 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a1.png 622w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a1-300x194.png 300w" sizes="(max-width: 409px) 100vw, 409px" /></p>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a2.png" alt="" width="472" height="211" class="wp-image-1354 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a2.png 611w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a2-300x134.png 300w" sizes="(max-width: 472px) 100vw, 472px" /></p>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a3.png" alt="" width="566" height="335" class="wp-image-1355 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a3.png 665w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a3-300x177.png 300w" sizes="(max-width: 566px) 100vw, 566px" /></p>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a4.png" alt="" width="325" height="364" class=" wp-image-1356 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a4.png 421w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a4-268x300.png 268w" sizes="(max-width: 325px) 100vw, 325px" /></p>
<p>&nbsp;</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5.png" alt="" width="516" height="336" class=" wp-image-1357 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5.png 591w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/a5-300x195.png 300w" sizes="(max-width: 516px) 100vw, 516px" /></p>
<p>&nbsp;</p>
<p>ඉතින් මෙහෙම install කරල ඉවර වෙලා ඔයාගෙ cmd එක open කරල <strong>mongod</strong> කියල type කරන්න​.හරියට install උනානම් මෙන්න මෙහෙම details ටිකක් එන්න ඕනි.</p>
<p><img src="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/23.png" alt="" width="740" height="261" class="wp-image-1358 aligncenter" srcset="https://danushka96.github.io/sigma/wp-content/uploads/2018/09/23.png 956w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/23-300x106.png 300w, https://danushka96.github.io/sigma/wp-content/uploads/2018/09/23-768x271.png 768w" sizes="(max-width: 740px) 100vw, 740px" /></p>
<p>&nbsp;</p>
<p>mongod කියල command එක run කරලා අපි කරන්නෙ <strong><em>mongo DB server</em></strong> එක <em><strong>on</strong></em> කරන එකයි.</p>
<p>mongo DB  වල insert,delete,update කරන්නේ කොහොමද කියල කියන්න ඕනි වුනත් ලිපියේ මුලම mean stack ගැන විස්තර ටිකක් කතාකරපු හින්දා ලිපිය අවශය ප්‍රමනයට වඩා දිග වුනා.ඒක හින්දා ඒ කොටස මම ඊලග ලිපියෙන් කතාකරන්න බලාපොරොත්තු වෙනවා.</p>
<p>The post <a rel="nofollow" href="https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/">MEAN Part 1 (Mongo DB)</a> appeared first on <a rel="nofollow" href="https://danushka96.github.io/sigma/">The SIGMA</a>.</p>
]]></content:encoded>
							<wfw:commentRss>https://danushka96.github.io/sigma/index.php/2018/09/22/mean-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
							</item>
	</channel>
</rss>
