<?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>Leon</title>
	<atom:link href="http://www.leonrenkema.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leonrenkema.nl</link>
	<description>Programming, Software, Internet</description>
	<lastBuildDate>Thu, 15 Dec 2011 20:53:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Science or fiction?</title>
		<link>http://www.leonrenkema.nl/2011/11/28/science-or-fiction/</link>
		<comments>http://www.leonrenkema.nl/2011/11/28/science-or-fiction/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 22:15:03 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Philosophical]]></category>
		<category><![CDATA[fiction]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[truth]]></category>

		<guid isPermaLink="false">http://www.leonrenkema.nl/?p=656</guid>
		<description><![CDATA[There is a thin line between what we call science and what we call fiction. If some imaginary story or event becomes true it becomes fact and even becomes common accepted in the science. For example, if you told someone &#8230; <a href="http://www.leonrenkema.nl/2011/11/28/science-or-fiction/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.leonrenkema.nl/wp-content/uploads/2011/11/science_fiction_9.jpg"><img class="alignright size-medium wp-image-671" title="science_fiction_9" src="http://www.leonrenkema.nl/wp-content/uploads/2011/11/science_fiction_9-300x225.jpg" alt="" width="270" height="203" /></a>There is a thin line between what we call science and what we call fiction. If some imaginary story or event becomes true it becomes fact and even becomes common accepted in the science. For example, if you told someone who lived hundred years ago that we can construct microchips with a million transistors on it they would not believe you. Let alone the fact that the earth is not flat (actually the earth has become flat again but in a slightly different way <sup>[<a href="#science-or-fiction-n-1" class="footnoted" id="to-science-or-fiction-n-1">1</a>]</sup>).</p>
<p>So what we now call fiction can become faction and even science within a few year or few decades. Nature still has a lot of secrets that she will not share with us for a long time but once she will reveal it and we will learn something new about our existence. I can&#8217;t wait for the replicators and warp-drive <img src='http://www.leonrenkema.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Bottom line is that we never can know anything for certain because we can&#8217;t oversee the present, future events and discoveries that has to be made. Scientists should always be open minded about the &#8220;truth&#8221;. Truth is very complex and in my opinion impossible to grasp. We never can be certain of anything. Einstein has a great quote that covers it in a very nice way:</p>
<blockquote><p>&#8220;Whoever undertakes to set himself up as a judge of Truth and Knowledge is shipwrecked by the laughter of the gods.&#8221; &#8211; Albert Einstein</p></blockquote>
<p>&nbsp;</p>

<ol class="footnotes">
	<li class="footnote" id="science-or-fiction-n-1"><strong><sup>[1]</sup></strong> <a href="http://www.youtube.com/watch?v=53vLQnuV9FY">http://www.youtube.com/watch?v=53vLQnuV9FY</a> <a class="note-return" href="#to-science-or-fiction-n-1">&#x21A9;</a></li></ol>
]]></content:encoded>
			<wfw:commentRss>http://www.leonrenkema.nl/2011/11/28/science-or-fiction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Singleton pattern in PHP 5.3</title>
		<link>http://www.leonrenkema.nl/2011/11/25/singleton-pattern-in-php-5-3/</link>
		<comments>http://www.leonrenkema.nl/2011/11/25/singleton-pattern-in-php-5-3/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 21:24:55 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[php 5.3]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://www.leonrenkema.nl/?p=650</guid>
		<description><![CDATA[With the introduction of PHP 5.3 some nice object oriented features are available. One of them is the function get_called_class. Below a short example when this function comes in handy. When we have an abstract CacheDriver as shown below and &#8230; <a href="http://www.leonrenkema.nl/2011/11/25/singleton-pattern-in-php-5-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With the introduction of PHP 5.3 some nice object oriented features are available. One of them is the function <code>get_called_class</code>. Below a short example when this function comes in handy.</p>
<p>When we have an abstract CacheDriver as shown below and we extend this with a MemcachedDriver. We only want one instance of this driver available so we apply the singleton pattern. But before PHP 5.3 it was very difficult to put the getInstance method in the base class. There is a solution to use the factory pattern (eg. <code>CacheDriver::getInstance('Memcached')</code>) but the following solution is more elegant and possible from PHP 5.3</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> CacheDriver <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> static <span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$classname</span> <span style="color: #339933;">=</span> get_called_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$instance</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000088;">$classname</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MemcachedDriver <span style="color: #000000; font-weight: bold;">extends</span> CacheDriver <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$cacheDriver</span> <span style="color: #339933;">=</span> MemcachedDriver<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p lang="php">Because <code>get_called_class()</code> yields the name of the class we are using (MemcachedDriver) we get directly an instance of the MemcachedDriver without duplicating the getInstance method or using the factory pattern.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.leonrenkema.nl/2011/11/25/singleton-pattern-in-php-5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How big is Google?</title>
		<link>http://www.leonrenkema.nl/2011/11/15/how-big-is-google/</link>
		<comments>http://www.leonrenkema.nl/2011/11/15/how-big-is-google/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 19:54:28 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Nerd Stuff]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.leonrenkema.nl/?p=625</guid>
		<description><![CDATA[What started in the late 90&#8242;s (1998 to be exact) is now a very large company that reaches probably the most amount of people worldwide. It started with their search algorithm and an interface to use the information they had &#8230; <a href="http://www.leonrenkema.nl/2011/11/15/how-big-is-google/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>What started in the late 90&#8242;s (1998 to be exact) is now a very large company that reaches probably the most amount of people worldwide. It started with their search algorithm and an interface to use the information they had stored and indexed. But now they have their own operating system (Android), a browser (Chrome) and a whole bunch of other products.</p>
<p>In this article I will give a short oversight of what they are doing and how all these products interconnect with each other. Also why some products are not creating money but are very important to sell their main product. While Google is really big and you can discuss if they aren&#8217;t too big they always claim to &#8220;Not do any evil&#8221;.<span id="more-625"></span></p>
<h2>Search engine</h2>
<p>The core of the company is their search engine that most of the people will know. Or better formulated; most people think Google is only a search engine. Google is a lot more than only a search engine but the search is the core part in my opinion.</p>
<h2>Adwords</h2>
<p>Maybe the most known kind of online advertising is Google adwords and it is found on a lot of Google products like Youtube and Gmail and also on a lot of other sites. An advertiser can create ads that are displayed on the user profile that is visiting the site. It is plausible that this is the cash cow of Google because they have a very accurate profile of users and can very effectively show ads.</p>
<h2>Analytics</h2>
<p>Google allows webmasters to install Google Analytics to track the visits to his site. This way Google collects very much information on the visitors and also the webmaster has some nice tools to monitor the visitors. The market share of Analytics is around 50% <sup>[<a href="#how-big-is-google-n-1" class="footnoted" id="to-how-big-is-google-n-1">1</a>]</sup> <sup>[<a href="#how-big-is-google-n-2" class="footnoted" id="to-how-big-is-google-n-2">2</a>]</sup></p>
<h2>Gmail, Google Docs</h2>
<p>The total number of gmail users is about 150 million in <a href="http://news.bbc.co.uk/2/hi/technology/8232971.stm" target="_blank">2009</a> and I suspect it has grown the last years with the introduction of Android and Chrome OS. Also universities has started using the office suit of Google because it is very cheap in comparison to Microsoft Exchange.</p>
<h2>Youtube</h2>
<p>What began in 2005 from a garage has been acquired by Google one year later and is now the greatest video site on the internet. The site generates roughly 2 billion views per day<sup>[<a href="#how-big-is-google-n-3" class="footnoted" id="to-how-big-is-google-n-3">3</a>]</sup> and 1 day of video is uploaded every minute.</p>
<h2>Android</h2>
<p>What started really small a few years ago as a mobile operating system has now grown to one of the largest smart phone operating systems. Almost 50% of the smart phones is running Android according to <a href="http://www.canalys.com/newsroom/android-takes-almost-50-share-worldwide-smart-phone-market" target="_blank">Canalys</a></p>
<h2>Chrome</h2>
<p>The browser market has been dominated for year by Internet Explorer after losing the browser war in the nineties. FireFox started the next battle and won some ground in the years following. Google decided to build there own smooth and (very) fast browser. They launched their Chrome browser in december 2008 and in 2011 has a worldwide marketshare of 25%. According to <a href="http://gs.statcounter.com/" target="_blank">statcounter</a> Internet Explorer is slowly losing the new browser battle and Google Chrome is growing.</p>
<h2>Chrome OS</h2>
<p>Google is exploring a new Operating System paradigm that uses only a browser (Chrome) and a internet connection. All apps are running in the cloud and no local data is stored. As Chrome OS is still under development it is not used very much but it is an interesting paradigm shift back to the client-server architecture.</p>
<h2>Google TV</h2>
<p>Not very popular but look promising is Google TV. It works on Android and uses Chrome to render apps and web-content to a TV. This way it is possible to get all the content and functionality of Google and the Web to the living room.</p>
<h2>And much, much more</h2>
<p>As this is supposed to stay a blog post and not become a book I only picked the greatest products of Google and I forgot to mention a lot more. For a impression a short list of products I did not mention:</p>
<ul>
<li>Blogger</li>
<li>Picasaweb</li>
<li>Groups</li>
<li>News</li>
<li>Earth</li>
<li>AppEngine</li>
<li>Maps</li>
<li>etc&#8230;</li>
</ul>
<h2>Why?</h2>
<p>With Google Adwords they have a really interesting cash cow and they could not do all the other things without a steady stream of cash flowing towards them. In my opinion Google is build by very technical and enthusiastic people who love what the are doing. They build en invent really great products. But there is a underlying motive and that is they need to earn money to pay it all. One way of earning money is getting people online and clicking ads and providing user information in the form of statistics and other data that Google can use to server more ads.</p>
<p>If we read our mail we get an ad of Adwords, if we watch a video we get an ad of Adwords, if we read a blog we get one, if we watch photos, well you get the point. Google is really big and has a great impact in our lives.</p>
<p>Whether this can be called &#8220;evil&#8221; I do not know, that is a discussion of another magnitude. Facebook should also be considered in that context. But we should be aware of that motivation and act accordingly.</p>
<p><strong><em>Disclaimer</em></strong><br />
<em>The facts are probably not always correct but I don&#8217;t have the intention to be correct to the decimal, it is just an impression to show how massive Google affects our digital live. </em></p>

<ol class="footnotes">
	<li class="footnote" id="how-big-is-google-n-1"><strong><sup>[1]</sup></strong> <a href="http://metricmail.tumblr.com/post/904126172/google-analytics-market-share">http://metricmail.tumblr.com/post/904126172/google-analytics-market-share</a> <a class="note-return" href="#to-how-big-is-google-n-1">&#x21A9;</a></li>
	<li class="footnote" id="how-big-is-google-n-2"><strong><sup>[2]</sup></strong> <a href="http://trends.builtwith.com/analytics/Google-Analytics">http://trends.builtwith.com/analytics/Google-Analytics</a> <a class="note-return" href="#to-how-big-is-google-n-2">&#x21A9;</a></li>
	<li class="footnote" id="how-big-is-google-n-3"><strong><sup>[3]</sup></strong> <a href="http://www.website-monitoring.com/blog/2010/05/17/youtube-facts-and-figures-history-statistics/">http://www.website-monitoring.com/blog/2010/05/17/youtube-facts-and-figures-history-statistics/</a> <a class="note-return" href="#to-how-big-is-google-n-3">&#x21A9;</a></li></ol>
]]></content:encoded>
			<wfw:commentRss>http://www.leonrenkema.nl/2011/11/15/how-big-is-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB introduction</title>
		<link>http://www.leonrenkema.nl/2011/09/14/mongodb-introduction/</link>
		<comments>http://www.leonrenkema.nl/2011/09/14/mongodb-introduction/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 20:59:03 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[mongodb]]></category>

		<guid isPermaLink="false">http://www.leonrenkema.nl/?p=570</guid>
		<description><![CDATA[This short MongoDB introduction assumes that you have a running MongoDB instance on your computer and have all command line tools installed. When the shell command has been started the first thing you want to know is which databases are &#8230; <a href="http://www.leonrenkema.nl/2011/09/14/mongodb-introduction/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This short MongoDB introduction assumes that you have a running MongoDB instance on your computer and have all command line tools installed.</p>
<p>When the shell command has been started the first thing you want to know is which databases are available. To do this you run the command <code>show dbs</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> show dbs
admin
local
crm</pre></div></div>

<p><span id="more-570"></span></p>
<p>The databases admin and local are system databases but the crm database is one I have created. To perform operations on this database we first need to tell we want to <em>use</em> that database.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> <span style="color: #003366; font-weight: bold;">use</span> crm
switched to db crm</pre></div></div>

<p>MongoDB is a lot easier to use than MySQL because when we try to open a non existing database there are no complaints from the server. The catch is only that when there is a typo in your configuration there will be no complaints when using a non existing database or collection.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> <span style="color: #003366; font-weight: bold;">use</span> doodle
switched to db doodle</pre></div></div>

<h2>Creating collections and inserting data</h2>
<h3>Inserting</h3>
<p>There is no need to create a collection, these will be created upon first use. With a simple save call the collection will be implicitly created.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #339933;">,</span> phone<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;316123456789&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>The save function will accept any javascript object, you even can use different types of objects per inserted row. MongoDB will store the complete object (or document if you like) in a new row in the collection.</p>
<blockquote><p>Unlike other SQL-servers there is no need to predefine the columns and datatypes you are going to use. So MongoDB is giving us a very flexibel and scalable data storage.</p></blockquote>
<h3>Finding</h3>
<p>After inserting the record we can do a find with the following operation. This will returns us the same javascript object we added previously but with an extra field <em>&#8220;_id&#8221;</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;_id&quot;</span> <span style="color: #339933;">:</span> ObjectId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;4d83cf306d06a21d02a1b771&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;name&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;phone&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;316123456789&quot;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Also you can use queries to find a record with specific values, more about queries later.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;name&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;_id&quot;</span> <span style="color: #339933;">:</span> ObjectId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;4d83cf306d06a21d02a1b771&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;name&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;phone&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;316123456789&quot;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Counting</h3>
<p>On the collections you can perform various actions like counting. A count is in fact a function of the <code>db.persons</code> object. So you can call that function like so</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #CC0000;">1</span></pre></div></div>

<p>In these <code>count</code> you can use the same type of queries as in the <code>find</code>.</p>
<p>http://mongodb.onconfluence.com/display/DOCS/Queries+and+Cursors</p>
<h3>Updating</h3>
<p>When updating documents in MongoDB there are two strategies you can follow. Depending on the type of documents you can either choose the first or the last.</p>
<h4>Conventional</h4>
<p>The conventional way of updating an object is to fetch the object, change a value and then send the object back to the server. This could become very data intensive when an object is very large or there are very minor changes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> <span style="color: #003366; font-weight: bold;">var</span> row <span style="color: #339933;">=</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">findOne</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&gt;</span> row.<span style="color: #660066;">phone</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;316987654321&quot;</span>
<span style="color: #339933;">&gt;</span> row.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span></pre></div></div>

<h4>Modifier Operations</h4>
<p>MongoDB adds the possibility to update only a few properties of a object at a time. This way you don&#8217;t have to load the whole object so updating the document is very fast.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">update</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Leon&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>$set <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>phone<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4567&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Update queries can be rather complicated so read the docs on the mongodb website for more information <a href="http://www.mongodb.org/display/DOCS/Updating" target="_blank">http://www.mongodb.org/display/DOCS/Updating</a></p>
<h3>Removing</h3>
<p>Removing rows from the collections is as easy as creating them. As a argument you are giving the same sort of query as when finding or counting. The primary key of a row is the &#8220;_id&#8221; field so it is logical to use that column when removing rows.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">persons</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;_id&quot;</span><span style="color: #339933;">:</span> ObjectId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;4d83cf306d06a21d02a1b771&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>This is the short introduction for now, more is to follow but it takes some time. Leave a message if you have questions about this introduction or want to know more.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.leonrenkema.nl/2011/09/14/mongodb-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

