Cheatography
https://cheatography.com
A Kuzzle cheat sheet for Javascript
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Where to find docs
REST API |
|
SDK |
|
Real-time filters |
|
Persistant filters |
|
Instantiate a Kuzzle connexion
var kuzzle = new Kuzzle(kuzzleUrl, {defaultIndex: 'defaultIndex'});
// kuzzleUrl example "http://localhost:7512"
|
|
|
dataCollectionFactory
var collection = kuzzle.dataCollectionFactory('optional_Index', 'mandatory_collection');
|
createDocument
kuzzle
.dataCollectionFactory('optional_index', 'mandatory_collection')
.createDocument('optional_document_id', {document: 'object''}, {updateIfExist: true}, function (err, res) {
// callback called once the create action has been completed
// => the result is a KuzzleDocument object
});
|
deleteDocument
kuzzle
.dataCollectionFactory('optional_index', 'mandatory_collection')
.deleteDocument('mandatory_document_id', function (err, res) {
// callback called once the delete action has been completed
// => the result is an array containing the deleted document IDs
});
|
subscribe
var mandatory_filter = {};
var optional_options = {};
var room =
kuzzle
.dataCollectionFactory('optional_index', 'mandatory_collection')
.subscribe(mandatory_filter, optional_options, function (error, result) {
// called each time a new notification on this filter is received
};
|
subscribe options
metadata |
object |
Additional information passed to notifications to other users |
scope |
string (in, out, all, none) default 'all' |
Does the document is entering or leaving the filter scope |
state |
string (pending, done, all) default 'done' |
does the document is yet written or not |
subscribeToSelf |
boolean (default true) |
(Don't) subscribe to your own documents |
users |
string (in, out, all, none) default none |
a user is (un)subscribing to the same filter |
|