Official Kuzzle Javascript SDK
:warning: This SDK version requires Kuzzle v0.6.0 or higher.
About Kuzzle
For UI and linked objects developers, Kuzzle is an open-source solution that handles all the data management (CRUD, real-time storage, search, high-level features, etc).
You can access the Kuzzle repository on Github
SDK Documentation
The complete SDK documentation is available here
Installation
NodeJS
npm install kuzzle-sdk --save
Basic usage
var
Kuzzle = require('kuzzle-sdk'),
kuzzle = new Kuzzle('http://foobar:7512');
var myDoc = {
name: 'Rick Astley',
birthDate: '1966/02/06',
mainActivity: 'Singer',
website: 'http://www.rickastley.co.uk',
comment: 'Never gonna give you up, never gonna let you down'
};
kuzzle
.dataCollectionFactory('people')
.createDocument(myDoc, function(error, response) {
if (error) {
}
});
Hate callbacks & love promises ?
There are promise-based methods for all Kuzzle method allowing a callback. Just suffix those methods with Promise
.
Here is the above example, using promises:
var
Kuzzle = require('kuzzle-sdk'),
kuzzle = new Kuzzle('http://foobar:7512');
var myDoc = {
name: 'Rick Astley',
birthDate: '1966/02/06',
mainActivity: 'Singer',
website: 'http://www.rickastley.co.uk',
comment: 'Never gonna give you up, never gonna let you down'
};
kuzzle
.dataCollectionFactory('people')
.createDocumentPromise(myDoc)
.then(response => {
})
.catch(error => {
});
});
HTML
Using automatic builds
Download the file kuzzle.min.js available in the browser branch of this project.
<script type="text/javascript" src="path/to/kuzzle.min.js"></script>
You are now ready to use Kuzzle:
var
kuzzle = new Kuzzle('http://foobar:7512');
var myDoc = {
name: 'Rick Astley',
birthDate: '1966/02/06',
mainActivity: 'Singer',
website: 'http://www.rickastley.co.uk',
comment: 'Never gonna give you up, never gonna let you down'
};
kuzzle
.dataCollectionFactory('people')
.createDocument(myDoc, function(error, response) {
if (error) {
}
});
Building manually
Clone this github repository and run grunt
. A browser
directory will be created, containing a plain browserified version of this SDK, and a minified version.
License
Apache 2