@@ -29,23 +29,23 @@ npm install slicerjs
2929var SlicingDice = require (' slicerjs' ); // only required for Node.js
3030
3131// Configure the client
32- let client = new SlicingDice ({
32+ const client = new SlicingDice ({
3333 masterKey: ' MASTER_API_KEY' ,
3434 writeKey: ' WRITE_API_KEY' ,
3535 readKey: ' READ_API_KEY'
3636}, usesTestEndpoint = true );
3737
3838// Indexing data
39- var indexData = {
39+ const indexData = {
4040 " user1@slicingdice.com" : {
4141 " age" : 22
4242 },
4343 " auto-create-fields" : true
4444};
45- client .index (indexData, false );
45+ client .index (indexData);
4646
4747// Querying data
48- var queryData = {
48+ const queryData = {
4949 " users-between-20-and-40" : [
5050 {
5151 " age" : {
@@ -57,11 +57,10 @@ var queryData = {
5757 }
5858 ]
5959};
60-
6160client .countEntity (queryData).then ((resp ) => {
6261 console .log (resp);
6362}, (err ) => {
64- console .log (err);
63+ console .err (err);
6564});
6665```
6766
@@ -75,8 +74,8 @@ client.countEntity(queryData).then((resp) => {
7574
7675### Constructor
7776
78- ` SlicingDice(key ) `
79- * ` key (Object)` - [ API key] ( http://panel.slicingdice.com/docs/#api-details-api-connection-api-keys ) to authenticate requests with the SlicingDice API.
77+ ` SlicingDice(apiKeys, usesTestEndpoint ) `
78+ * ` apiKeys (Object)` - [ API key] ( http://panel.slicingdice.com/docs/#api-details-api-connection-api-keys ) to authenticate requests with the SlicingDice API.
8079* ` usesTestEndpoint (boolean) ` - If false the client will send requests to production end-point, otherwise to tests end-point.
8180
8281### ` getProjects() `
@@ -87,14 +86,14 @@ Get all created projects, both active and inactive ones. This method corresponds
8786``` javascript
8887let SlicingDice = require (' slicerjs' );
8988
90- let client = new SlicingDice ({
89+ const client = new SlicingDice ({
9190 masterKey: ' MASTER_API_KEY'
9291}, usesTestEndpoint = false );
9392
9493client .getProjects ().then ((resp ) => {
9594 console .log (resp);
9695}, (err ) => {
97- console .log (err);
96+ console .error (err);
9897});
9998```
10099
@@ -129,14 +128,14 @@ Get all created fields, both active and inactive ones. This method corresponds t
129128``` javascript
130129let SlicingDice = require (' slicerjs' );
131130
132- let client = new SlicingDice ({
131+ const client = new SlicingDice ({
133132 masterKey: ' MASTER_API_KEY'
134133}, usesTestEndpoint = true );
135134
136135client .getFields ().then ((resp ) => {
137136 console .log (resp);
138137}, (err ) => {
139- console .log (err);
138+ console .error (err);
140139});
141140```
142141
@@ -176,7 +175,7 @@ Create a new field. This method corresponds to a [POST request at /field](http:/
176175``` javascript
177176let SlicingDice = require (' slicerjs' );
178177
179- let client = new SlicingDice ({
178+ const client = new SlicingDice ({
180179 masterKey: ' MASTER_API_KEY'
181180}, usesTestEndpoint = true );
182181
@@ -191,7 +190,7 @@ field = {
191190client .createField (field).then ((resp ) => {
192191 console .log (resp);
193192}, (err ) => {
194- console .log (err);
193+ console .error (err);
195194});
196195```
197196
@@ -212,7 +211,7 @@ Index data to existing entities or create new entities, if necessary. This metho
212211``` javascript
213212let SlicingDice = require (' slicerjs' );
214213
215- let client = new SlicingDice ({
214+ const client = new SlicingDice ({
216215 masterKey: ' MASTER_API_KEY' ,
217216 writeKey: ' WRITE_API_KEY'
218217}, usesTestEndpoint = true );
@@ -255,7 +254,7 @@ indexData = {
255254client .index (indexData, autoCreateFields = true ).then ((resp ) => {
256255 console .log (resp);
257256}, (err ) => {
258- console .log (err);
257+ console .error (err);
259258});
260259```
261260
@@ -278,7 +277,7 @@ Verify which entities exist in a project given a list of entity IDs. This method
278277``` javascript
279278let SlicingDice = require (' slicerjs' );
280279
281- let client = new SlicingDice ({
280+ const client = new SlicingDice ({
282281 masterKey: ' MASTER_KEY' ,
283282 readKey: ' READ_KEY'
284283}, usesTestEndpoint = true );
@@ -292,7 +291,7 @@ ids = [
292291client .existsEntity (ids).then ((resp ) => {
293292 console .log (resp);
294293}, (err ) => {
295- console .log (err);
294+ console .error (err);
296295});
297296```
298297
@@ -320,15 +319,15 @@ Count the number of indexed entities. This method corresponds to a [GET request
320319``` javascript
321320let SlicingDice = require (' slicerjs' );
322321
323- let client = new SlicingDice ({
322+ const client = new SlicingDice ({
324323 masterKey: ' MASTER_KEY' ,
325324 readKey: ' READ_KEY'
326325}, usesTestEndpoint = true );
327326
328327client .countEntityTotal ().then ((resp ) => {
329328 console .log (resp);
330329}, (err ) => {
331- console .log (err);
330+ console .error (err);
332331});
333332```
334333
@@ -352,7 +351,7 @@ Count the number of entities attending the given query. This method corresponds
352351``` javascript
353352let SlicingDice = require (' slicerjs' );
354353
355- let client = new SlicingDice ({
354+ const client = new SlicingDice ({
356355 masterKey: ' MASTER_KEY' ,
357356 readKey: ' READ_KEY'
358357}, usesTestEndpoint = true );
@@ -384,7 +383,7 @@ query = {
384383client .countEntity (query).then ((resp ) => {
385384 console .log (resp);
386385}, (err ) => {
387- console .log (err);
386+ console .error (err);
388387});
389388```
390389
@@ -409,7 +408,7 @@ Count the number of occurrences for time-series events attending the given query
409408``` javascript
410409let SlicingDice = require (' slicerjs' );
411410
412- let client = new SlicingDice ({
411+ const client = new SlicingDice ({
413412 masterKey: ' MASTER_KEY' ,
414413 readKey: ' READ_KEY'
415414}, usesTestEndpoint = true );
@@ -443,7 +442,7 @@ query = {
443442client .countEvent (query).then ((resp ) => {
444443 console .log (resp);
445444}, (err ) => {
446- console .log (err);
445+ console .error (err);
447446});
448447```
449448
@@ -468,7 +467,7 @@ Return the top values for entities attending the given query. This method corres
468467``` javascript
469468let SlicingDice = require (' slicerjs' );
470469
471- let client = new SlicingDice ({
470+ const client = new SlicingDice ({
472471 masterKey: ' MASTER_KEY' ,
473472 readKey: ' READ_KEY'
474473}, usesTestEndpoint = true );
@@ -485,7 +484,7 @@ query = {
485484client .topValues (query).then ((resp ) => {
486485 console .log (resp);
487486}, (err ) => {
488- console .log (err);
487+ console .error (err);
489488});
490489```
491490
@@ -536,7 +535,7 @@ Return the aggregation of all fields in the given query. This method corresponds
536535``` javascript
537536let SlicingDice = require (' slicerjs' );
538537
539- let client = new SlicingDice ({
538+ const client = new SlicingDice ({
540539 masterKey: ' MASTER_KEY' ,
541540 readKey: ' READ_KEY'
542541}, usesTestEndpoint = true );
@@ -559,7 +558,7 @@ query = {
559558client .aggregation (query).then ((resp ) => {
560559 console .log (resp);
561560}, (err ) => {
562- console .log (err);
561+ console .error (err);
563562});
564563```
565564
@@ -598,14 +597,14 @@ Get all saved queries. This method corresponds to a [GET request at /query/saved
598597``` javascript
599598let SlicingDice = require (' slicerjs' );
600599
601- let client = new SlicingDice ({
600+ const client = new SlicingDice ({
602601 masterKey: ' MASTER_KEY'
603602}, usesTestEndpoint = true );
604603
605604client .getSavedQueries ().then ((resp ) => {
606605 console .log (resp);
607606}, (err ) => {
608- console .log (err);
607+ console .error (err);
609608});
610609```
611610
@@ -657,7 +656,7 @@ Create a saved query at SlicingDice. This method corresponds to a [POST request
657656``` javascript
658657let SlicingDice = require (' slicerjs' );
659658
660- let client = new SlicingDice ({
659+ const client = new SlicingDice ({
661660 masterKey: ' MASTER_KEY'
662661}, usesTestEndpoint = true );
663662
@@ -683,7 +682,7 @@ query = {
683682client .createSavedQuery (query).then ((resp ) => {
684683 console .log (resp);
685684}, (err ) => {
686- console .log (err);
685+ console .error (err);
687686});
688687```
689688
@@ -720,7 +719,7 @@ Update an existing saved query at SlicingDice. This method corresponds to a [PUT
720719``` javascript
721720let SlicingDice = require (' slicerjs' );
722721
723- let client = new SlicingDice ({
722+ const client = new SlicingDice ({
724723 masterKey: ' MASTER_KEY'
725724}, usesTestEndpoint = true );
726725
@@ -745,7 +744,7 @@ newQuery = {
745744client .updateSavedQuery (" my-saved-query" , newQuery).then ((resp ) => {
746745 console .log (resp);
747746}, (err ) => {
748- console .log (err);
747+ console .error (err);
749748});
750749```
751750
@@ -781,15 +780,15 @@ Executed a saved query at SlicingDice. This method corresponds to a [GET request
781780``` javascript
782781let SlicingDice = require (' slicerjs' );
783782
784- let client = new SlicingDice ({
783+ const client = new SlicingDice ({
785784 masterKey: ' MASTER_KEY' ,
786785 readKey: ' READ_KEY'
787786}, usesTestEndpoint = true );
788787
789788client .getSavedQuery (" my-saved-query" ).then ((resp ) => {
790789 console .log (resp);
791790}, (err ) => {
792- console .log (err);
791+ console .error (err);
793792});
794793```
795794
@@ -827,14 +826,14 @@ Delete a saved query at SlicingDice. This method corresponds to a [DELETE reques
827826``` javascript
828827let SlicingDice = require (' slicerjs' );
829828
830- let client = new SlicingDice ({
829+ const client = new SlicingDice ({
831830 masterKey: ' MASTER_KEY'
832831}, usesTestEndpoint = true );
833832
834833client .deleteSavedQuery (" my-saved-query" ).then ((resp ) => {
835834 console .log (resp);
836835}, (err ) => {
837- console .log (err);
836+ console .error (err);
838837});
839838```
840839
@@ -871,7 +870,7 @@ Retrieve indexed values for entities attending the given query. This method corr
871870``` javascript
872871let SlicingDice = require (' slicerjs' );
873872
874- let client = new SlicingDice ({
873+ const client = new SlicingDice ({
875874 masterKey: ' MASTER_KEY' ,
876875 readKey: ' READ_KEY'
877876}, usesTestEndpoint = true );
@@ -897,7 +896,7 @@ query = {
897896client .result (query).then ((resp ) => {
898897 console .log (resp);
899898}, (err ) => {
900- console .log (err);
899+ console .error (err);
901900});
902901```
903902
@@ -930,7 +929,7 @@ Retrieve indexed values as well as their relevance for entities attending the gi
930929``` javascript
931930let SlicingDice = require (' slicerjs' );
932931
933- let client = new SlicingDice ({
932+ const client = new SlicingDice ({
934933 masterKey: ' MASTER_KEY' ,
935934 readKey: ' READ_KEY'
936935}, usesTestEndpoint = true );
@@ -956,7 +955,7 @@ query = {
956955client .score (query).then ((resp ) => {
957956 console .log (resp);
958957}, (err ) => {
959- console .log (err);
958+ console .error (err);
960959});
961960```
962961
0 commit comments