Skip to content
Browse files

fixed documentation

  • Loading branch information...
1 parent ffd685b commit 4de31a6f2600e8e452eb51ea733c855fa7018e3e @chrisdew committed
Showing with 84 additions and 7 deletions.
  1. +2 −1 Makefile
  2. +9 −3 README.md
  3. +25 −1 docs/barricane-db.html
  4. +6 −1 docs/disk-io.html
  5. +36 −0 lib/barricane-db.js
  6. +6 −1 lib/disk-io.js
View
3 Makefile
@@ -5,6 +5,7 @@ clean:
docs:
docco lib/*.js examples/*.js
- google-chrome ./docs
+ scp -rp docs/* root@yellow:/var/www/drupal/barricane-db/
+ google-chrome http://www.barricane.com/barricane-db/
View
12 README.md
@@ -1,17 +1,23 @@
BarricaneDB
===========
-Alpha development. Does NOT yet work yet.
+Alpha development. Just about works - may contain bugs.
BarricaneDB is a loose implementation of the [Prevalence](http://www.ibm.com/developerworks/library/wa-objprev/) System Design Pattern, as implemented in Java by [Prevaylor](http://www.prevayler.org/), but for [NodeJS](http://nodejs.org/).
BarricaneDB is really just an ultra-simple persistance layer for a single process. It can persist your application's model without any explicit 'save' commands. Every Javascript <code>x.y = "foo";</code> (on registered instances) causes asynchronous persistance to disk.
-See the [examples](https://github.com/chrisdew/barricane-db/tree/master/examples) for how easy it is to get started.
+Examples
+--------
+* [example-create-database](http://www.barricane.com/barricane-db/example-create-database.html)
+* [example-create-database](http://www.barricane.com/barricane-db/example-model.html)
+* [example-create-database](http://www.barricane.com/barricane-db/example-read-database.html)
+
+There's also full, docco-generated, documentation online at [http://www.barricane.com/barricane-db/](http://www.barricane.com/barricane-db/).
Installation
------------
-* Package not available yet - will be <code>npm install barricane-db</code>
+* <code>npm install barricane-db</code>
Reasons why BarricaneDB will never be a good fit for your application.
----------------------------------------------------------------------
View
26 docs/barricane-db.html
@@ -1,5 +1,29 @@
<!DOCTYPE html> <html> <head> <title>barricane-db.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="example-create-database.html"> example-create-database.js </a> <a class="source" href="example-model.html"> example-model.js </a> <a class="source" href="example-read-database.html"> example-read-database.js </a> <a class="source" href="barricane-db.html"> barricane-db.js </a> <a class="source" href="db.html"> db.js </a> <a class="source" href="disk-io.html"> disk-io.js </a> <a class="source" href="swoj-codec.html"> swoj-codec.js </a> <a class="source" href="util.html"> util.js </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> barricane-db.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>Copyright (c) 2010 Barricane Technology Ltd., All Rights Reserved.
-Released under the MIT open source licence.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This file is the entry point for the NPM barricane-db package.
+Released under the MIT open source licence.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>BarricaneDB</h1> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Alpha development. Just about works - may contain bugs.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>BarricaneDB is a loose implementation of the <a href="http://www.ibm.com/developerworks/library/wa-objprev/">Prevalence</a> System Design Pattern, as implemented in Java by <a href="http://www.prevayler.org/">Prevaylor</a>, but for <a href="http://nodejs.org/">NodeJS</a>.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>BarricaneDB is really just an ultra-simple persistance layer for a single process. It can persist your application's model without any explicit 'save' commands. Every Javascript <code>x.y = "foo";</code> (on registered instances) causes asynchronous persistance to disk.</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> <h2>Examples</h2>
+
+<ul>
+<li><a href="http://www.barricane.com/barricane-db/example-create-database.html">example-create-database</a> </li>
+<li><a href="http://www.barricane.com/barricane-db/example-model.html">example-model</a> </li>
+<li><a href="http://www.barricane.com/barricane-db/example-read-database.html">example-read-database</a> </li>
+</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>There's also full, docco-generated, documentation online at <a href="http://www.barricane.com/barricane-db/">http://www.barricane.com/barricane-db/</a>.</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> <h2>Installation</h2>
+
+<ul>
+<li><code>npm install barricane-db</code></li>
+</ul> </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> <h2>Reasons why BarricaneDB will never be a good fit for your application.</h2>
+
+<ul>
+<li>Your data set is too big to fit in RAM.</li>
+<li>Your application needs ACID guarantees. BarricaneDB could loose 1-5 seconds of data on a process crash (OS dependent).</li>
+<li>Your application doesn't happily shard into BarricaneDB's one-DB-per-process design.</li>
+<li>You need to query your database from outside the NodeJS process - e.g. Crystal Reports.</li>
+</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h2>Reasons why BarricaneDB is not <em>currently</em> a good fit.</h2>
+
+<ul>
+<li>Your application needs a production-tested solution.</li>
+<li>You need good error handling.</li>
+<li>You need async database opening (persistence is already fully async).</li>
+<li>Transactions are important to you.</li>
+</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <p>This file is the entry point for the NPM barricane-db package.
It only exports symbols required from other modules.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">bdb</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./db&#39;</span><span class="p">);</span>
<span class="nx">exports</span><span class="p">.</span><span class="nx">DB</span> <span class="o">=</span> <span class="nx">bdb</span><span class="p">.</span><span class="nx">DB</span><span class="p">;</span>
View
7 docs/disk-io.html
@@ -63,7 +63,12 @@
</pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">&#182;</a> </div> <p>Forcing this registration is required, as db.persist is currently
false.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">registerInstance</span><span class="p">(</span><span class="nx">object</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="p">}</span>
- <span class="k">this</span><span class="p">.</span><span class="nx">codec</span><span class="p">.</span><span class="nx">fixRefs</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>TODO: write all these instances to disk.</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">}</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>This will delete any pre-existing database files - for now it just moves them
+ <span class="k">this</span><span class="p">.</span><span class="nx">codec</span><span class="p">.</span><span class="nx">fixRefs</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">);</span>
+ </pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">&#182;</a> </div> <p>Write all these instances to disk.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">instance</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">instances</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">persist</span><span class="p">(</span><span class="nx">instance</span><span class="p">);</span>
+ <span class="p">}</span>
+<span class="p">}</span></pre></div> </td> </tr> <tr id="section-18"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-18">&#182;</a> </div> <p>This will delete any pre-existing database files - for now it just moves them
aside.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">DiskIO</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">deleteSync</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-19"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-19">&#182;</a> </div> <p>First get the contents of the path.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="kd">var</span> <span class="nx">contents</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">readdirSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">path</span><span class="p">);</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">contents</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">contents</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="k">this</span><span class="p">.</span><span class="nx">FILENAME</span><span class="p">)</span> <span class="p">{</span>
View
36 lib/barricane-db.js
@@ -1,6 +1,42 @@
// Copyright (c) 2010 Barricane Technology Ltd., All Rights Reserved.
// Released under the MIT open source licence.
+// BarricaneDB
+// ===========
+
+// Alpha development. Just about works - may contain bugs.
+
+// BarricaneDB is a loose implementation of the [Prevalence](http://www.ibm.com/developerworks/library/wa-objprev/) System Design Pattern, as implemented in Java by [Prevaylor](http://www.prevayler.org/), but for [NodeJS](http://nodejs.org/).
+
+// BarricaneDB is really just an ultra-simple persistance layer for a single process. It can persist your application's model without any explicit 'save' commands. Every Javascript <code>x.y = "foo";</code> (on registered instances) causes asynchronous persistance to disk.
+
+// Examples
+// --------
+// * [example-create-database](http://www.barricane.com/barricane-db/example-create-database.html)
+// * [example-model](http://www.barricane.com/barricane-db/example-model.html)
+// * [example-read-database](http://www.barricane.com/barricane-db/example-read-database.html)
+
+// There's also full, docco-generated, documentation online at [http://www.barricane.com/barricane-db/](http://www.barricane.com/barricane-db/).
+
+// Installation
+// ------------
+// * <code>npm install barricane-db</code>
+
+// Reasons why BarricaneDB will never be a good fit for your application.
+// ----------------------------------------------------------------------
+// * Your data set is too big to fit in RAM.
+// * Your application needs ACID guarantees. BarricaneDB could loose 1-5 seconds of data on a process crash (OS dependent).
+// * Your application doesn't happily shard into BarricaneDB's one-DB-per-process design.
+// * You need to query your database from outside the NodeJS process - e.g. Crystal Reports.
+
+// Reasons why BarricaneDB is not _currently_ a good fit.
+// ------------------------------------------------------
+// * Your application needs a production-tested solution.
+// * You need good error handling.
+// * You need async database opening (persistence is already fully async).
+// * Transactions are important to you.
+
+
// This file is the entry point for the NPM barricane-db package.
// It only exports symbols required from other modules.
View
7 lib/disk-io.js
@@ -100,7 +100,12 @@ DiskIO.prototype._load = function(filepath) {
this.db.registerInstance(object, true);
}
this.codec.fixRefs(this.db.instances);
- // TODO: write all these instances to disk.
+
+ // Write all these instances to disk.
+ for (var i in this.db.instances) {
+ var instance = this.db.instances[i];
+ this.persist(instance);
+ }
}

0 comments on commit 4de31a6

Please sign in to comment.
Something went wrong with that request. Please try again.