Permalink
Browse files

cleaned up

  • Loading branch information...
1 parent c851f2b commit e44b5a73d79dcacdaa1a471e62a05e0d32b8c4ac @chrisdew committed Feb 9, 2011
View
6 docs/example-create-database.html
@@ -6,15 +6,15 @@
you can manually inject the database into appropriate constructors, or call
<code>DB.registerInstance(instance)</code> every time you create an object. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">process</span><span class="p">.</span><span class="nx">db</span> <span class="o">=</span> <span class="nx">db</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Delete any database of the same path and name. Most applications will never
use this. It's only used here so that we know this has created a brand new
-database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">deleteSync</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>process.exit(0);</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Open the database for business. Most once-per-process methods of DB are
+database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">deleteSync</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>Open the database for business. Most once-per-process methods of DB are
synchronous, as it's not really an issue and makes applications simpler.
-All persistence is done asynchronously.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">openSync</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>Construct a simple model from which objects can be persisted.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">house</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">model</span><span class="p">.</span><span class="nx">House</span><span class="p">(</span><span class="s2">&quot;301 Cobblestone Wy., Bedrock, 70777&quot;</span><span class="p">);</span>
+All persistence is done asynchronously.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">openSync</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Construct a simple model from which objects can be persisted.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">house</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">model</span><span class="p">.</span><span class="nx">House</span><span class="p">(</span><span class="s2">&quot;301 Cobblestone Wy., Bedrock, 70777&quot;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">fred</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">model</span><span class="p">.</span><span class="nx">Person</span><span class="p">(</span><span class="s2">&quot;Fred&quot;</span><span class="p">,</span> <span class="s2">&quot;Flintstone&quot;</span><span class="p">);</span>
<span class="nx">fred</span><span class="p">.</span><span class="nx">house</span> <span class="o">=</span> <span class="nx">house</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">wilma</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">model</span><span class="p">.</span><span class="nx">Person</span><span class="p">(</span><span class="s2">&quot;Wilma&quot;</span><span class="p">,</span> <span class="s2">&quot;Flintstone&quot;</span><span class="p">);</span>
<span class="nx">wilma</span><span class="p">.</span><span class="nx">house</span> <span class="o">=</span> <span class="nx">house</span><span class="p">;</span>
<span class="nx">fred</span><span class="p">.</span><span class="nx">spouse</span> <span class="o">=</span> <span class="nx">wilma</span><span class="p">;</span>
-<span class="nx">wilma</span><span class="p">.</span><span class="nx">spouse</span> <span class="o">=</span> <span class="nx">fred</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>No save() needed - persistence is implicit.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Finally, close the database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
+<span class="nx">wilma</span><span class="p">.</span><span class="nx">spouse</span> <span class="o">=</span> <span class="nx">fred</span><span class="p">;</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>No save() needed - persistence is implicit.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Finally, close the database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;database has persisted successfully&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
View
3 docs/example-read-database.html
@@ -17,7 +17,8 @@
<span class="cm">/* --&gt; &#39;Fred&#39; */</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">fred</span><span class="p">.</span><span class="nx">house</span><span class="p">.</span><span class="nx">address</span><span class="p">);</span>
-<span class="cm">/* --&gt; &#39;301 Cobblestone Wy., Bedrock, 70777&#39; */</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Finally, close the database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
+<span class="cm">/* --&gt; &#39;301 Cobblestone Wy., Bedrock, 70777&#39; */</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Show that the instances use the right constructors.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">fred</span><span class="p">.</span><span class="nx">house</span><span class="p">.</span><span class="nx">logConstructionMaterial</span><span class="p">();</span>
+<span class="cm">/* --&gt; &#39;301 Cobblestone Wy., Bedrock, 70777 is made of stone&#39; */</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <p>Finally, close the database.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">db</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;database has persisted successfully&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
View
1 examples/example-create-database.js
@@ -18,7 +18,6 @@ process.db = db;
// use this. It's only used here so that we know this has created a brand new
// database.
db.deleteSync();
-//process.exit(0);
// Open the database for business. Most once-per-process methods of DB are
// synchronous, as it's not really an issue and makes applications simpler.
View
4 examples/example-read-database.js
@@ -38,6 +38,10 @@ console.log(fred.spouse.spouse.personalName);
console.log(fred.house.address);
/* --> '301 Cobblestone Wy., Bedrock, 70777' */
+// Show that the instances use the right constructors.
+fred.house.logConstructionMaterial();
+/* --> '301 Cobblestone Wy., Bedrock, 70777 is made of stone' */
+
// Finally, close the database.
db.end(function(err, result) {
if (!err) {

0 comments on commit e44b5a7

Please sign in to comment.