autonoma-datamanager
v0.1.3
Published
Autonoma Datamanager
Downloads
6
Readme
Autonoma Datamanager
This tool enables third party developers to interact with the Autonoma database in a easy to use manner.
Installation
Install the Autonoma Datamanager with npm
npm install autonoma-datamanager
After installation you have to copy the worker.js file (/node_modules/autonoma-datamanager/src/worker/worker.js) into your public directory. It must be accessible from root (E.g.: https://myDomain.com/worker.js)
Initialisation
import {initDatamanager} from "autonoma-datamanager";
initDatamanager(Your_Autonoma_Token);
The datamanger is linked to the window object and accessible through window.$dataManager
afterwards.
Your can find your Autonoma Token in your Autonoma Profile. Click here for more information.
Usage
Create a function that you call when you want to load data. Inside this function, the Datamanager tries to load the data and call itself if data has changed.
// This example loads
function loadData() {
// GraphQL styled query
const query = `{
name
image
id
}`;
// Every instance needs a unique ID
let id = (Math.random() + 1).toString(36).substring(7);
window.$dataManager
.get(id, "device", "*", query, () => {
this.loadExample();
})
.then((response) => {
// Do something with the response
})
.catch(() => {
// Some error occured
});
}
License
Model reference documentation
Here you can find the models and all relations that can be queried. Documentation