Jexia SDK currently exposes the following features:
Currently SDK is focused on consuming data. In order to manage data schema (creating Datasets, adding fields to them, etc.) you need to use our web application. We suggest you read the guide Start your first project.
The user can execute the following operations on records:
Executing an operation on a set of records is done through a Query. Depending on their type, Queries give the user access to some (or all) of the following options:
Important to notice that all these features are handled server-side.
Please keep in mind that this quick start guide uses ECMAScript 8 or sometimes TypeScript syntaxes.
The examples are made with a simple data schema in mind: think a basic social media platform where users can write posts and/or comments to posts. A post can be related to any number of comments, while each post and each comment has a user as author.
import { jexiaClient } from "jexia-sdk-js/node";import { jexiaClient } from "jexia-sdk-js/browser";The jexiaClient() function will return a Promise of the Client class. You can provide a custom fetch standard compliant function as a parameter, as default we are using node-fetch package at NodeJS, and the native browser's fetch implementation.
import { Client } from "jexia-sdk-js";
import { jexiaClient } from "jexia-sdk-js/node";
const clientPromise: Promise<Client> = jexiaClient()
.init({
projectID: "<your-project-id>",
key: "<your-project-api-key>",
secret: "<your-project-api-secret>",
});
clientPromise.then((client: Client) => {
// you have been succesfully logged in!
}).catch((error: Error) => {
// uh-oh, there was a problem logging in, check error.message for more info
});Jexia SDK is built as a set of modules structured around a core entity (the Client class used above).
In order to use a module you need to:
Client when calling the .init() methodThe example below will show how to initialize SDK using Datasets Module. The modules await the client initialization before make any operations, so you don't need to manually await for client's initialization Promise.
import { jexiaClient, dataOperations } from "jexia-sdk-js/node";
const dataModule = dataOperations();
jexiaClient().init(credentials, dataModule);
dataModule.dataset("posts")
.select()
.execute()
.then(data => {
// you have been succesfully logged in!
// you can start using the dataModule variable to operate on records here
}).catch(error => {
// uh-oh, there was a problem logging in, check the error.message for more info
});The Client class exposes a method called .terminate(). Use this to clear up resources used by the Client and any modules you initialized along with it (Client will terminate any modules you supplied on initialization, so you don't have to pass them.)
[..]
client
.terminate()
.then(terminatedClient => {
// everything has been cleared
}).catch(error => {
// something went wrong when cleaning up
});
[..]