Introduction

What is jIO?

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.

How does it work?

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.

JIO uses a job management system, so every method called adds a job into a queue. The queue is copied in the browser’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.

Getting started

This walkthrough is designed to get you started using a basic jIO instance.

  1. 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. [Download & Fork]

  2. Add the scripts to your HTML page in the following order:

    <!-- jio core + dependency -->
    <script src="sha256.amd.js"></script>
    <script src="rsvp-custom.js"></script>
    <script src="jio.js"></script>
    
    <!-- storages + dependencies -->
    <script src="complex_queries.js"></script>
    <script src="localstorage.js"></script>
    <script src="davstorage.js"></script>
    
    <script ...>

    With require js, the main.js will be like this:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    require.config({
        "paths": {
            // jio core + dependency
    
            // the AMD compatible version of sha256.js -> see Download and Fork
            "sha256": "sha256.amd",
            "rsvp": "rsvp-custom",
            "jio": "jio",
            // storages + dependencies
            "complex_queries": "complex_queries",
            "localstorage": "localstorage",
            "davstorage": "davstorage"
        }
    });
    
  3. 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.

    See List of Available Storages.

    // create your jio instance
    var my_jio = jIO.createJIO(storage_description);
    
  1. The jIO API provides six main methods to manage documents across the storage(s) specified in your jIO storage tree.

    Method Sample Call Description
    post my_jio.post(document, [options]); Creates a new document
    put my_jio.put(document, [options]); Creates/Updates a document
    putAttachment my_jio.putAttachement(attachment, [options]); Updates/Adds an attachment to a document
    get my_jio.get(document, [options]); Reads a document
    getAttachment my_jio.getAttachment(attachment, [options]); Reads a document attachment
    remove my_jio.remove(document, [options]); Deletes a document and its attachments
    removeAttachment my_jio.removeAttachment(attachment, [options]); Deletes a document attachment
    allDocs my_jio.allDocs([options]); Retrieves a list of existing documents
    check my_jio.check(document, [options]); Check the document state
    repair my_jio.repair(document, [options]); Repair the document

Table Of Contents

Previous topic

Welcome to JIO’s documentation!

Next topic

Downloads

This Page