<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Introduction &mdash; JIO 2.0.0 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.0.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="JIO 2.0.0 documentation" href="index.html" />
    <link rel="next" title="Downloads" href="download.html" />
    <link rel="prev" title="Welcome to JIO’s documentation!" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="download.html" title="Downloads"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Welcome to JIO’s documentation!"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">JIO 2.0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="introduction">
<h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
<div class="section" id="what-is-jio">
<h2>What is jIO?<a class="headerlink" href="#what-is-jio" title="Permalink to this headline">¶</a></h2>
<p>JIO is a JavaScript library that allows to manage JSON documents on local or
remote storages in asynchronous fashion. jIO is an abstracted API mapped after
CouchDB, that offers connectors to multiple storages, special handlers to
enhance functionality (replication, revisions, indexing) and a query module to
retrieve documents and specific information across storage trees.</p>
</div>
<div class="section" id="how-does-it-work">
<h2>How does it work?<a class="headerlink" href="#how-does-it-work" title="Permalink to this headline">¶</a></h2>
<p>JIO is separated into three parts - jIO core and storage library(ies). The core
is using storage libraries (connectors) to interact with the associated remote
storage servers. Some queries can be used on top of the jIO allDocs method to
query documents based on defined criteria.</p>
<p>JIO uses a job management system, so every method called adds a job into a
queue. The queue is copied in the browser&#8217;s local storage (by default), so it
can be restored in case of a browser crash. Jobs are being invoked
asynchronously with ongoing jobs not being able to re-trigger to prevent
conflicts.</p>
</div>
<div class="section" id="getting-started">
<h2>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h2>
<p>This walkthrough is designed to get you started using a basic jIO instance.</p>
<ol class="arabic">
<li><p class="first">Download jIO core, the storages you want to use as well as the
complex-queries scripts as well as the dependencies required for the storages
you intend to use.  <a class="reference internal" href="download.html#download-fork"><em>[Download &amp; Fork]</em></a></p>
</li>
<li><p class="first">Add the scripts to your HTML page in the following order:</p>
<div class="highlight-html"><pre>&lt;!-- jio core + dependency --&gt;
&lt;script src="sha256.amd.js"&gt;&lt;/script&gt;
&lt;script src="rsvp-custom.js"&gt;&lt;/script&gt;
&lt;script src="jio.js"&gt;&lt;/script&gt;

&lt;!-- storages + dependencies --&gt;
&lt;script src="complex_queries.js"&gt;&lt;/script&gt;
&lt;script src="localstorage.js"&gt;&lt;/script&gt;
&lt;script src="davstorage.js"&gt;&lt;/script&gt;

&lt;script ...&gt;</pre>
</div>
<p>With require js, the main.js will be like this:</p>
<div class="highlight-javascript"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14</pre></div></td><td class="code"><div class="highlight"><pre><span class="nx">require</span><span class="p">.</span><span class="nx">config</span><span class="p">({</span>
    <span class="s2">&quot;paths&quot;</span><span class="o">:</span> <span class="p">{</span>
        <span class="c1">// jio core + dependency</span>

        <span class="c1">// the AMD compatible version of sha256.js -&gt; see Download and Fork</span>
        <span class="s2">&quot;sha256&quot;</span><span class="o">:</span> <span class="s2">&quot;sha256.amd&quot;</span><span class="p">,</span>
        <span class="s2">&quot;rsvp&quot;</span><span class="o">:</span> <span class="s2">&quot;rsvp-custom&quot;</span><span class="p">,</span>
        <span class="s2">&quot;jio&quot;</span><span class="o">:</span> <span class="s2">&quot;jio&quot;</span><span class="p">,</span>
        <span class="c1">// storages + dependencies</span>
        <span class="s2">&quot;complex_queries&quot;</span><span class="o">:</span> <span class="s2">&quot;complex_queries&quot;</span><span class="p">,</span>
        <span class="s2">&quot;localstorage&quot;</span><span class="o">:</span> <span class="s2">&quot;localstorage&quot;</span><span class="p">,</span>
        <span class="s2">&quot;davstorage&quot;</span><span class="o">:</span> <span class="s2">&quot;davstorage&quot;</span>
    <span class="p">}</span>
<span class="p">});</span>
</pre></div>
</td></tr></table></div>
</li>
<li><p class="first">jIO connects to a number of storages and allows to add handlers (or
functions) to specifc storages.
You can use both handlers and available storages to build a storage
tree across which all documents will be maintained and managed by jIO.</p>
<p>See <a class="reference internal" href="available_storages.html#list-of-available-storages"><em>List of Available Storages</em></a>.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// create your jio instance</span>
<span class="kd">var</span> <span class="nx">my_jio</span> <span class="o">=</span> <span class="nx">jIO</span><span class="p">.</span><span class="nx">createJIO</span><span class="p">(</span><span class="nx">storage_description</span><span class="p">);</span>
</pre></div>
</div>
</li>
</ol>
<ol class="arabic">
<li><p class="first">The jIO API provides six main methods to manage documents across the storage(s) specified in your jIO storage tree.</p>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="48%" />
<col width="36%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Method</th>
<th class="head">Sample Call</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><cite>post</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">post</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Creates a new document</td>
</tr>
<tr class="row-odd"><td><cite>put</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">put</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Creates/Updates a document</td>
</tr>
<tr class="row-even"><td><cite>putAttachment</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">putAttachement</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Updates/Adds an attachment to a document</td>
</tr>
<tr class="row-odd"><td><cite>get</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">get</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Reads a document</td>
</tr>
<tr class="row-even"><td><cite>getAttachment</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">getAttachment</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Reads a document attachment</td>
</tr>
<tr class="row-odd"><td><cite>remove</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">remove</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Deletes a document and its attachments</td>
</tr>
<tr class="row-even"><td><cite>removeAttachment</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">removeAttachment</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name other"><span class="pre">attachment</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Deletes a document attachment</td>
</tr>
<tr class="row-odd"><td><cite>allDocs</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">allDocs</span></span><span class="punctuation"><span class="pre">(</span></span><span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Retrieves a list of existing documents</td>
</tr>
<tr class="row-even"><td><cite>check</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">check</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Check the document state</td>
</tr>
<tr class="row-odd"><td><cite>repair</cite></td>
<td><tt class="code js javascript docutils literal"><span class="name other"><span class="pre">my_jio</span></span><span class="punctuation"><span class="pre">.</span></span><span class="name other"><span class="pre">repair</span></span><span class="punctuation"><span class="pre">(</span></span><span class="name builtin"><span class="pre">document</span></span><span class="punctuation"><span class="pre">,</span></span> <span class="punctuation"><span class="pre">[</span></span><span class="name other"><span class="pre">options</span></span><span class="punctuation"><span class="pre">]);</span></span></tt></td>
<td>Repair the document</td>
</tr>
</tbody>
</table>
</li>
</ol>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/jio-logo.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introduction</a><ul>
<li><a class="reference internal" href="#what-is-jio">What is jIO?</a></li>
<li><a class="reference internal" href="#how-does-it-work">How does it work?</a></li>
<li><a class="reference internal" href="#getting-started">Getting started</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">Welcome to JIO&#8217;s documentation!</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="download.html"
                        title="next chapter">Downloads</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/introduction.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="download.html" title="Downloads"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Welcome to JIO’s documentation!"
             >previous</a> |</li>
        <li><a href="index.html">JIO 2.0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2013, Nexedi.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>