Javascript SDK

The Javascript SDK enables you to interact with your data within your javascript application. The SDK handles authentication, lets you perform CRUD operations on your dataset and provides you with methods for:

  • filtering (only records satisfying a certain condition will be retrieved/affected);
  • sorting (the records will be sorted by a rule and direction before the action is executed);
  • limiting/offsetting (only a certain number of records, starting from a certain position in the Dataset will be affected);
  • selecting fields to be retrieved (when the user does not want the entire record to be retrieved, only certain columns);
  • relations (records from related datasets, as instructed, will also be affected by the request).

The advantage of using the Javascript SDK is that it allows you to perform a lot of actions like making GET/POST/PUT/DELETE calls and handle authentication by only calling methods. Using the SDK you can perform complex actions on your datasets with only a few lines of code.

Installation

You can easily install this SDK through NPM using the following command:

npm install jexia-sdk-js --save

You can use this SDK server-side or browser-side.

Serverside:

Include the SDK in your project:

const sdk = require('jexia-sdk-js/node');

Browserside:

In order to use the SDK in your browser application the SDK in the <head> section of your html page. In order to get access to the methods of the SDK you need to use the namespace jexia when calling a method.

<script src="path/to/jexia-sdk-js/dist/browser-jexia-sdk.min.js></script>

Example:

 <script type="text/javascript">
      document.getElementById("authorize").onclick = function(){
        //Initialize dataOperationsModule
        let dom = jexia.dataOperations();
        let credentials = {
          projectID: "<your-project-id>",
          key: "<your-api-key>",
          secret: "<your-secret>"
        };
        let jexiaClient = jexia.jexiaClient().init(credentials, dom);
        dom.dataset("posts")
          .select()
          .execute()
          .then(data => {
            for (const item of data) {
              document.write("<ul><li>" + item.title + "</li></ul>");
            }
          })
          .catch(error => console.log(error));
      }
   </script>

API Reference

Methods, classes and interfaces are described in the API Reference.