# Interact with data

# Install SDKs

  • JavaScript
  • Python
  • cURL
npm install jexia-sdk-js node-fetch ws --save

# Make request

Now let's make simple CRUD to access our Dataset. For this, you can use the REST API or one of our SDKs. Our JS SDK is built on top of the RxJS library, so you can use all the power of this library. Other SDKs can be found on our GitHub.

  • JavaScript
  • Python
  • cURL

Below you can see an example with all the modules imported into the project. These are optional. If you do not need to access Filesets, Project Users (UMSModule) or real-time events, feel free to skip importing them.

import { 
  // required main object
  jexiaClient,
  dataOperations, // To work with DataSets
  //fileOperations, // To work with FileSets 
  //UMSModule, // To work with Project Users
  //realTime // To get real-time notification for data changes and work channels  
} from "jexia-sdk-js/node";

const ds = dataOperations();
//const jfs = fileOperations();
//const ums = new UMSModule();
//const rtc = realTime();

// You need to use your API Key / API Secret which is generated within your Jexia application. 
// Do not forget make a Policy for your API!
jexiaClient().init({
  projectID: "PROJECT_ID",
  key: "API_KEY",
  secret: "API_SECRET",
}, ds); //jfs, ums, rtc

// Now you can run any CRUD operations for your Datasets
const orders = ds.dataset("orders");
const archive = ds.dataset("arch");
const selectQuery = orders
  .select()
  .where(field => field("dislike").isEqualTo(true));  

//const insertQuery = orders.insert([order1, order2]);  
//const updateQuery = orders.update([{ title: "Updated title" }]);  
//const deleteQuery = orders.delete();  

selectQuery.subscribe(records => {
    // You will always get an array of created records, including their 
    // generated IDs (even when inserting a single record) 
  },
  error => {
    // If something goes wrong, the error information is accessible here 
});

# Work from browser

You can work with Jexia platform directly from browser. For this you need to import Jexia SDK through unpkg

<html>
<head>
     <script src="https://unpkg.com/jexia-sdk-js/bundle/browser.umd.min.js"></script>
</head>

and then do similar commands to get data. Below you can find example:

<html>
<head>
     <script src="https://unpkg.com/jexia-sdk-js/bundle/browser.umd.min.js"></script>
</head>
<body>
<i>loading...</i>
<ul></ul>
<script type="text/javascript">
  window.onload = function() {
    if (!jexia) {
      throw new Error("Please inform support team of Jexia.");
    }
    //Initialize dataOperationsModule
    const dataModule = jexia.dataOperations();
    const credentials = {
      projectID: "<your-project-id>",
      key: "<your-project-api-key>",
      secret: "<your-project-api-secret>",
    };
    jexia.jexiaClient().init(credentials, dataModule);
    const postsList = document.querySelector("ul");
    dataModule.dataset("posts")
      .select()
      .subscribe(
        (posts) => {
          posts.forEach((post) => {
            const postTitle = document.createElement("li");
            postTitle.innerText(post.title);
            postsList.appendChild(postTitle);
          });
        },
        (errors)=>{console.log(error)}
      )
  }
</script>
</body>
</html>